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
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 ContentQueryParams { id?: Filter; contentType?: Filter; language?: Filter; `fields.${string}`?: Filter; // Allows filtering by specific field values // For example: 'fields.slug': 'my-post' includeRelatedContent?: boolean; // Whether to include related content in the response (only first level relations}| Name | Description |
|---|---|
id | The ID of the content you want to retrieve. This parameter must be a string. Example: /content?id=1234You can find the content id in your project’s Content tab. |
contentType | The model of the content to retrieve. Example: /content?id=1234&contentType=post |
language | The 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%20mundoRetrieves content with fields matching the specified values. |
includeRelatedContent | A boolean indicating whether to include related content in the response. This is useful when you want to fetch content along with its related items (only first level relations). Example: /content?id=1234&includeRelatedContent=true |
type Filter = | string | { in?: string[]; };| Name | Description |
|---|---|
string | Filters content where the parameter equals the specified value.Example: /content?id=1234&contentType=postRetrieves content where the model is equal to post. |
in | Filters content where the parameter matches any of the provided values. Example: /content?id=1234&language[in]=es,enRetrieves content fields matching es and/or en. |
Example:
// Retrieve a single content item filtering by model and languagecurl 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 anidand aname.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
| Code | Description |
|---|---|
| 200 | The request was successfully processed and the content was returned. |
| 401 | Unauthorized. The access token is invalid or has expired. |
| 500 | Internal server error. An error occurred while processing the request. |