How to fetch component keys from team library?

I am trying to make a plugin to download all components from a selected team library.
(without having the user to import the components in the document manually, or hardcoding all the component keys)

I found a way to fetch the “variable collection” from a team library, but it seems there is no possible way to directly fetch the “components” from a team library.

So I am trying to make the plugin to

  1. import the components into the document, and then
  2. fetch them from the document

I am trying to find a way to do step 1, which I probably will use importComponentByKeyAsync, but I need a way to find the component keys with the plugin.

Are there any possible ways to do this?

If you are running the plugin in a non-library file, you can get the keys for components and component sets using the REST API.
This seems to solve the problem! Thank you