Skip to main content

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

status
string
required
Status of the API response (“success” or “error”)
count
number
required
Total number of news articles returned
data
object
required
Container for the news data
news
array
required
Array of news article objects
id
string
Unique identifier for the article
collection
string
Collection name (“news”)
title
string
Article title
description
string
Article summary or excerpt
image
string
URL to article featured image
author
string
Author name
Whether the article is featured
date
string
Publication date (YYYY-MM-DD)
category
string
Article category (e.g., “business-spotlight”, “community-update”, “announcement”)

Error Responses

status
string
“error”
message
string
Error message description
error
string
Detailed error information
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

curl -X GET "https://services.dzaleka.com/api/news" \
  -H "Content-Type: application/json"

Example Response

{
  "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

options
object
Optional configuration for the response
includeMetadata
boolean
Include export metadata in response
includeStats
boolean
Include statistics in response

Response Format

Same as GET endpoint, with optional additional fields:
metadata
object
Export metadata (only if includeMetadata: true)
exportDate
string
ISO 8601 timestamp of export
collection
string
Collection name
stats
object
Statistics (only if includeStats: true)
totalItems
number
Total number of items
collection
string
Collection name

Example Request

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

Example Response

{
  "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