Skip to content

Public APIs

This page is a one-stop path if you simply want to access and use CoRE Stack public data:


1. Generate An API Key

For public dataset access:

  1. Register or sign in at dashboard.core-stack.org
  2. Generate an API key from the dashboard
  3. Send it as the X-API-Key header on public_api routes

Register or sign in at dashboard.core-stack.org

If you need place names before you use the public routes, start with GeoAdmin (NoAuth) APIs.


2. Inspect The Public Surface

Two direct tools are useful here:

  • Swagger: better for trying requests quickly.
  • ReDoc: better for reading grouped routes and schema details carefully.

3. Public API Endpoints

This is the practical pattern for moving from discovery to analysis with the public data APIs.

Route What it does Source
GET /api/v1/get_admin_details_by_latlon/ state, district, tehsil for a coordinate get_admin_details_by_lat_lon()
GET /api/v1/get_mwsid_by_latlon/ MWS identifier for a coordinate get_mws_by_lat_lon()
GET /api/v1/get_tehsil_data/ tehsil JSON derived from stats spreadsheets generate_tehsil_data()
GET /api/v1/get_mws_data/ MWS time-series data get_mws_data()
GET /api/v1/get_mws_kyl_indicators/ KYL indicator subset for one MWS get_mws_json_by_kyl_indicator()
GET /api/v1/get_generated_layer_urls/ generated vector or raster layer URLs get_generated_layer_urls()
GET /api/v1/get_mws_report/ report URL for one MWS get_mws_report_urls()
GET /api/v1/get_active_locations/ activated location inventory get_active_locations()
GET /api/v1/get_mws_geometries/ MWS geometries via GeoServer get_mws_geometries()
GET /api/v1/get_village_geometries/ village geometries via GeoServer get_village_geometries()

Discover a real place

Use either:

Reveal a quick location-finding route Start with your state:
curl https://geoserver.core-stack.org/api/v1/get_states/
Once you find your state (eg: 29), start with:
curl https://geoserver.core-stack.org/api/v1/get_districts/29/
Using the district code in your state, follow with:
curl https://geoserver.core-stack.org/api/v1/get_blocks/566/
That lets you copy the exact district and block names before you try the computation route locally.
  • GET /api/v1/get_active_locations/ if you want only places currently active in the public surface

Inventory the published layers

Call GET /api/v1/get_generated_layer_urls/ and inspect:

  • dataset_name
  • layer_type
  • layer_url
  • style_url
  • gee_asset_path

The output url provides several ways to download and utilise the data:

  • direct download
  • QGIS loading
  • GeoServer-backed clients
  • Earth Engine-oriented follow-up work

Fetch stable geometries

Use:

  • GET /api/v1/get_mws_geometries/
  • GET /api/v1/get_village_geometries/

The main practical join key to watch for is uid on micro-watershed-aligned outputs.

Fetch analytical tables

Use:

  • GET /api/v1/get_tehsil_data/ for tehsil-wide analytical tables keyed by watershed identifiers
  • GET /api/v1/get_mws_data/ for one watershed time series
  • GET /api/v1/get_mws_kyl_indicators/ for a compact watershed snapshot
  • GET /api/v1/get_mws_report/ for report handoff URLs

Join by uid

That is the central reuse pattern:

geometries = fetch_mws_geometries(...)
tehsil_data = fetch_tehsil_data(...)
metric_table = build_metric_table(tehsil_data)
joined_geojson = join_metrics_to_geojson(geometries, metric_table)

In other words:

  1. choose a stable geometry layer
  2. choose an analytical table
  3. join through the watershed identifier
  4. visualize, rank, or export

5. Installer Helper And Smoke Test

The backend repo now ships a standard-library helper at installation/public_api_client.py.

It is useful when you want one of these:

  • a minimal public API smoke test
  • active-location inspection
  • fuzzy name resolution against the active hierarchy
  • bulk download of tehsil, village, MWS, and layer payloads

The current installer can run the same surface automatically during public_api_check if PUBLIC_API_X_API_KEY is configured in nrm_app/.env.

Common commands:

# Minimal smoke test
python installation/public_api_client.py smoke-test

# Resolve misspelled names using the active hierarchy
python installation/public_api_client.py resolve \
  --state bihar \
  --district jamu \
  --tehsil jami

# Download everything for one tehsil
python installation/public_api_client.py download \
  --state assam \
  --district cachar \
  --tehsil lakhipur

# Resolve the containing tehsil from a point first
python installation/public_api_client.py download \
  --latitude 24.79 \
  --longitude 92.79

Important runtime details:

  • it is standard-library only, so it does not depend on corestackenv
  • it can read credentials from --api-key, environment variables, or an optional env file
  • broad state or district downloads expand across activated tehsils and write aggregated metadata as well as per-tehsil output folders

If you are debugging public API access during local setup, this helper is usually faster than composing many raw curl calls by hand.