REFERENCE
API Documentation
The OpenDataBD REST API gives programmatic access to Bangladesh's open dataset catalog. All responses are JSON. The base URL for every endpoint is:
https://opendatabd.com
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| GET | /api/datasets | — | List active datasets |
| GET | /api/datasets/:id | — | Get single dataset |
| GET | /api/stats | — | Platform statistics |
| POST | /api/datasets | Required | Submit a dataset |
| GET | /api/download/:id | Required | Download dataset file |
Authentication
Protected endpoints require a Bearer token in the Authorization header.
Obtain a token by signing in via the portal or with the Supabase JS client.
Using the Supabase JS client
// npm install @supabase/supabase-js
import { createClient } from '@supabase/supabase-js'
const supabase = createClient(
'https://smyjlzxfhbdzxitkygzz.supabase.co',
'YOUR_ANON_KEY'
)
const { data } = await supabase.auth.signInWithPassword({
email: 'you@example.com',
password: 'yourpassword',
})
const token = data.session.access_token
Sending the token
fetch('https://opendatabd.com/api/download/DATASET_ID', {
headers: {
'Authorization': `Bearer ${token}`
}
})
/api/datasets
Returns a paginated list of all published datasets. Public — no auth required.
Query parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| q | string | — | Full-text search on title |
| category | string | — | Filter by category e.g. Health |
| format | string | — | Filter by format e.g. CSV |
| page | integer | 1 | Page number |
| limit | integer | 20 | Results per page (max 100) |
Example request
# All datasets
curl https://opendatabd.com/api/datasets
# Filter by category + search
curl "https://opendatabd.com/api/datasets?category=Health&q=hospital&limit=5"
Response
{
"datasets": [
{
"id": "uuid",
"title": "District Hospital Bed Capacity",
"description": "Hospital capacity across 64 districts...",
"category": "Health",
"format": ["CSV"],
"source": "DGHS Bangladesh",
"source_url": "https://dghs.gov.bd/...",
"file_url": "https://pub-xxx.r2.dev/datasets/uuid.csv",
"license": "CC-BY 4.0",
"tags": ["health", "hospitals"],
"downloads": 4210,
"views": 18903,
"status": "active",
"created_at": "2025-05-24T12:00:00Z"
}
],
"total": 42,
"page": 1,
"limit": 20
}
/api/datasets/:id
Returns full metadata for a single dataset. Increments the view counter on each call.
Path parameters
| Parameter | Description |
|---|---|
| id | Dataset UUID |
Example request
curl https://opendatabd.com/api/datasets/YOUR_DATASET_ID
Responses
/api/stats
Returns platform-wide statistics. Cached at the edge for 60 seconds.
Example request
curl https://opendatabd.com/api/stats
Response
{
"totalDatasets": 42,
"totalContributors": 8,
"totalDownloads": 15430,
"categoryCounts": {
"Health": 12,
"Economy & Finance": 9,
"Education": 7
}
}
/api/datasets
Auth requiredSubmit a new dataset. The submission starts in pending status and must be approved by an admin before it becomes public.
Request body (JSON)
| Field | Type | Required | Description |
|---|---|---|---|
| title | string | Yes | Dataset name |
| description | string | Yes | What the dataset contains |
| category | string | Yes | One of the standard categories |
| format | string[] | Yes | e.g. ["CSV"] |
| source | string | No | Organization name |
| source_url | string | No | Link to original source |
| file_url | string | No | R2 file URL (from upload presign flow) |
| license | string | No | Default: Open Data |
| tags | string[] | No | Search tags |
Example request
curl -X POST https://opendatabd.com/api/datasets \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "Dhaka Air Quality 2024",
"description": "PM2.5 readings across Dhaka stations",
"category": "Environment",
"format": ["CSV"],
"source": "DoE Bangladesh",
"license": "CC-BY 4.0",
"tags": ["air quality", "Dhaka", "pollution"]
}'
Responses
{ "dataset": {...} } — submission created (status: pending)/api/download/:id
Auth requiredReturns a download URL and suggested filename for a dataset file. Increments the download counter. Use the returned url to fetch the actual file.
Example request
curl https://opendatabd.com/api/download/DATASET_ID \
-H "Authorization: Bearer YOUR_TOKEN"
Response
{
"url": "https://pub-xxx.r2.dev/datasets/uuid.csv",
"filename": "dhaka-air-quality-2024.csv",
"isHosted": true
}
Download in Python
import requests
token = "YOUR_TOKEN"
dataset_id = "DATASET_ID"
# Step 1: get download URL
meta = requests.get(
f"https://opendatabd.com/api/download/{dataset_id}",
headers={"Authorization": f"Bearer {token}"}
).json()
# Step 2: download the file
r = requests.get(meta["url"])
with open(meta["filename"], "wb") as f:
f.write(r.content)
print(f"Saved: {meta['filename']}")
Playground
Try the API directly from your browser. Uses relative URLs so it works in local dev too.
Request body (JSON)
Response
// Click Run to execute the request
Valid categories
Agriculture
Climate & Weather
Demographics
Economy & Finance
Education
Energy
Environment
Governance
Health
Infrastructure
Land & Maps
Labor & Employment
Rivers & Water
Trade & Exports
Transport