Search code examples
strapi

How can we get all the content type structures and details from strapi using the Rest API?


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"?


Solution

  • 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.