GnistAI GnistAI
Log in

Getting Started with Postal Codes

Postal/ZIP code lookup — city, state, coordinates for 70+ countries.

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

Data source: Zippopotam.us

Overview

Postal Codes wraps Zippopotam.us, handling authentication, pagination, and rate limits for you. This tutorial covers all 4 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-postal-codes": {
      "url": "https://context.gnist.ai/mcp/postal-codes/",
      "headers": {
        "Gnist-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Tools (4)

lookup_postal_code

Look up location details for a postal/ZIP code — city, state, country, and coordinates. Supports 70+ countries including US, UK, Norway, Germany, France, Japan, and more.

ParameterTypeRequiredDescription
country_codestringrequiredISO 3166-1 alpha-2 country code (e.g. 'US', 'NO', 'DE').
postal_codestringrequiredPostal or ZIP code to look up (e.g. '90210', '0150').
curl -X POST "https://context.gnist.ai/mcp/postal-codes/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "lookup_postal_code", "arguments": {"country_code": "'US'", "postal_code": "'90210'"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/postal-codes/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'country_code': "'US'", 'postal_code': "'90210'"},
            'name': 'lookup_postal_code'}},
)
print(resp.json())

search_by_place

Find postal codes for a city within a country and state. Useful for reverse lookup — find postal codes when you know the place name.

ParameterTypeRequiredDescription
country_codestringrequiredISO 3166-1 alpha-2 country code (e.g. 'US', 'DE').
statestringrequiredState or province name (e.g. 'California', 'Bayern').
citystringrequiredCity or place name (e.g. 'Los Angeles', 'München').
curl -X POST "https://context.gnist.ai/mcp/postal-codes/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "search_by_place", "arguments": {"country_code": "'US'", "state": "'California'", "city": "'Los"}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/postal-codes/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {'city': "'Los",
                          'country_code': "'US'",
                          'state': "'California'"},
            'name': 'search_by_place'}},
)
print(resp.json())

list_supported_countries

List all countries supported for postal code lookup. Returns ISO country codes and names for all 70+ supported countries.

curl -X POST "https://context.gnist.ai/mcp/postal-codes/" \
  -H "Content-Type: application/json" \
  -H "Gnist-API-Key: YOUR_API_KEY" \
  -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": "list_supported_countries", "arguments": {}}}'
import httpx

resp = httpx.post(
    "https://context.gnist.ai/mcp/postal-codes/",
    headers={"Gnist-API-Key": "YOUR_API_KEY"},
    json={'id': 1,
 'jsonrpc': '2.0',
 'method': 'tools/call',
 'params': {'arguments': {}, 'name': 'list_supported_countries'}},
)
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/postal-codes/" \
  -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/postal-codes/",
    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_by_place to find items, then lookup_postal_code to get full details. This two-step pattern is common for exploring data before drilling down.

FAQ

What data does Postal Codes provide?

Postal/ZIP code lookup — city, state, coordinates for 70+ countries. It exposes 4 tools: lookup_postal_code, search_by_place, list_supported_countries, 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 Postal Codes API return?

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

Next Steps

Related Tutorials