Galerie
Ziskani fotek z galerie projektu.
Opravneni
Tento endpoint vyzaduje API klic s opravnenim Media.
GET /:slug/gallery
Vrati seznam fotek z galerie.
Pozadavek
curl -X GET \
-H "X-API-Key: vas_api_klic" \
https://api.zarezervujto.cz/api/v1/vas-projekt/gallery
Query parametry
| Parametr | Typ | Vychozi | Popis |
|---|---|---|---|
limit | number | 50 | Max pocet fotek (max 100) |
offset | number | 0 | Pocet preskocit (strankovani) |
Odpoved
{
"success": true,
"count": 12,
"total": 25,
"photos": [
{
"id": "photo-1",
"imageUrl": "https://s3.eu-central-1.amazonaws.com/...",
"title": "Interiér restaurace",
"description": "Hlavní sál s výhledem do zahrady",
"displayOrder": 1,
"createdAt": "2024-06-15T10:30:00Z"
},
{
"id": "photo-2",
"imageUrl": "https://s3.eu-central-1.amazonaws.com/...",
"title": "Letní terasa",
"description": null,
"displayOrder": 2,
"createdAt": "2024-06-15T10:31:00Z"
}
]
}
Popis poli
| Pole | Typ | Popis |
|---|---|---|
id | string | Unikatni ID fotky |
imageUrl | string | URL obrazku |
title | string | null | Nazev/titulek |
description | string | null | Popis |
displayOrder | number | Poradi zobrazeni |
createdAt | string | Datum pridani (ISO 8601) |
Strankovani
# Prvnich 10 fotek
curl -X GET \
-H "X-API-Key: vas_api_klic" \
"https://api.zarezervujto.cz/api/v1/vas-projekt/gallery?limit=10"
# Dalsich 10 fotek
curl -X GET \
-H "X-API-Key: vas_api_klic" \
"https://api.zarezervujto.cz/api/v1/vas-projekt/gallery?limit=10&offset=10"
Priklad pouziti
async function getGallery(slug, apiKey, options = {}) {
const params = new URLSearchParams();
if (options.limit) params.append('limit', options.limit);
if (options.offset) params.append('offset', options.offset);
const response = await fetch(
`https://api.zarezervujto.cz/api/v1/$:slug/gallery?${params}`,
{
headers: { 'X-API-Key': apiKey }
}
);
return response.json();
}
// Nacteni vsech fotek s strankovani
async function getAllPhotos(slug, apiKey) {
const allPhotos = [];
let offset = 0;
const limit = 50;
while (true) {
const data = await getGallery(slug, apiKey, { limit, offset });
allPhotos.push(...data.photos);
if (allPhotos.length >= data.total) break;
offset += limit;
}
return allPhotos;
}
Zobrazeni galerie (React)
function Gallery({ photos }) {
return (
<div className="grid grid-cols-3 gap-4">
{photos.map(photo => (
<div key={photo.id} className="relative">
<img
src={photo.imageUrl}
alt={photo.title || 'Fotka'}
className="w-full h-48 object-cover rounded-lg"
/>
{photo.title && (
<p className="mt-2 text-sm font-medium">{photo.title}</p>
)}
</div>
))}
</div>
);
}
Chybove odpovedi
403 Permission Denied
{
"error": "Forbidden",
"message": "API key does not have media read permission",
"code": "PERMISSION_DENIED"
}
Reseni: Povolte opravneni Media pro vas API klic v nastaveni projektu.