List Entries
This endpoint retrieves a list of content entries from a specific collection. By default, it returns all entries. To receive a paginated response, you must use the paginate query parameter.
Endpoint
[GET]
/{collection_slug}Path Parameters
| Name | Required | Description |
|---|---|---|
collection_slug | Yes | The unique slug of the collection. |
Query Parameters
| Name | Type | Description |
|---|---|---|
first | integer | The first entry to return. /api/posts?first |
paginate | integer | The number of entries per page. If provided, the response will be a paginated object. If omitted, it will be a simple array. Ex: /api/posts?paginate=10 |
page | integer | The page number for pagination. Only used when paginate is active. Defaults to 1. /api/posts?page=1 |
locale | string | Filters entries by a specific locale code (e.g., en). /api/posts?locale=en |
state | string | Controls the publication state. Options: published (default), only_draft, with_draft. /api/posts?state=published |
where[field] | mixed | Filters entries based on field values. See Advanced Filtering. /api/posts?where[title]=Hello |
exclude | string | Comma-separated field names (or exclude[]) to exclude from the response. Works for top-level fields, group fields, and nested group child fields. /api/posts?exclude=content,title |
timestamps | boolean | If present, includes created_at and updated_at in the response. /api/posts?timestamps |
count | boolean | If present, returns only { "count": number } for the current filters. It ignores limit/offset/paginate windows and reports the full filtered total. /api/posts?count |
sort | string | Sorts the entries by a specific field. Format: field:direction. Example: title:asc. /api/posts?sort=title:asc |
limit | integer | Limits the number of entries returned. If paginate is present, this will be ignored. /api/posts?limit=10 |
offset | integer | Offsets the entries by a specific number. If paginate is present, this will be ignored. Should be used with limit. Otherwise, it will be ignored. /api/posts?offset=10&limit=10 |
Headers
| Name | Required | Description |
|---|---|---|
Accept | Yes | Specifies the response content type. Must be application/json. |
Authorization | Conditionally | Required for private APIs. Must be a Bearer token. |
project-id | Yes | The unique identifier for the project. |
Example Requests (Paginated)
https://your-domain.com/api/{collection_slug}?paginate={number}&page={number}import { createClient } from '@elmapicms/js-sdk';
const client = createClient(
'https://your-domain.com/api',
'YOUR_API_TOKEN',
'YOUR_PROJECT_UUID'
);
// Get paginated entries
const entries = await client.getEntries('blog-posts', {
paginate: 10,
page: 1
});const collectionSlug = 'blog-posts';
axios.get(`https://your-domain.com/api/${collectionSlug}?paginate=10&page=1`, {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_API_TOKEN',
'project-id': 'YOUR_PROJECT_UUID'
}
});use Illuminate\Support\Facades\Http;
$collectionSlug = 'blog-posts';
$response = Http::withHeaders([
'Accept' => 'application/json',
'Authorization' => 'Bearer YOUR_API_TOKEN',
'project-id' => 'YOUR_PROJECT_UUID'
])->get("https://your-domain.com/api/{$collectionSlug}", [
'paginate' => 10,
'page' => 1
]);import React, { useState, useEffect } from 'react';
function PaginatedEntries({ collectionSlug }) {
const [response, setResponse] = useState(null);
const [error, setError] = useState(null);
useEffect(() => {
const fetchEntries = async () => {
try {
const res = await fetch(`https://your-domain.com/api/${collectionSlug}?paginate=10&page=1`, {
method: 'GET',
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_API_TOKEN',
'project-id': 'YOUR_PROJECT_UUID'
}
});
if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`);
setResponse(await res.json());
} catch (e) {
setError(e.message);
}
};
fetchEntries();
}, [collectionSlug]);
if (error) return <div>Error: {error}</div>;
if (!response) return <div>Loading...</div>;
return (
<div>
<ul>
{response.data.map(entry => (
<li key={entry.uuid}>{entry.fields.title}</li>
))}
</ul>
{/* Add pagination controls using response.meta and response.links */}
</div>
);
}<template>
<div v-if="error">Error: {{ error }}</div>
<div v-else-if="response">
<ul>
<li v-for="entry in response.data" :key="entry.uuid">
{{ entry.fields.title }}
</li>
</ul>
<!-- Add pagination controls using response.meta and response.links -->
</div>
<div v-else>Loading...</div>
</template>
<script setup>
import { ref, onMounted, defineProps } from 'vue';
const props = defineProps({ collectionSlug: { type: String, required: true } });
const response = ref(null);
const error = ref(null);
onMounted(async () => {
try {
const res = await fetch(`https://your-domain.com/api/${props.collectionSlug}?paginate=10&page=1`, {
method: 'GET',
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_API_TOKEN',
'project-id': 'YOUR_PROJECT_UUID'
}
});
if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`);
response.value = await res.json();
} catch (e) {
error.value = e.message;
}
});
</script>curl -G "https://your-domain.com/api/blog-posts" \
-d "paginate=10" \
-d "page=1" \
-H "Accept: application/json" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "project-id: YOUR_PROJECT_UUID"Example Requests (Non-Paginated)
https://your-domain.com/api/{collection_slug}import { createClient } from '@elmapicms/js-sdk';
const client = createClient(
'https://your-domain.com/api',
'YOUR_API_TOKEN',
'YOUR_PROJECT_UUID'
);
// Get all entries (non-paginated)
const entries = await client.getEntries('blog-posts');const collectionSlug = 'blog-posts';
axios.get(`https://your-domain.com/api/${collectionSlug}`, {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_API_TOKEN',
'project-id': 'YOUR_PROJECT_UUID'
}
});use Illuminate\Support\Facades\Http;
$collectionSlug = 'blog-posts';
$response = Http::withHeaders([
'Accept' => 'application/json',
'Authorization' => 'Bearer YOUR_API_TOKEN',
'project-id' => 'YOUR_PROJECT_UUID'
])->get("https://your-domain.com/api/{$collectionSlug}");import React, { useState, useEffect } from 'react';
function AllEntries({ collectionSlug }) {
const [entries, setEntries] = useState([]);
const [error, setError] = useState(null);
useEffect(() => {
const fetchEntries = async () => {
try {
const res = await fetch(`https://your-domain.com/api/${collectionSlug}`, {
method: 'GET',
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_API_TOKEN',
'project-id': 'YOUR_PROJECT_UUID'
}
});
if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`);
setEntries(await res.json());
} catch (e) {
setError(e.message);
}
};
fetchEntries();
}, [collectionSlug]);
if (error) return <div>Error: {error}</div>;
if (!entries.length) return <div>Loading...</div>;
return (
<ul>
{entries.map(entry => (
<li key={entry.uuid}>{entry.fields.title}</li>
))}
</ul>
);
}<template>
<div v-if="error">Error: {{ error }}</div>
<ul v-else-if="entries.length">
<li v-for="entry in entries" :key="entry.uuid">
{{ entry.fields.title }}
</li>
</ul>
<div v-else>Loading...</div>
</template>
<script setup>
import { ref, onMounted, defineProps } from 'vue';
const props = defineProps({ collectionSlug: { type: String, required: true } });
const entries = ref([]);
const error = ref(null);
onMounted(async () => {
try {
const res = await fetch(`https://your-domain.com/api/${props.collectionSlug}`, {
method: 'GET',
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_API_TOKEN',
'project-id': 'YOUR_PROJECT_UUID'
}
});
if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`);
entries.value = await res.json();
} catch (e) {
error.value = e.message;
}
});
</script>curl -G "https://your-domain.com/api/blog-posts" \
-H "Accept: application/json" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "project-id: YOUR_PROJECT_UUID"Example Requests (Other Filtering Options)
https://your-domain.com/api/{collection_slug}?state=with_draft&locale=fr&exclude[]=contentimport { createClient } from '@elmapicms/js-sdk';
const client = createClient(
'https://your-domain.com/api',
'YOUR_API_TOKEN',
'YOUR_PROJECT_UUID'
);
// Get entries with filtering options
const entries = await client.getEntries('blog-posts', {
state: 'with_draft',
locale: 'fr',
exclude: 'content,author_bio'
});const collectionSlug = 'blog-posts';
axios.get(`https://your-domain.com/api/${collectionSlug}`, {
params: {
state: 'with_draft',
locale: 'fr',
'exclude[]': ['content', 'author_bio']
},
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_API_TOKEN',
'project-id': 'YOUR_PROJECT_UUID'
}
});use Illuminate\Support\Facades\Http;
$collectionSlug = 'blog-posts';
$response = Http::withHeaders([
'Accept' => 'application/json',
'Authorization' => 'Bearer YOUR_API_TOKEN',
'project-id' => 'YOUR_PROJECT_UUID'
])->get("https://your-domain.com/api/{$collectionSlug}", [
'state' => 'with_draft',
'locale' => 'fr',
'exclude' => ['content', 'author_bio']
]);curl -G "https://your-domain.com/api/blog-posts" \
-d "state=with_draft" \
-d "locale=fr" \
-d "exclude[]=content" \
-d "exclude[]=author_bio" \
-H "Accept: application/json" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "project-id: YOUR_PROJECT_UUID"Singleton Collections
For singleton collections, this endpoint returns a single object (not an array):
- If
localeis provided, that locale is used. - If
localeis omitted, the project'sdefault_localeis used.
Responses
200: Success (Paginated)
Returns a paginated list of content entries when the paginate parameter is used.
{
"data": [
{
"uuid": "e3a4b1c2-d5e6-f7g8-h9i0-j1k2l3m4n5o6",
"locale": "en",
"published_at": "2023-10-28T12:00:00Z",
"fields": {
"title": "My First Blog Post"
}
}
],
"links": {
"first": "https://your-domain.com/api/blog-posts?page=1",
"last": "https://your-domain.com/api/blog-posts?page=5",
"prev": null,
"next": "https://your-domain.com/api/blog-posts?page=2"
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 5,
"path": "https://your-domain.com/api/blog-posts",
"per_page": 10,
"to": 10,
"total": 50
}
}200: Success (Non-Paginated)
Returns a simple array of all content entries if paginate is not used.
[
{
"uuid": "e3a4b1c2-d5e6-f7g8-h9i0-j1k2l3m4n5o6",
"locale": "en",
"published_at": "2023-10-28T12:00:00Z",
"fields": {
"title": "My First Blog Post"
}
}
]404: Not Found
Returned if the collection with the specified slug does not exist.
{
"message": "Collection not found."
}