Get Project
This endpoint retrieves the details of a specific project, including its name, description, and localization settings.
Endpoint
[GET]
/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. |
Query Parameters
| Name | Required | Description |
|---|---|---|
with | No | Add collections or collections with fields to the response. /api/?with=collections,fields |
Example Requests
import { createClient } from '@elmapicms/js-sdk';
const client = createClient(
'https://your-domain.com/api',
'YOUR_API_TOKEN', // Required for private APIs
'YOUR_PROJECT_UUID'
);
// Get project details
const project = await client.getProject();
// Get project with collections and fields
const projectWithCollections = await client.getProject({
with: 'collections,fields'
});axios.get('https://your-domain.com/api', {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_API_TOKEN', // Required for private APIs
'project-id': 'YOUR_PROJECT_UUID'
}
});use Illuminate\Support\Facades\Http;
$response = Http::withHeaders([
'Accept' => 'application/json',
'Authorization' => 'Bearer YOUR_API_TOKEN', // Required for private APIs
'project-id' => 'YOUR_PROJECT_UUID'
])->get('https://your-domain.com/api');
if ($response->successful()) {
$project = $response->json();
}import React, { useState, useEffect } from 'react';
function ProjectDetails() {
const [project, setProject] = useState(null);
const [error, setError] = useState(null);
useEffect(() => {
const fetchProject = async () => {
try {
const response = await fetch('https://your-domain.com/api', {
method: 'GET',
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_API_TOKEN', // Required for private APIs
'project-id': 'YOUR_PROJECT_UUID'
}
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
setProject(await response.json());
} catch (e) {
setError(e.message);
}
};
fetchProject();
}, []);
if (error) return <div>Error: {error}</div>;
if (!project) return <div>Loading...</div>;
return (
<div>
<h1>{project.name}</h1>
<p>{project.description}</p>
</div>
);
}<template>
<div v-if="error">Error: {{ error }}</div>
<div v-else-if="project">
<h1>{{ project.name }}</h1>
<p>{{ project.description }}</p>
</div>
<div v-else>Loading...</div>
</template>
<script setup>
import { ref, onMounted } from 'vue';
const project = ref(null);
const error = ref(null);
onMounted(async () => {
try {
const response = await fetch('https://your-domain.com/api', {
method: 'GET',
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_API_TOKEN', // Required for private APIs
'project-id': 'YOUR_PROJECT_UUID'
}
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
project.value = await response.json();
} catch (e) {
error.value = e.message;
}
});
</script>curl -X GET "https://your-domain.com/api" \
-H "Accept: application/json" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "project-id: YOUR_PROJECT_UUID"Responses
200: Success
Returns a project object with its details.
{
"uuid": "c03c1ff5-e844-4311-8464-4a33371836b3",
"name": "My Awesome Project",
"description": "A description of my awesome project.",
"default_locale": "en",
"locales": [
"en",
"fr",
"es"
]
}401: Unauthenticated
Returned if the API token is missing or invalid for a private project.
{
"message": "Unauthenticated."
}403: Forbidden
Returned if the API token does not have the required read permission.
{
"message": "API token does'nt have the right abilities!"
}404: Not Found
Returned if the project with the specified project-id does not exist.
{
"message": "Project not found."
}