{
  "openapi": "3.1.0",
  "info": {
    "title": "Zip & Postal Code API",
    "version": "1.0.0",
    "description": "Postal and ZIP code lookup for about 100 countries, with place, region and coordinates.\n\nLook up postal/ZIP codes for ~100 countries — place name, state/province, county, and geographic coordinates. Search forward by code, or reverse by place name. Backed by the GeoNames postal dataset (~1.5M codes).",
    "contact": {
      "name": "Data and APIs",
      "url": "https://dataandapis.com/contact"
    },
    "termsOfService": "https://dataandapis.com/terms-of-service",
    "license": {
      "name": "Data and APIs Terms of Service",
      "url": "https://dataandapis.com/terms-of-service"
    },
    "x-logo": {
      "url": "https://dataandapis.com/images/postal-code.webp"
    }
  },
  "externalDocs": {
    "description": "Documentation, live tester and pricing",
    "url": "https://dataandapis.com/apis/zip-postal-code"
  },
  "servers": [
    {
      "url": "https://api-postal-code.dataandapis.com"
    }
  ],
  "tags": [
    {
      "name": "Data",
      "description": "Zip & Postal Code API belongs to the Data category of the Data and APIs catalog."
    }
  ],
  "paths": {
    "/v1/postal-code": {
      "get": {
        "operationId": "postalCodeLookup",
        "summary": "Postal Code Lookup",
        "description": "Postal Code Lookup endpoint of the Zip & Postal Code API. Costs 2 tokens per call.",
        "externalDocs": {
          "url": "https://dataandapis.com/apis/zip-postal-code/postal-code-lookup"
        },
        "parameters": [
          {
            "name": "code",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "90210"
          },
          {
            "name": "country",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "US"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "country": "US",
                  "postal_code": "90210",
                  "place_count": 1,
                  "places": [
                    {
                      "country_code": "US",
                      "postal_code": "90210",
                      "place_name": "Beverly Hills",
                      "state": "California",
                      "state_code": "CA",
                      "county": "Los Angeles",
                      "county_code": "037",
                      "latitude": 34.0901,
                      "longitude": -118.4065,
                      "accuracy": 4
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "402": {
            "description": "Subscription past due; the response carries a payment_url"
          },
          "429": {
            "description": "Monthly token allowance exhausted"
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1/search": {
      "get": {
        "operationId": "searchByPlace",
        "summary": "Search By Place",
        "description": "Search By Place endpoint of the Zip & Postal Code API. Costs 2 tokens per call.",
        "externalDocs": {
          "url": "https://dataandapis.com/apis/zip-postal-code/search-by-place"
        },
        "parameters": [
          {
            "name": "country",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "US"
          },
          {
            "name": "place",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "Beverly Hills"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "country": "US",
                  "query": "Beverly Hills",
                  "result_count": 1,
                  "results": [
                    {
                      "country_code": "US",
                      "postal_code": "90210",
                      "place_name": "Beverly Hills",
                      "state": "California",
                      "state_code": "CA",
                      "county": "Los Angeles",
                      "county_code": "037",
                      "latitude": 34.0901,
                      "longitude": -118.4065,
                      "accuracy": 4
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "402": {
            "description": "Subscription past due; the response carries a payment_url"
          },
          "429": {
            "description": "Monthly token allowance exhausted"
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Key",
        "description": "Create a free key at https://dataandapis.com/sign-up. 500 tokens a month on the Free plan; this API costs 2 tokens per call."
      }
    }
  },
  "security": [
    {
      "ApiKey": []
    }
  ]
}