GnistAI GnistAI
Log in

Getting Started with Open Data (Government Portals)

Search 460K+ government datasets across US (data.gov), UK (data.gov.uk), and Canada (open.canada.ca) open data portals — find datasets by topic, organization, or keyword.

All Tutorials   |   Overview   |   Playground   |   MCP   |   REST API   |   Home
Government

Data source: CKAN Open Data Portals

Overview

Open Data (Government Portals) wraps CKAN Open Data Portals, handling authentication, pagination, and rate limits for you. This tutorial covers all 5 tools with working code examples you can copy and run.

Prerequisites

  1. Sign up at https://context.gnist.ai/signup for a free API key (100 calls/day).
  2. Choose your integration method: MCP protocol or REST API.

Connect via MCP

Add to your MCP client config (Claude Desktop, Cursor, etc.):

MCP Config
{
  "mcpServers": {
    "gnist-opendata": {
      "url": "https://context.gnist.ai/mcp/opendata/",
      "headers": {
        "Gnist-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Tools (5)

search_datasets

Search government open data datasets across US (data.gov), UK (data.gov.uk), or Canada (open.canada.ca). Covers 460K+ datasets published by government agencies — CSV, JSON, GeoJSON, and API endpoints for climate, transportation, health, economics, geospatial, and more. All free, no API key required. Each result includes download links, formats, and organization info. Args: query: Keyword or topic to search for. portal: Which country portal to search. limit: Number of results (1-50, default 20). offset: Pagination offset. Returns: List of matching datasets with title, description, organization, resources (download links), tags, and license. Use get_dataset for full details on a specific result.

ParameterTypeRequiredDescription
querystringrequiredSearch query for datasets (e.g. "climate change", "transportation safety", "public health spending").
portalstringoptionalPortal to search: 'us' (data.gov, 290K+ datasets), 'uk' (data.gov.uk, 55K+), 'ca' (open.canada.ca, 115K+). Default 'us'. (default: us)
limitintegeroptionalNumber of results (1-50, default 20). (default: 20)
offsetintegeroptionalResult offset for pagination (default 0). (default: 0)
curl -X POST "https://context.gnist.ai/mcp/opendata/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "search_datasets", "arguments": {"query": "climate change"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/opendata/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'query': 'climate change'},
            'name': 'search_datasets'}},
)
print(resp.json())

get_dataset

Get full details for a single government dataset by its name or ID. Returns complete metadata including all download resources (CSV, JSON, API endpoints), description, organization, tags, license, and last-modified date. Args: dataset_id: Dataset name or UUID from search results. portal: Which country portal. Returns: Full dataset record with resources, or found=false if not found.

ParameterTypeRequiredDescription
dataset_idstringrequiredDataset name or ID (e.g. 'annual-enterprise-survey-2021'). Found in search_datasets results.
portalstringoptionalPortal: 'us', 'uk', or 'ca'. Default 'us'. (default: us)
curl -X POST "https://context.gnist.ai/mcp/opendata/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "get_dataset", "arguments": {"dataset_id": "'annual-enterprise-survey-2021'"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/opendata/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'dataset_id': "'annual-enterprise-survey-2021'"},
            'name': 'get_dataset'}},
)
print(resp.json())

list_organizations

List government organizations that publish open data on a portal. Browse the publishing organizations (agencies, departments, offices) on a specific portal. Each entry shows the organization name, description, and number of datasets published. Args: portal: Which country portal. limit: Number of results (1-50, default 20). Returns: List of organizations with name, description, and dataset count.

ParameterTypeRequiredDescription
portalstringoptionalPortal: 'us', 'uk', or 'ca'. Default 'us'. (default: us)
limitintegeroptionalNumber of results (1-50, default 20). (default: 20)
curl -X POST "https://context.gnist.ai/mcp/opendata/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "list_organizations", "arguments": {"portal": "us"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/opendata/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'portal': 'us'}, 'name': 'list_organizations'}},
)
print(resp.json())

get_organization

Get details for a specific government data-publishing organization. Returns organization metadata including description, logo, and total dataset count. Args: org_id: Organization name or UUID. portal: Which country portal. Returns: Organization details with dataset count, or found=false if not found.

ParameterTypeRequiredDescription
org_idstringrequiredOrganization name or ID (e.g. 'nasa-gov', 'department-of-energy'). Found in list_organizations results.
portalstringoptionalPortal: 'us', 'uk', or 'ca'. Default 'us'. (default: us)
curl -X POST "https://context.gnist.ai/mcp/opendata/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "get_organization", "arguments": {"org_id": "'nasa-gov'"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/opendata/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'org_id': "'nasa-gov'"}, 'name': 'get_organization'}},
)
print(resp.json())

report_feedback

Report a bug, feature request, or general feedback for this data source. Use this when something doesn't work as expected, when you'd like a new feature, or when you have suggestions for improvement. Args: feedback: Describe the issue or suggestion. feedback_type: One of 'bug', 'feature_request', or 'general'.

ParameterTypeRequiredDescription
feedbackstringrequired
feedback_typestringoptional (default: general)
curl -X POST "https://context.gnist.ai/mcp/opendata/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "report_feedback", "arguments": {"feedback": "example"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/opendata/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'feedback': 'example'}, 'name': 'report_feedback'}},
)
print(resp.json())

Common Patterns

Search then retrieve
Use search_datasets to find items, then get_dataset to get full details. This two-step pattern is common for exploring data before drilling down.
Pagination
Several tools support limit, offset, or page parameters. Start with small limits during development, then increase for production queries.

FAQ

What data does Open Data (Government Portals) provide?

Search 460K+ government datasets across US (data.gov), UK (data.gov.uk), and Canada (open.canada.ca) open data portals — find datasets by topic, organization, or keyword. It exposes 5 tools: search_datasets, get_dataset, list_organizations, get_organization, report_feedback.

What do I need to get started?

A Gnist API key (free tier: 100 calls/day). Sign up at https://context.gnist.ai/signup.

What format does the Open Data (Government Portals) API return?

JSON, via either MCP protocol (JSON-RPC 2.0) or REST API.

Next Steps

Related Tutorials