How to use Kibana API in plugin development

Hi @Fabio-sama, inside Kibana plugin you shouldn't use REST API for this, but should use other plugins instead.

In this case you need to depend on data plugin which provides services for working with index patterns (they are called data views now in main branch).

Not sure if you've seen, but we have a bunch of examples plugins. We don't have many with server-side code though, but this one might be useful:

To run kibana with these plugins start development with: yarn start --run-examples and you will have Developer Examples app in a side menu

Similar how that examples plugins uses data.search server side, you'll need to use data.indexPatterns