
Step 1: Obtain an Official API Key
To call the upstream Data API directly from your own backend or scripts, register on the official data.gov.in APIs portal and generate an API key in your account dashboard. Treat this key like a password: never commit it to source control, and never embed it in frontend JavaScript or HTML files.
Step 2: Protect the Key with a Backend Proxy
In a browser application, anything included in client-side requests can be inspected by users. Data Khoj routes all browser requests to same-origin endpoints such as /api/resources/{resourceId}/records while the Node.js backend injects DATA_GOV_IN_API_KEY server-side, validates parameters, enforces timeouts and rate limits, and redacts secrets from error messages.

Step 3: Illustrative Request Structure
The illustrative example below shows how a server-side script structures a request using placeholder values:
GET https://api.data.gov.in/resource/<your-resource-id>?api-key=<YOUR_API_KEY>&format=json&offset=0&limit=20Understanding the Response Payload
A typical JSON response includes both data rows and structural metadata:
- fields: Column identifiers, human-readable names, and upstream type hints.
- records: An array of row objects matching your current page and filters.
- offset & limit: The pagination window applied to the query.
- total & count: Total matching records (when provided by upstream) and rows in the current response.
- metadata: Title, organizations, source, and last-updated timestamp.