2

Does anyone know if there is an API for CRAFT 3 where I can authenticate to and query (CRUD) all the elements (channels, etc.) I have created on it?

Thanks.

2

You may have a look at the headless documentation which offers a few solutions / ways such as a GraphQL API, REST-API & a JSON API

  • I have tried to use the rest api but I cant make it work. Do you have any link or tutorial for getting to work? – Rafael Mora Oct 26 at 14:34
  • 1
    You can try this tutorial/video out to get started mijingo.com/blog/what-is-the-element-api-in-craft-cms. It is for an older version, but still holds up rather well. You will have to define the routes that you want and it is only designed for read access. – Jason McCallister Oct 26 at 16:32
  • What if I want to change (update) the something in the DB? – Rafael Mora Oct 26 at 22:59
2

Currently, neither the Element API plugin nor the native Craft GraphQL implementation supports writes or updates.

It is on the Craft 4.0 backlog to have mutations support in the native GraphQL implementation. https://github.com/craftcms/cms/issues/4835

There is a 3rd party CraftQL plugin that does support mutations.

If you want the ability to write in a REST context, I'd suggest watching this video: https://dotall.com/sessions/how-to-create-a-full-rest-api-with-craft-3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.