> ## 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.

# News API

> Get news articles and updates about Dzaleka Refugee Camp

## GET /api/news

Retrieve a list of all news articles about 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 news articles returned
</ResponseField>

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

  <ResponseField name="news" type="array" required>
    Array of news article objects

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

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

    <ResponseField name="title" type="string">
      Article title
    </ResponseField>

    <ResponseField name="description" type="string">
      Article summary or excerpt
    </ResponseField>

    <ResponseField name="image" type="string">
      URL to article featured image
    </ResponseField>

    <ResponseField name="author" type="string">
      Author name
    </ResponseField>

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

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

    <ResponseField name="category" type="string">
      Article category (e.g., "business-spotlight", "community-update", "announcement")
    </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/news" \
  -H "Content-Type: application/json"
```

### Example Response

```json theme={null}
{
  "status": "success",
  "count": 1,
  "data": {
    "news": [
      {
        "id": "9 Innovative Refugee-Led Initiatives in Dzaleka You Should Know",
        "collection": "news",
        "title": "11 Innovative Refugee-Led Initiatives in Dzaleka You Should Know",
        "description": "These unique businesses and social enterprises highlight the invaluable contributions of refugees to our culture and economy. From tech hubs like ADAI Circle to community-driven initiatives such as There Is Hope Malawi, refugees in Dzaleka are creating opportunities and achieving economic independence.",
        "image": "https://dzalekaconnect.com/images/49083236178_c692c9746d_b.jpg",
        "author": "Bakari Mustafa",
        "featured": true,
        "date": "2025-04-21",
        "category": "business-spotlight"
      }
    ]
  }
}
```

## POST /api/news

Retrieve news 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/news" \
  -H "Content-Type: application/json" \
  -d '{
    "options": {
      "includeMetadata": true,
      "includeStats": true
    }
  }'
```

### Example Response

```json theme={null}
{
  "status": "success",
  "count": 22,
  "data": {
    "news": [
      {
        "id": "9 Innovative Refugee-Led Initiatives in Dzaleka You Should Know",
        "title": "11 Innovative Refugee-Led Initiatives in Dzaleka You Should Know",
        "author": "Bakari Mustafa",
        "date": "2025-04-21",
        "category": "business-spotlight"
      }
    ]
  },
  "metadata": {
    "exportDate": "2025-03-09T12:00:00.000Z",
    "collection": "news"
  },
  "stats": {
    "totalItems": 22,
    "collection": "news"
  }
}
```

## Implementation

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

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