Reputation: 3696
The Strapi REST API allows reading any data from the CMS provided that we specify statically the type of content we want to read from
Are there any ways of getting the list of content types from the API? So instead of having to know that the strapi CMS has "articles" and "reviews" as content types, is there an API that can tell us that the strapi CMS has "articles" and "reviews"?
Upvotes: 3
Views: 3391
Reputation: 3696
In order to get the structure of the content types you need to make a request to api/content-type-builder/content-types
using an API token that has full access. The full access token can be generated in the admin/settings/api-tokens
area of the strapi backoffice.
Here's a CRUL of the request:
curl --location --request GET 'http://localhost:1337/api/content-type-builder/content-types' \
--header 'Authorization: Bearer <FULL ACCESS TOKEN>'
PS: The OpenAI chatbot helped me discover this. It's not specified in the docs, yet it works.
Upvotes: 5
Reputation: 1934
you request sounds like exactly what is graphql server.
Since I don’t use graphql, and not sure if it’s capable for you, I can only recommend doing some bulk controller or a plugin, and then using strapi
object return the information you want directly from an api route.
I haven’t seen such functionality built in, however you can check this https://github.com/strapi/strapi/tree/main/packages/core/admin/admin/src/hooks sources as most likely place where you can find how it handled originally by strapi…
Also there is really nice command:
strapi list
That basically gives you all the stuff you have access to. It’s really nice to use it to check what is available in internals.
https://docs.strapi.io/developer-docs/latest/developer-resources/cli/CLI.html#strapi-routes-list
Upvotes: 1