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/contents/<id> --header 'Authorization: Bearer YOUR_ACCESS_TOKEN'

URL Params

  • id: The ID of the content you want to retrieve. This parameter is required and must be a string.

Query Params

This endpoint accepts the following query parameters:

interface QueryParams {
contentType?: Filter;
language?: Filter;
}
NameDescription
contentTypeThe model of the content to retrieve.
Example: /contents/1234?contentType=post
languageThe language of the content to retrieve.
Only fields in the selected language will be returned.
Example: /contents/1234?language=es
type Filter =
| string
| {
in?: string[];
};
NameDescription
stringFilters content where the parameter equals the specified value.
Example: /contents/1234?contentType=post
Retrieves content where the model is equal to post.
inFilters content where the parameter matches any of the provided values.
Example: /contents/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/contents/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.