Skip to main content

GET /api/resources

Retrieve a list of all resources, documents, and reports related to 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 resources returned
data
object
required
Container for the resources data
resources
array
required
Array of resource objects
id
string
Unique identifier for the resource
collection
string
Collection name (“resources”)
title
string
Resource title
description
string
Resource description
date
string
Publication or creation date (YYYY-MM-DD)
category
string
Resource category (e.g., “Situation Reports / Updates”, “Guidelines”, “Research”)
fileType
string
File type (e.g., “pdf”, “doc”, “xlsx”)
resourceUrl
string
URL to view the resource online
downloadUrl
string
Direct download URL
fileSize
string
File size (e.g., “748.24 KB”, “2.5 MB”)
lastUpdated
string
Last update date (YYYY-MM-DD)
languages
array
Array of available languages
Whether the resource is featured
author
string
Author or publishing organization

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/resources" \
  -H "Content-Type: application/json"

Example Response

{
  "status": "success",
  "count": 1,
  "data": {
    "resources": [
      {
        "id": "Banking-services-in-Dzaleka-Refugee-Camp",
        "collection": "resources",
        "title": "Banking services in Dzaleka Refugee Camp",
        "description": "New Finance Bank opened its branch of service in Dzaleka Refugee Camp on 12 April 2018.",
        "date": "2019-03-01",
        "category": "Situation Reports / Updates",
        "fileType": "pdf",
        "resourceUrl": "https://data.unhcr.org/en/documents/details/68623",
        "downloadUrl": "https://data.unhcr.org/en/documents/download/68623",
        "fileSize": "748.24 KB",
        "lastUpdated": "2024-12-27",
        "languages": ["English"],
        "featured": false,
        "author": "UNHCR Malawi"
      }
    ]
  }
}

POST /api/resources

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

Example Response

{
  "status": "success",
  "count": 156,
  "data": {
    "resources": [
      {
        "id": "Banking-services-in-Dzaleka-Refugee-Camp",
        "title": "Banking services in Dzaleka Refugee Camp",
        "category": "Situation Reports / Updates",
        "fileType": "pdf",
        "author": "UNHCR Malawi"
      }
    ]
  },
  "metadata": {
    "exportDate": "2025-03-09T12:00:00.000Z",
    "collection": "resources"
  },
  "stats": {
    "totalItems": 156,
    "collection": "resources"
  }
}

Implementation

The Resources API is implemented using the createGetHandler and createPostHandler utility functions from src/utils/api-utils.ts:118. Source code: src/pages/api/resources.ts:5