> ## Documentation Index
> Fetch the complete documentation index at: https://dos.dzaleka.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Photos API

> Access photo stories and visual narratives from Dzaleka

## GET /api/photos

Retrieve a collection of photo stories and visual narratives from Dzaleka Refugee Camp.

### Query Parameters

This endpoint does not require any query parameters.

### Response Format

<ResponseField name="status" type="string" required>
  Status of the API response ("success" or "error")
</ResponseField>

<ResponseField name="count" type="number" required>
  Total number of photos returned
</ResponseField>

<ResponseField name="data" type="object" required>
  Container for the photos data

  <ResponseField name="photos" type="array" required>
    Array of photo story objects

    <ResponseField name="id" type="string">
      Unique identifier for the photo story
    </ResponseField>

    <ResponseField name="collection" type="string">
      Collection name ("photos")
    </ResponseField>

    <ResponseField name="title" type="string">
      Photo story title
    </ResponseField>

    <ResponseField name="description" type="string">
      Description or narrative of the photo story
    </ResponseField>

    <ResponseField name="photographer" type="object">
      Photographer information

      <ResponseField name="name" type="string">
        Photographer's name
      </ResponseField>

      <ResponseField name="instagram" type="string">
        Instagram handle
      </ResponseField>

      <ResponseField name="website" type="string">
        Photographer's website
      </ResponseField>

      <ResponseField name="bio" type="string">
        Brief biography
      </ResponseField>
    </ResponseField>

    <ResponseField name="contributor" type="string">
      Contributor slug/identifier
    </ResponseField>

    <ResponseField name="image" type="string">
      URL to the main image
    </ResponseField>

    <ResponseField name="date" type="string">
      Publication date (YYYY-MM-DD)
    </ResponseField>

    <ResponseField name="tags" type="array">
      Array of tag strings
    </ResponseField>

    <ResponseField name="featured" type="boolean">
      Whether the photo story is featured
    </ResponseField>

    <ResponseField name="location" type="string">
      Location where the photo was taken
    </ResponseField>
  </ResponseField>
</ResponseField>

### Error Responses

<ResponseField name="status" type="string">
  "error"
</ResponseField>

<ResponseField name="message" type="string">
  Error message description
</ResponseField>

<ResponseField name="error" type="string">
  Detailed error information
</ResponseField>

**Status Codes:**

* `200` - Success
* `429` - Rate limit exceeded (60 requests per minute)
* `500` - Internal server error

### Rate Limiting

All API endpoints are rate-limited to 60 requests per minute per IP address. Rate limit headers are included in responses:

* `X-RateLimit-Limit`: Maximum requests per window
* `X-RateLimit-Remaining`: Remaining requests in current window
* `X-RateLimit-Reset`: Timestamp when the rate limit resets
* `Retry-After`: Seconds to wait before retrying (only on 429 responses)

### Example Request

```bash theme={null}
curl -X GET "https://services.dzaleka.com/api/photos" \
  -H "Content-Type: application/json"
```

### Example Response

```json theme={null}
{
  "status": "success",
  "count": 1,
  "data": {
    "photos": [
      {
        "id": "Andy",
        "collection": "photos",
        "title": "From Survival to Innovation: Andy's Journey in Dzaleka",
        "description": "Escaping his past as a child soldier, Andy found refuge in Dzaleka, reunited with his mother, and discovered coding. Now, he dreams of growing his messaging app into something greater.",
        "photographer": {
          "name": "Badre Bahaji",
          "instagram": "badrebahaji",
          "website": "https://mw.linkedin.com/in/badre-bahaji-1bb67942",
          "bio": "Photography based in Uganda"
        },
        "contributor": "badre-bahaji",
        "image": "https://www.wfp.org/sites/default/files/styles/media_embed/public/2021-06/Malawi%205.jpg?itok=NkB_eCtY",
        "date": "2021-06-18",
        "tags": [
          "Former Child Soldier",
          "Refugee Resilience",
          "Family Reunion",
          "Coding Skills"
        ],
        "featured": true,
        "location": "Dzaleka Refugee Camp"
      }
    ]
  }
}
```

## POST /api/photos

Retrieve photos data with optional metadata and statistics.

### Request Body

<ParamField body="options" type="object">
  Optional configuration for the response

  <ParamField body="includeMetadata" type="boolean">
    Include export metadata in response
  </ParamField>

  <ParamField body="includeStats" type="boolean">
    Include statistics in response
  </ParamField>
</ParamField>

### Response Format

Same as GET endpoint, with optional additional fields:

<ResponseField name="metadata" type="object">
  Export metadata (only if `includeMetadata: true`)

  <ResponseField name="exportDate" type="string">
    ISO 8601 timestamp of export
  </ResponseField>

  <ResponseField name="collection" type="string">
    Collection name
  </ResponseField>
</ResponseField>

<ResponseField name="stats" type="object">
  Statistics (only if `includeStats: true`)

  <ResponseField name="totalItems" type="number">
    Total number of items
  </ResponseField>

  <ResponseField name="collection" type="string">
    Collection name
  </ResponseField>
</ResponseField>

### Example Request

```bash theme={null}
curl -X POST "https://services.dzaleka.com/api/photos" \
  -H "Content-Type: application/json" \
  -d '{
    "options": {
      "includeMetadata": true,
      "includeStats": true
    }
  }'
```

### Example Response

```json theme={null}
{
  "status": "success",
  "count": 32,
  "data": {
    "photos": [
      {
        "id": "Andy",
        "title": "From Survival to Innovation: Andy's Journey in Dzaleka",
        "photographer": {
          "name": "Badre Bahaji"
        },
        "date": "2021-06-18"
      }
    ]
  },
  "metadata": {
    "exportDate": "2025-03-09T12:00:00.000Z",
    "collection": "photos"
  },
  "stats": {
    "totalItems": 32,
    "collection": "photos"
  }
}
```

## Implementation

The Photos API is implemented using the `createGetHandler` and `createPostHandler` utility functions from `src/utils/api-utils.ts:118`.

Source code: `src/pages/api/photos.ts:5`
