I’m trying to create a Contentful app that will provide my content admin when they post something live the progress of the Gatsby Cloud build, and potentially report on build errors so they can reach out to me (the developer) to find out if something might have gone wrong. Right now, a content admin could just post the new entry and would know nothing about the build status, and would have no idea when they can start panicing if their new post is still not live after some time waiting.
I might have missed something, but I haven’t found a public Gatsby Cloud API, the only thing that’s reachable via an external app is Preview, which already has a Contentful App, but what I’m looking for is the ability to show a dashboard with live build status following the publishing of a post.
As of now, there’s no publicly documented API for Gatsby Cloud. You might have to use the same API calls used by the UI. Currently, there’s a feature being worked on: API tokens, which would allow your to create a token to call those API endpoints. But till then, you should be able to use the authentication data from the dev tools.
Would you mind being a bit more precise with the information you provide please? What are “the same API calls used by the UI” - which UI? Is that Contentful? What API calls would correspond to getting responses of successful or failed builds? On one sire you’re telling me to use the API calls, then you’re talking about a new future which will be the only one allowing me to do so? What do you mean by “use the authentication data from the dev tools”, what authentication data, and how do I get it from dev tools? Is this documented somewhere?
Gatsby Cloud’s UI makes some API calls to the backend, which you can inspect from dev tools like:
Almost all requests are handled by a single endpoint:
graphql and you can also inspect the
Payload tab to find out the query being used. By trial and error you’d have to find the correct API needed for your use case.
I did not say that’s the only thing. Personal Access Tokens are a recommended way by most of the sites and services to access the API, so that you don’t have to use your actual credentials and you can delete a token safely in case it leaks. Personal Access Tokens are not publicly available right now, but you can still call the API just like Gatsby Cloud UI does.
If you check out request headers:
you’d find the header. You need to use the value of that header to access the API right now (which would later be replaced with Personal Access Tokens).
None of this is documented anywhere and Gatsby Cloud’s API, as I mentioned is not publicly available in a documented format. You’d have to reverse-engineer it unfortunately.
Sorry for the delay. Okay, I’ll give it a go and see. Thanks for your help.
Sorry, I had planned to try this, but there is quite some work that needs to precede it. In the meantime you may be able to answer a question: what happens to CORS? I mean if I launch this from Contentful, will the browser not complain about same-origin, especially considering this is not a public API?