Skip to content

bharatdata-ai/bharatdata

Repository files navigation

BharatData

India's Open Public Data Infrastructure
Clean, queryable, and trusted government statistics for everyone.

License: MIT API Status Data Source Open Source


What is BharatData?

BharatData is an independent open-source initiative that eliminates the data access tax paid by every developer, researcher, journalist, and student who needs to work with Indian government statistics.

Every fintech building credit models, every journalist investigating crime trends, every academic studying demographic shifts—they all spend weeks downloading PDFs, normalizing administrative names, and building fragile scrapers before writing a single line of their actual product.

BharatData solves this at the infrastructure level. We collect, normalize, and serve verified Indian public data through a single, consistent API.


Core Features

Feature Description
AI Query Engine Ask questions in plain English about Indian government data
Universal API One consistent endpoint for all datasets (/v1/data/:dataset)
Geo Intelligence Built-in choropleth maps for state and district-level visualization
TypeScript SDK Type-safe client for Node.js, browsers, and edge environments
Python SDK Pandas-native client built for data science workflows
CSV Export One-click export of any query result for offline analysis
Source Attribution Every data point traces back to its official government source

Packages

This monorepo contains the following production components:

bharatdata/
├── packages/
│   ├── api/               # Core Cloudflare Workers API (Hono)
│   ├── typescript-sdk/    # Official TypeScript/JavaScript client
│   ├── python-sdk/        # Official Python client (Pandas integration)
│   ├── playground/        # Next.js interactive data playground
│   └── shared/            # Shared types and constants
├── pipeline/              # Data ingestion and normalization scripts
├── Docs/                  # Full documentation suite
└── sources/               # Raw government data archives

Quick Start

Using the Playground (No Code Required)

Visit the live playground and ask any question about Indian government data:

https://bharatdata.dev

TypeScript SDK

npm install @bharatdata/typescript-sdk
import { BharatData } from '@bharatdata/typescript-sdk';

const bd = new BharatData();

// AI-powered query — ask in plain English
for await (const event of bd.queryAI('Crime trends in Maharashtra 2021-2023')) {
  if (event.type === 'initial') {
    console.log(`Found ${event.count} records`);
    console.table(event.data);
  }
  if (event.type === 'delta') {
    process.stdout.write(event.content);
  }
}

// Direct structured query
const data = await bd.query('ncrb-crime', 'state', {
  entity: 'Maharashtra',
  year: '2023',
  limit: '50',
});

Python SDK

pip install bharatdata
import bharatdata as bd

# Discover all available datasets
datasets = bd.list_datasets()

# Query directly into a Pandas DataFrame
df = bd.query("ncrb-crime", level="district", filters={
    "entity": "Maharashtra",
    "year": "2023"
})
print(df.describe())

# AI-powered narrative analysis
report = bd.query_ai("Compare cyber crime across top 5 Indian states in 2023")
print(report['narrative'])

API Reference

Base URL: https://api.bharatdata.dev

Endpoint Method Description
/health GET System health, Supabase status, latency
/v1/registry GET List all registered datasets
/v1/registry/:id GET Full metadata for one dataset
/v1/data/:dataset GET Universal data query endpoint
/v1/ai/query POST Streaming AI narrative endpoint
/v1/meta/states GET List of all Indian states
/v1/meta/years GET Available data years
/v1/fallback GET Static fallback dataset (always available)

Rate Limits (per IP):

  • 10 requests / minute
  • 200 requests / day

Current Data Coverage

Dataset Source Years Available Granularity
NCRB Crime Statistics Ministry of Home Affairs 2021–2023 State & District
(RBI Economic Data) Reserve Bank of India Coming soon State
(Census Demographics) Office of the Registrar General Coming soon District & Sub-district

Architecture

BharatData System Architecture


Contributing

We welcome contributions of all kinds — new data sources, bug fixes, documentation, and translations. Please read our Contributing Guide before submitting a pull request.


Data Attribution & Legal

All data served by BharatData originates from official Government of India publications. We do not modify, interpolate, or editorialize source data.

BharatData is an independent project. We are not affiliated with any government body.


License

This project is licensed under the MIT License. See LICENSE for full terms.


Generated by the BharatData Team  |  Data Attribution  |  Contribute

About

BharatData solves this at the infrastructure level. We collect, normalize, and serve verified Indian public data through a single, consistent API.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors