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}` } })
GET

/api/datasets

Returns a paginated list of all published datasets. Public — no auth required.

Query parameters

Parameter Type Default Description
qstringFull-text search on title
categorystringFilter by category e.g. Health
formatstringFilter by format e.g. CSV
pageinteger1Page number
limitinteger20Results 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 }
GET

/api/datasets/:id

Returns full metadata for a single dataset. Increments the view counter on each call.

Path parameters

ParameterDescription
idDataset UUID

Example request

curl https://opendatabd.com/api/datasets/YOUR_DATASET_ID

Responses

200Dataset object (same schema as list response)
404Dataset not found or not published
GET

/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 } }
POST

/api/datasets

Auth required

Submit 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
titlestringYesDataset name
descriptionstringYesWhat the dataset contains
categorystringYesOne of the standard categories
formatstring[]Yese.g. ["CSV"]
sourcestringNoOrganization name
source_urlstringNoLink to original source
file_urlstringNoR2 file URL (from upload presign flow)
licensestringNoDefault: Open Data
tagsstring[]NoSearch 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

201{ "dataset": {...} } — submission created (status: pending)
401Missing or invalid token
400Validation error — missing required fields
GET

/api/download/:id

Auth required

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

Bearer
Try:

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