Loading...

Using the API

Once authentication is set up, you can start making API requests to access your content.

Example code

The following is a simple example of fetching content using the JSON:API:

// JavaScript example using fetch async function getArticles() { // First, get the access token const tokenResponse = await fetch('https://your-site.com/oauth/token', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, body: new URLSearchParams({ 'grant_type': 'client_credentials', 'client_id': 'YOUR_CLIENT_ID', 'client_secret': 'YOUR_CLIENT_SECRET', }) }); const { access_token } = await tokenResponse.json(); // Then use the token to fetch articles const articlesResponse = await fetch('https://your-site.com/jsonapi/node/article?include=field_image&sort=-created', { headers: { 'Authorization': `Bearer ${access_token}`, 'Accept': 'application/vnd.api+json', } }); return articlesResponse.json(); }

Did not find what you were looking for?

If this content did not answer your questions, try searching or contacting our support team for further assistance.

Back to Section navigation
Back to Site navigation