Get an Entry
This endpoint retrieves a single content entry by its UUID.
Endpoint
[GET]
/{collection_slug}/{entry_uuid}Path Parameters
| Name | Required | Description |
|---|---|---|
collection_slug | Yes | The unique slug of the collection. |
entry_uuid | Yes | The unique identifier for the entry. |
Query Parameters
| Name | Type | Description |
|---|---|---|
locale | string | Fetches the entry for a specific locale code (e.g., en-US). |
translation_locale | string | Get the translation of this entry in the specified locale. Returns the linked translation entry instead of the original. See Translations for more details. |
state | string | Controls the publication state. Options: published (default), only_draft, with_draft. |
exclude[] | array | An array of field names to exclude from the response. |
timestamps | boolean | If present, includes created_at and updated_at in the response. |
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
https://your-domain.com/api/{collection_slug}/{entry_uuid}import { createClient } from '@elmapicms/js-sdk';
const client = createClient(
'https://your-domain.com/api',
'YOUR_API_TOKEN',
'YOUR_PROJECT_UUID'
);
// Get a specific entry by UUID
const entry = await client.getEntry('blog-posts', 'e3a4b1c2-d5e6-f7g8-h9i0-j1k2l3m4n5o6');
// Get entry with optional parameters
const entryWithOptions = await client.getEntry('blog-posts', 'e3a4b1c2-d5e6-f7g8-h9i0-j1k2l3m4n5o6', {
locale: 'en',
state: 'published',
exclude: ['content'],
timestamps: true
});
// Get translation of an entry
const translation = await client.getEntry('blog-posts', 'e3a4b1c2-d5e6-f7g8-h9i0-j1k2l3m4n5o6', {
translation_locale: 'fr'
});const collectionSlug = 'blog-posts';
const entryUuid = 'e3a4b1c2-d5e6-f7g8-h9i0-j1k2l3m4n5o6';
axios.get(`https://your-domain.com/api/${collectionSlug}/${entryUuid}`, {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_API_TOKEN', // Required for private APIs
'project-id': 'YOUR_PROJECT_UUID'
}
});use Illuminate\Support\Facades\Http;
$collectionSlug = 'blog-posts';
$entryUuid = 'e3a4b1c2-d5e6-f7g8-h9i0-j1k2l3m4n5o6';
$response = Http::withHeaders([
'Accept' => 'application/json',
'Authorization' => 'Bearer YOUR_API_TOKEN',
'project-id' => 'YOUR_PROJECT_UUID'
])->get("https://your-domain.com/api/{$collectionSlug}/{$entryUuid}");import React, { useState, useEffect } from 'react';
function EntryDetails({ collectionSlug, entryUuid }) {
const [entry, setEntry] = useState(null);
const [error, setError] = useState(null);
useEffect(() => {
const fetchEntry = async () => {
try {
const response = await fetch(`https://your-domain.com/api/${collectionSlug}/${entryUuid}`, {
method: 'GET',
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_API_TOKEN',
'project-id': 'YOUR_PROJECT_UUID'
}
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
setEntry(data.data);
} catch (e) {
setError(e.message);
}
};
fetchEntry();
}, [collectionSlug, entryUuid]);
if (error) return <div>Error: {error}</div>;
if (!entry) return <div>Loading...</div>;
return (
<div>
<h1>{entry.fields.title}</h1>
<div dangerouslySetInnerHTML={{ __html: entry.fields.content }} />
</div>
);
}<template>
<div v-if="error">Error: {{ error }}</div>
<div v-else-if="entry">
<h1>{{ entry.fields.title }}</h1>
<div v-html="entry.fields.content"></div>
</div>
<div v-else>Loading...</div>
</template>
<script setup>
import { ref, onMounted, defineProps } from 'vue';
const props = defineProps({
collectionSlug: { type: String, required: true },
entryUuid: { type: String, required: true }
});
const entry = ref(null);
const error = ref(null);
onMounted(async () => {
try {
const response = await fetch(`https://your-domain.com/api/${props.collectionSlug}/${props.entryUuid}`, {
method: 'GET',
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_API_TOKEN',
'project-id': 'YOUR_PROJECT_UUID'
}
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
entry.value = data.data;
} catch (e) {
error.value = e.message;
}
});
</script>curl -X GET "https://your-domain.com/api/blog-posts/e3a4b1c2-d5e6-f7g8-h9i0-j1k2l3m4n5o6" \
-H "Accept: application/json" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "project-id: YOUR_PROJECT_UUID"Responses
200: Success
Returns a single content entry object.
{
"data": {
"uuid": "e3a4b1c2-d5e6-f7g8-h9i0-j1k2l3m4n5o6",
"locale": "en",
"published_at": "2023-10-28T12:00:00Z",
"fields": {
"title": "My First Blog Post",
"slug": "my-first-blog-post",
"content": "<p>This is the content of the post.</p>",
"author": "John Doe"
}
}
}404: Not Found
Returned if the collection or the entry with the specified UUID does not exist.
{
"message": "Collection not found."
}{
"message": "Content not found."
}