Skip to content

Content

Retrieves a single content item from a project.

This endpoint is useful for retrieving a specific piece of content, such as an article or blog post.

Endpoint

shell
curl https://api.contentisland.net/api/1.0/content --header 'Authorization: Bearer YOUR_ACCESS_TOKEN'

Query Params

This endpoint accepts the following query parameters:

interface QueryParams {
id?: Filter;
contentType?: Filter;
language?: Filter;
`fields.${string}`?: Filter; // Allows filtering by specific field values
// For example: 'fields.slug': 'my-post'
}
NameDescription
idThe ID of the content you want to retrieve.
This parameter must be a string.
Example: /content?id=1234
You can find the content id in your project’s Content tab.
contentTypeThe model of the content to retrieve.
Example: /content?id=1234&contentType=post
languageThe language of the content to retrieve.
Only fields in the selected language will be returned.
Example: /content?id=1234&language=es
fields.${string}Allows filtering by specific field values.
Examples:
/content?fields.slug=my-post
/content?fields.title[in]=hello%20world,hola%20mundo
Retrieves content with fields matching the specified values.
type Filter =
| string
| {
in?: string[];
};
NameDescription
stringFilters content where the parameter equals the specified value.
Example: /content?id=1234&contentType=post
Retrieves content where the model is equal to post.
inFilters content where the parameter matches any of the provided values.
Example: /content?id=1234&language[in]=es,en
Retrieves content fields matching es and/or en.

Example:

shell
// Retrieve a single content item filtering by model and language
curl https://api.contentisland.net/api/1.0/content?id=1234&contentType=post&language[in]=es,en --header 'Authorization: Bearer YOUR_ACCESS_TOKEN'

Response

The response is a JSON object containing information about the content. It has the following structure:

export interface Content {
id: string;
contentType: { id: string; name: string };
lastUpdate: Date;
fields: Field[];
}
export interface Field {
id: string;
name: string;
value: any;
type: FieldType;
isArray: boolean;
language: string;
}
  • id: The content ID.
  • contentType: The model to which the content belongs. Contains an id and a name.
  • lastUpdate: The timestamp of the last update.
  • fields: An array of objects representing the content fields.

Example:

{
"id": "1",
"contentType": {
"id": "100",
"name": "post"
},
"lastUpdate": "2023-10-01T12:00:00Z",
"fields": [
{
"id": "111",
"name": "title",
"value": "Hola Mundo",
"type": "short-text",
"isArray": false,
"language": "es"
},
{
"id": "222",
"name": "body",
"value": "Este es el cuerpo del post en markdown.",
"type": "long-text",
"isArray": false,
"language": "es"
},
{ "id": "333", "name": "order", "value": 1, "type": "number", "isArray": false, "language": "es" }
]
}

Status Codes

CodeDescription
200The request was successfully processed and the content was returned.
401Unauthorized. The access token is invalid or has expired.
500Internal server error. An error occurred while processing the request.