How to get results of subcategories also?(WP Rest Api v2)

This answer has what you want https://wordpress.stackexchange.com/a/314152/49962

WP already does this out of the box thanks to the include_children parameter of tax_query which is true by default.

So you do not need to tell it the sub-terms, just do something like this:

/wp/v2/posts?categories=1

Where categories=1 is the parent category ID