Need clarity on what Content API returns

Hello,

In the company I work for, we’re looking at making use of Ghost for the company blog, and we want to do so via the API.
I’ve gone through the documentation and I see that the API returns JSON, but the JavaScript Content API Client Library has this part that confuses me,

api.posts.read({slug: 'something'}, {formats: ['html', 'plaintext']});

Is that for cases where you want a format different from the “default” format which I presume is JSON?

Thanks.

By default the content api includes a html field - which is the html of the post. You can also request the plaintext which will add a plaintext field

source: https://ghost.org/docs/api/v3/content/#formats

I think you’re getting confused between the API response format and the content format.

Ghost’s API always returns JSON, but you can choose what format you want your content in.

By far and away the easiest way to understand this is to just try the API.

The content API docs have a working example here:

If you run this curl command, or easier copy and paste the URL into your browser you can instantly see what the API returns for our demo site:

Here is the default response:

https://demo.ghost.io/ghost/api/v3/content/posts/?key=22444f78447824223cefc48062

And here’s the same request but with both the html and plaintext formats returned:

https://demo.ghost.io/ghost/api/v3/content/posts/?key=22444f78447824223cefc48062&formats=html,plaintext