{
  "openapi": "3.0.3",
  "info": {
    "title": "Geloky API",
    "version": "1.0.0",
    "description": "Geocode addresses, find the address of a point, measure road distances and routes through several stops, and find each customer's nearest location, with simple HTTPS requests.\n\n**Price.** Every call is paid from your API wallet: $0.001 per request, per address in a batch and per leg of a route. Distances and routes cost $0.001 more for each address they look up. Nearest location costs $0.003 per customer by road or $0.001 in a straight line, plus $0.001 per address. Extra columns (time zone, county, census tract, congressional district) add $0.001 per lookup. Calls that end in an error are free.\n\n**Key.** Your API key goes in the `key` query parameter. It is on the API tab of your dashboard: https://geloky.com/dashboard/tab/api. Your first top-up comes with $10 extra.\n\n**Errors.** When a call cannot be served, the answer is `{\"code\": \"ERROR\", \"message\": \"...\"}` instead of results, and nothing is charged. A missing required parameter is answered with HTTP 400.\n\nThe same service runs as an MCP server for AI assistants at https://geloky.com/mcp. Full docs with examples in cURL, Python, JavaScript and PHP: https://geloky.com/help-api",
    "termsOfService": "https://geloky.com/terms",
    "contact": {
      "name": "Geloky",
      "url": "https://geloky.com/contact",
      "email": "hello@geloky.com"
    },
    "x-logo": {
      "url": "https://geloky.com/img/geloky-icon-512.png",
      "backgroundColor": "#FFFFFF",
      "altText": "geloky"
    }
  },
  "externalDocs": {
    "description": "Geloky API docs",
    "url": "https://geloky.com/help-api"
  },
  "servers": [
    {
      "url": "https://geloky.com/api/geo"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "Account",
      "description": "Your API wallet."
    },
    {
      "name": "Geocoding",
      "description": "Addresses to latitude and longitude, and points back to addresses, one at a time or in batches. Answers come in the Geloky format, or in the shape of the Google Geocoding API with format=google."
    },
    {
      "name": "Distances",
      "description": "Road distance and travel time between two places, routes through up to 25 stops, and the nearest of your locations for each customer. Distances are in miles unless you ask for kilometers; times are in minutes."
    }
  ],
  "paths": {
    "/balance": {
      "get": {
        "tags": ["Account"],
        "operationId": "getBalance",
        "summary": "Check your balance",
        "description": "What is left in your API wallet and how many requests it has paid for. Free, and it works with an empty wallet too, so you can check a key before your first top-up.",
        "responses": {
          "200": {
            "description": "The wallet, or an error for a wrong key.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    { "$ref": "#/components/schemas/Balance" },
                    { "$ref": "#/components/schemas/Error" }
                  ]
                },
                "examples": {
                  "balance": {
                    "summary": "A wallet",
                    "value": {
                      "balance_usd": 24.999,
                      "requests_total": 1,
                      "price_per_request_usd": 0.001,
                      "top_up_url": "https://geloky.com/dashboard/tab/api"
                    }
                  },
                  "wrongKey": {
                    "$ref": "#/components/examples/WrongKey"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/geocode": {
      "get": {
        "tags": ["Geocoding"],
        "operationId": "geocode",
        "summary": "Geocode an address",
        "description": "Finds the latitude and longitude of one address, place or postal code. $0.001 per request; +$0.001 with extra columns.",
        "parameters": [
          {
            "name": "address",
            "in": "query",
            "required": true,
            "description": "The address to look up. Street, city, postal code and country give the best match; leave out business names and unit numbers.",
            "schema": { "type": "string" },
            "example": "350 5th Ave, New York, NY 10118"
          },
          { "$ref": "#/components/parameters/format" },
          { "$ref": "#/components/parameters/fields" }
        ],
        "responses": {
          "200": {
            "description": "A list with one answer, the Google-shaped answer with format=google, or an error.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "array",
                      "items": { "$ref": "#/components/schemas/GeocodeResult" }
                    },
                    { "$ref": "#/components/schemas/GoogleGeocodeResponse" },
                    { "$ref": "#/components/schemas/Error" }
                  ]
                },
                "examples": {
                  "geloky": {
                    "summary": "Geloky format",
                    "value": [
                      {
                        "address": "350 5th Ave, New York, New York, 10118",
                        "latitude": 40.74837686528841,
                        "longitude": -73.98485413472395
                      }
                    ]
                  },
                  "extraColumns": {
                    "summary": "With fields=all",
                    "value": [
                      {
                        "address": "350 5th Ave, New York, New York, 10118",
                        "latitude": 40.748377,
                        "longitude": -73.984854,
                        "timezone": "America/New_York",
                        "utc_offset": "-05:00",
                        "dst": "yes",
                        "county": "New York County",
                        "county_fips": "36061",
                        "tract": "36061007600",
                        "block_group": "360610076001",
                        "district": "NY-12",
                        "match_level": "building"
                      }
                    ]
                  },
                  "google": {
                    "summary": "Google format",
                    "value": {
                      "results": [
                        {
                          "formatted_address": "350 5th Ave, New York, New York, 10118",
                          "geometry": {
                            "location": { "lat": 40.74837686528841, "lng": -73.98485413472395 }
                          }
                        }
                      ],
                      "status": "OK"
                    }
                  },
                  "noFunds": {
                    "$ref": "#/components/examples/NoFunds"
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/MissingParameter" }
        }
      }
    },
    "/reverse-geocode": {
      "get": {
        "tags": ["Geocoding"],
        "operationId": "reverseGeocode",
        "summary": "Reverse geocode a point",
        "description": "Finds the nearest readable address for one latitude and longitude. $0.001 per request; +$0.001 with extra columns.",
        "parameters": [
          {
            "name": "latlng",
            "in": "query",
            "required": true,
            "description": "Latitude and longitude, separated by a comma.",
            "schema": { "type": "string" },
            "example": "40.74838,-73.98485"
          },
          { "$ref": "#/components/parameters/format" },
          { "$ref": "#/components/parameters/fields" }
        ],
        "responses": {
          "200": {
            "description": "A list with one answer, the Google-shaped answer with format=google, or an error.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "array",
                      "items": { "$ref": "#/components/schemas/ReverseResult" }
                    },
                    { "$ref": "#/components/schemas/GoogleGeocodeResponse" },
                    { "$ref": "#/components/schemas/Error" }
                  ]
                },
                "examples": {
                  "geloky": {
                    "summary": "Geloky format",
                    "value": [
                      {
                        "address": "350 5th Ave, New York, NY, 10118, USA",
                        "latitude": 40.748376823379,
                        "longitude": -73.984854050905,
                        "type": "address",
                        "distance": 0,
                        "plus_code": "87G8P2X8+93"
                      }
                    ]
                  },
                  "google": {
                    "summary": "Google format",
                    "value": {
                      "results": [
                        {
                          "formatted_address": "350 5th Ave, New York, NY, 10118, USA",
                          "geometry": {
                            "location": { "lat": 40.748376823379, "lng": -73.984854050905 }
                          },
                          "plus_code": { "global_code": "87G8P2X8+93" },
                          "type": "address",
                          "distance": 0
                        }
                      ],
                      "status": "OK"
                    }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/MissingParameter" }
        }
      }
    },
    "/geocode-batch": {
      "get": {
        "tags": ["Geocoding"],
        "operationId": "geocodeBatch",
        "summary": "Geocode many addresses",
        "description": "Geocodes a list of addresses in one request. Results come back in the order you sent them. $0.001 per address; +$0.001 per address with extra columns. For thousands of rows, uploading the spreadsheet is usually simpler: https://geloky.com/geocoding/",
        "parameters": [
          {
            "name": "addresses",
            "in": "query",
            "required": true,
            "description": "A JSON array of addresses.",
            "schema": { "type": "string" },
            "example": "[\"350 5th Ave, New York, NY 10118\",\"1 Centre St, New York, NY 10007\"]"
          },
          { "$ref": "#/components/parameters/format" },
          { "$ref": "#/components/parameters/fields" }
        ],
        "responses": {
          "200": {
            "description": "One answer per address in the order sent, the Google-shaped answer with format=google, or an error.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "array",
                      "items": { "$ref": "#/components/schemas/GeocodeResult" }
                    },
                    { "$ref": "#/components/schemas/GoogleGeocodeResponse" },
                    { "$ref": "#/components/schemas/Error" }
                  ]
                },
                "examples": {
                  "geloky": {
                    "summary": "Geloky format",
                    "value": [
                      {
                        "address": "350 5th Ave, New York, New York, 10118",
                        "latitude": 40.74837686528841,
                        "longitude": -73.98485413472395
                      },
                      {
                        "address": "1 Centre St, New York, New York, 10007",
                        "latitude": 40.712968,
                        "longitude": -74.004124
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/MissingParameter" }
        }
      }
    },
    "/reverse-geocode-batch": {
      "get": {
        "tags": ["Geocoding"],
        "operationId": "reverseGeocodeBatch",
        "summary": "Reverse geocode many points",
        "description": "Finds the address of every point in a list, in the order you sent them. $0.001 per point; +$0.001 per point with extra columns.",
        "parameters": [
          {
            "name": "coordinates",
            "in": "query",
            "required": true,
            "description": "A JSON array of \"latitude,longitude\" strings.",
            "schema": { "type": "string" },
            "example": "[\"40.74838,-73.98485\",\"40.71297,-74.00412\"]"
          },
          { "$ref": "#/components/parameters/format" },
          { "$ref": "#/components/parameters/fields" }
        ],
        "responses": {
          "200": {
            "description": "One answer per point in the order sent, the Google-shaped answer with format=google, or an error.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "array",
                      "items": { "$ref": "#/components/schemas/ReverseResult" }
                    },
                    { "$ref": "#/components/schemas/GoogleGeocodeResponse" },
                    { "$ref": "#/components/schemas/Error" }
                  ]
                },
                "examples": {
                  "geloky": {
                    "summary": "Geloky format",
                    "value": [
                      {
                        "address": "350 5th Ave, New York, NY, 10118, USA",
                        "latitude": 40.748376823379,
                        "longitude": -73.984854050905,
                        "type": "address",
                        "distance": 0,
                        "plus_code": "87G8P2X8+93"
                      },
                      {
                        "address": "1 Centre St, New York, NY, 10007, USA",
                        "latitude": 40.712980297726,
                        "longitude": -74.003758092413,
                        "type": "address",
                        "distance": 31,
                        "plus_code": "87G7PX7W+59"
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/MissingParameter" }
        }
      }
    },
    "/distance": {
      "get": {
        "tags": ["Distances"],
        "operationId": "distance",
        "summary": "Distance between two places",
        "description": "Road distance and travel time from an origin to a destination. Each end is a point or an address: an address is found first, as the geocode endpoint finds it, and the answer adds origin_address and destination_address. When an address is not found, the answer is an error and nothing is charged. $0.001 per request, +$0.001 per address.",
        "parameters": [
          {
            "name": "origin",
            "in": "query",
            "required": true,
            "description": "Starting point as latitude,longitude, or an address.",
            "schema": { "type": "string" },
            "example": "40.74470,-73.94850"
          },
          {
            "name": "destination",
            "in": "query",
            "required": true,
            "description": "End point or address, in either form.",
            "schema": { "type": "string" },
            "example": "350 5th Ave, New York, NY 10118"
          },
          {
            "name": "vehicle",
            "in": "query",
            "description": "auto, truck or walk.",
            "schema": { "type": "string", "enum": ["auto", "truck", "walk"], "default": "auto" }
          },
          { "$ref": "#/components/parameters/priority" },
          { "$ref": "#/components/parameters/units" },
          { "$ref": "#/components/parameters/order" },
          {
            "name": "format",
            "in": "query",
            "description": "geloky for a plain list, google for the shape of the Google Distance Matrix API.",
            "schema": { "type": "string", "enum": ["geloky", "google"], "default": "geloky" }
          }
        ],
        "responses": {
          "200": {
            "description": "A list with one distance, the Google-shaped answer with format=google, or an error.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "array",
                      "items": { "$ref": "#/components/schemas/DistanceResult" }
                    },
                    { "$ref": "#/components/schemas/GoogleDistanceResponse" },
                    { "$ref": "#/components/schemas/Error" }
                  ]
                },
                "examples": {
                  "points": {
                    "summary": "Between two points",
                    "value": [
                      {
                        "origin": "40.74470,-73.94850",
                        "destination": "40.74838,-73.98485",
                        "length": 2.391,
                        "time": 14.78
                      }
                    ]
                  },
                  "addresses": {
                    "summary": "Between two addresses",
                    "value": [
                      {
                        "origin": "40.698236152855,-73.975163732644",
                        "destination": "40.748376823379,-73.984854050905",
                        "length": 6.517,
                        "time": 30.01,
                        "origin_address": "63 Flushing Ave, Brooklyn, New York, 11205",
                        "destination_address": "350 5th Ave, New York, New York, 10118"
                      }
                    ]
                  },
                  "google": {
                    "summary": "Google format",
                    "value": {
                      "destination": "40.74838,-73.98485",
                      "origin": "40.74470,-73.94850",
                      "rows": [
                        {
                          "elements": {
                            "distance": { "text": "2.391 ml", "value": 2.391 },
                            "duration": { "text": "14.78 mins", "value": 14.78 },
                            "status": "OK"
                          }
                        }
                      ],
                      "status": "OK"
                    }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/MissingParameter" }
        }
      }
    },
    "/route": {
      "get": {
        "tags": ["Distances"],
        "operationId": "route",
        "summary": "Route through several stops",
        "description": "Plans one road route through 2 to 25 stops in the order given, each a point or an address, with every leg, the total and, if you want it, the shape to draw on a map. $0.001 per leg, +$0.001 per address; an address the route comes back to is charged once.",
        "parameters": [
          {
            "name": "points",
            "in": "query",
            "required": true,
            "description": "2 to 25 stops separated by |, each as latitude,longitude or an address. If an address holds a |, send the stops as a JSON array of strings.",
            "schema": { "type": "string" },
            "example": "40.7128,-74.0060|39.9526,-75.1652|38.9072,-77.0369"
          },
          {
            "name": "vehicle",
            "in": "query",
            "description": "auto, truck, walk, or direct for straight lines without travel time.",
            "schema": { "type": "string", "enum": ["auto", "truck", "walk", "direct"], "default": "auto" }
          },
          {
            "name": "geometry",
            "in": "query",
            "description": "geojson or polyline to include the route shape.",
            "schema": { "type": "string", "enum": ["none", "geojson", "polyline"], "default": "none" }
          },
          { "$ref": "#/components/parameters/units" },
          { "$ref": "#/components/parameters/priority" },
          { "$ref": "#/components/parameters/order" }
        ],
        "responses": {
          "200": {
            "description": "The route, or an error.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    { "$ref": "#/components/schemas/RouteResponse" },
                    { "$ref": "#/components/schemas/Error" }
                  ]
                },
                "examples": {
                  "points": {
                    "summary": "Through three points",
                    "value": {
                      "legs": [
                        { "origin": "40.7128,-74.0060", "destination": "39.9526,-75.1652", "length": 94.423, "time": 125.55 },
                        { "origin": "39.9526,-75.1652", "destination": "38.9072,-77.0369", "length": 137.355, "time": 187.74 }
                      ],
                      "total": { "length": 231.778, "time": 313.29 },
                      "geometry": null,
                      "source": "routing"
                    }
                  },
                  "tooManyStops": {
                    "summary": "An input problem",
                    "value": { "code": "ERROR", "message": "points may contain at most 25 locations" }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/MissingParameter" }
        }
      }
    },
    "/nearest-location": {
      "post": {
        "tags": ["Distances"],
        "operationId": "nearestLocation",
        "summary": "Nearest location for every customer",
        "description": "Send your customers and your locations, such as stores, warehouses or offices: each customer gets its nearest location. Every location is measured in a straight line first; by road, the 3 closest are compared and the quickest wins, or the shortest. $0.003 per customer by road, $0.001 in a straight line, +$0.001 per address looked up (the same address twice in one call counts once). If the wallet cannot pay for the whole call, the answer is an error and nothing is charged. The key goes in the URL with POST too.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/NearestRequest" },
              "example": {
                "customers": ["120 Franklin St, Brooklyn, NY 11222", "40.6703,-73.9790"],
                "locations": [
                  { "name": "Lower East Side store", "latitude": 40.7178, "longitude": -73.9871 },
                  { "name": "Brooklyn store", "latitude": 40.6831, "longitude": -73.976 },
                  { "name": "Long Island City store", "latitude": 40.7508, "longitude": -73.9386 }
                ]
              }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/Nearest" }
        }
      },
      "get": {
        "tags": ["Distances"],
        "operationId": "nearestLocationGet",
        "summary": "Nearest location for every customer (short lists)",
        "description": "The same as the POST call, for short lists: separate the customers, or the locations, with |.",
        "parameters": [
          {
            "name": "customers",
            "in": "query",
            "required": true,
            "description": "1 to 50 customers separated by |, each an address or latitude,longitude.",
            "schema": { "type": "string" },
            "example": "120 Franklin St, Brooklyn, NY 11222"
          },
          {
            "name": "locations",
            "in": "query",
            "required": true,
            "description": "1 to 500 locations separated by |, each an address or latitude,longitude.",
            "schema": { "type": "string" },
            "example": "40.7178,-73.9871|40.6831,-73.9760|40.7508,-73.9386"
          },
          {
            "name": "vehicle",
            "in": "query",
            "description": "auto or walk to compare by road, direct for a straight line only.",
            "schema": { "type": "string", "enum": ["auto", "walk", "direct"], "default": "auto" }
          },
          { "$ref": "#/components/parameters/priority" },
          { "$ref": "#/components/parameters/units" },
          { "$ref": "#/components/parameters/order" }
        ],
        "responses": {
          "200": { "$ref": "#/components/responses/Nearest" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "apiKey",
        "in": "query",
        "name": "key",
        "description": "Your API key, from the API tab of your dashboard: https://geloky.com/dashboard/tab/api"
      }
    },
    "parameters": {
      "format": {
        "name": "format",
        "in": "query",
        "description": "geloky for a plain list, google for the same shape as the Google Geocoding API.",
        "schema": { "type": "string", "enum": ["geloky", "google"], "default": "geloky" }
      },
      "fields": {
        "name": "fields",
        "in": "query",
        "description": "Extra columns, comma separated: timezone, county, census (tract and block group), district, or all. County, census and district are for the US only. +$0.001 per lookup, whatever you ask for. The Google format leaves them out, and nothing is charged for them.",
        "schema": { "type": "string" },
        "example": "timezone,county"
      },
      "priority": {
        "name": "priority",
        "in": "query",
        "description": "fast for the quickest route, short for the shortest.",
        "schema": { "type": "string", "enum": ["fast", "short"], "default": "fast" }
      },
      "units": {
        "name": "units",
        "in": "query",
        "description": "ml for miles or km for kilometers.",
        "schema": { "type": "string", "enum": ["ml", "km"], "default": "ml" }
      },
      "order": {
        "name": "order",
        "in": "query",
        "description": "Use lon_lat if your points list longitude first.",
        "schema": { "type": "string", "enum": ["lat_lon", "lon_lat"], "default": "lat_lon" }
      }
    },
    "responses": {
      "MissingParameter": {
        "description": "A required parameter is missing.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "name": { "type": "string", "example": "Bad Request" },
                "message": { "type": "string", "example": "Missing required parameters: address" },
                "code": { "type": "integer", "example": 0 },
                "status": { "type": "integer", "example": 400 }
              }
            }
          }
        }
      },
      "Nearest": {
        "description": "Each customer's nearest location, or an error.",
        "content": {
          "application/json": {
            "schema": {
              "oneOf": [
                { "$ref": "#/components/schemas/NearestResponse" },
                { "$ref": "#/components/schemas/Error" }
              ]
            },
            "example": {
              "results": [
                {
                  "input": "120 Franklin St, Brooklyn, NY 11222",
                  "found": true,
                  "latitude": 40.728871506047,
                  "longitude": -73.957274488154,
                  "address": "120 Franklin St, Brooklyn, New York, 11222",
                  "nearest": { "index": 2, "name": "Long Island City store", "latitude": 40.7508, "longitude": -73.9386 },
                  "straight_line": 1.8,
                  "road_distance": 2.473,
                  "travel_time": 15.61,
                  "by_road": true
                },
                {
                  "input": "40.6703,-73.9790",
                  "found": true,
                  "latitude": 40.6703,
                  "longitude": -73.979,
                  "nearest": { "index": 1, "name": "Brooklyn store", "latitude": 40.6831, "longitude": -73.976 },
                  "straight_line": 0.9,
                  "road_distance": 1.47,
                  "travel_time": 11.75,
                  "by_road": true
                }
              ],
              "location_addresses": [],
              "units": "ml",
              "cost_usd": 0.007,
              "balance_usd": 24.993
            }
          }
        }
      }
    },
    "examples": {
      "WrongKey": {
        "summary": "A wrong key",
        "value": { "code": "ERROR", "message": "Wrong key" }
      },
      "NoFunds": {
        "summary": "An empty wallet",
        "value": { "code": "ERROR", "message": "You don't have enough funds. Please top up your API Wallet." }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "description": "A call that could not be served. Nothing is charged.",
        "required": ["code", "message"],
        "properties": {
          "code": { "type": "string", "enum": ["ERROR"] },
          "message": { "type": "string", "example": "Wrong key" }
        }
      },
      "Balance": {
        "type": "object",
        "properties": {
          "balance_usd": { "type": "number", "description": "What is left in the wallet, in US dollars.", "example": 24.999 },
          "requests_total": { "type": "integer", "description": "The requests this wallet has paid for so far.", "example": 1 },
          "price_per_request_usd": { "type": "number", "description": "The price of one request.", "example": 0.001 },
          "top_up_url": { "type": "string", "description": "Where to top up.", "example": "https://geloky.com/dashboard/tab/api" }
        }
      },
      "Coordinate": {
        "description": "A coordinate in decimal degrees, or an empty string when nothing was found.",
        "oneOf": [
          { "type": "number" },
          { "type": "string", "enum": [""] }
        ]
      },
      "ExtraColumns": {
        "type": "object",
        "description": "Present only for the groups asked for with fields. An empty value means there is nothing to say, such as a county outside the US.",
        "properties": {
          "timezone": { "type": "string", "description": "The time zone's name. Any country.", "example": "America/New_York" },
          "utc_offset": { "type": "string", "description": "Offset from UTC in standard time.", "example": "-05:00" },
          "dst": { "type": "string", "description": "yes or no for daylight saving time.", "example": "yes" },
          "county": { "type": "string", "description": "The county's name. US only.", "example": "New York County" },
          "county_fips": { "type": "string", "description": "The county's 5-digit code. US only.", "example": "36061" },
          "tract": { "type": "string", "description": "The 11-digit 2020 census tract. US only.", "example": "36061007600" },
          "block_group": { "type": "string", "description": "The 12-digit block group. US only.", "example": "360610076001" },
          "district": { "type": "string", "description": "The congressional district of the 120th Congress. US only.", "example": "NY-12" },
          "match_level": { "type": "string", "description": "building, street, place, road, postcode, city or region; point for a reverse lookup.", "example": "building" }
        }
      },
      "GeocodeResult": {
        "allOf": [
          {
            "type": "object",
            "properties": {
              "address": { "type": "string", "description": "The address found; empty when nothing was found.", "example": "350 5th Ave, New York, New York, 10118" },
              "latitude": { "$ref": "#/components/schemas/Coordinate" },
              "longitude": { "$ref": "#/components/schemas/Coordinate" }
            }
          },
          { "$ref": "#/components/schemas/ExtraColumns" }
        ]
      },
      "ReverseResult": {
        "allOf": [
          {
            "type": "object",
            "properties": {
              "address": { "type": "string", "description": "The nearest numbered address. Where there is none: a named place, a street or an area.", "example": "350 5th Ave, New York, NY, 10118, USA" },
              "latitude": { "$ref": "#/components/schemas/Coordinate" },
              "longitude": { "$ref": "#/components/schemas/Coordinate" },
              "type": { "type": "string", "enum": ["address", "place", "street", "area"], "description": "How exact the address is." },
              "distance": { "type": "number", "nullable": true, "description": "Metres from your point to the address, or null for an area.", "example": 0 },
              "plus_code": { "type": "string", "description": "Your point as a plus code.", "example": "87G8P2X8+93" }
            }
          },
          { "$ref": "#/components/schemas/ExtraColumns" }
        ]
      },
      "GoogleGeocodeResponse": {
        "type": "object",
        "description": "The shape of the Google Geocoding API (format=google).",
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "formatted_address": { "type": "string" },
                "geometry": {
                  "type": "object",
                  "properties": {
                    "location": {
                      "type": "object",
                      "properties": {
                        "lat": { "$ref": "#/components/schemas/Coordinate" },
                        "lng": { "$ref": "#/components/schemas/Coordinate" }
                      }
                    }
                  }
                },
                "plus_code": {
                  "type": "object",
                  "properties": { "global_code": { "type": "string" } }
                },
                "type": { "type": "string" },
                "distance": { "type": "number", "nullable": true }
              }
            }
          },
          "status": { "type": "string", "example": "OK" }
        }
      },
      "DistanceResult": {
        "type": "object",
        "properties": {
          "origin": { "type": "string", "description": "The starting point as latitude,longitude.", "example": "40.74470,-73.94850" },
          "destination": { "type": "string", "description": "The end point as latitude,longitude.", "example": "40.74838,-73.98485" },
          "length": { "type": "number", "description": "Road distance in the units asked for.", "example": 2.391 },
          "time": { "type": "number", "description": "Travel time in minutes.", "example": 14.78 },
          "origin_address": { "type": "string", "description": "The address found, when the origin was an address." },
          "destination_address": { "type": "string", "description": "The address found, when the destination was an address." }
        }
      },
      "GoogleDistanceResponse": {
        "type": "object",
        "description": "The shape of the Google Distance Matrix API (format=google).",
        "properties": {
          "origin": { "type": "string" },
          "destination": { "type": "string" },
          "rows": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "elements": {
                  "type": "object",
                  "properties": {
                    "distance": {
                      "type": "object",
                      "properties": { "text": { "type": "string" }, "value": { "type": "number" } }
                    },
                    "duration": {
                      "type": "object",
                      "properties": { "text": { "type": "string" }, "value": { "type": "number" } }
                    },
                    "status": { "type": "string" }
                  }
                }
              }
            }
          },
          "status": { "type": "string", "example": "OK" }
        }
      },
      "RouteLeg": {
        "type": "object",
        "properties": {
          "origin": { "type": "string", "example": "40.7128,-74.0060" },
          "destination": { "type": "string", "example": "39.9526,-75.1652" },
          "length": { "type": "number", "example": 94.423 },
          "time": { "type": "number", "description": "Minutes.", "example": 125.55 },
          "origin_address": { "type": "string", "description": "For a stop given as an address, the address found." },
          "destination_address": { "type": "string", "description": "For a stop given as an address, the address found." }
        }
      },
      "RouteResponse": {
        "type": "object",
        "properties": {
          "legs": {
            "type": "array",
            "description": "One leg per pair of neighbouring stops, in route order.",
            "items": { "$ref": "#/components/schemas/RouteLeg" }
          },
          "total": {
            "type": "object",
            "description": "Length and time of the whole route.",
            "properties": {
              "length": { "type": "number", "example": 231.778 },
              "time": { "type": "number", "example": 313.29 }
            }
          },
          "geometry": {
            "description": "The route shape in the format asked for (a GeoJSON LineString or an encoded polyline), or null.",
            "nullable": true,
            "oneOf": [
              { "type": "object" },
              { "type": "string" }
            ]
          },
          "source": { "type": "string", "enum": ["routing", "direct"], "description": "routing for a road route, direct for straight lines." }
        }
      },
      "NearestLocationInput": {
        "description": "A location: an address, latitude,longitude, or an object with an optional name and either a point or an address.",
        "oneOf": [
          { "type": "string", "example": "40.7178,-73.9871" },
          {
            "type": "object",
            "properties": {
              "name": { "type": "string", "example": "Brooklyn store" },
              "latitude": { "type": "number", "example": 40.6831 },
              "longitude": { "type": "number", "example": -73.976 },
              "address": { "type": "string", "example": "445 Albee Square W, Brooklyn, NY 11201" }
            }
          }
        ]
      },
      "NearestRequest": {
        "type": "object",
        "required": ["customers", "locations"],
        "properties": {
          "customers": {
            "type": "array",
            "minItems": 1,
            "maxItems": 50,
            "description": "1 to 50 customers, each an address or latitude,longitude.",
            "items": { "type": "string" }
          },
          "locations": {
            "type": "array",
            "minItems": 1,
            "maxItems": 500,
            "description": "1 to 500 locations, sent with every call.",
            "items": { "$ref": "#/components/schemas/NearestLocationInput" }
          },
          "vehicle": { "type": "string", "enum": ["auto", "walk", "direct"], "default": "auto", "description": "auto or walk to compare by road, direct for a straight line only." },
          "priority": { "type": "string", "enum": ["fast", "short"], "default": "fast" },
          "units": { "type": "string", "enum": ["ml", "km"], "default": "ml" },
          "order": { "type": "string", "enum": ["lat_lon", "lon_lat"], "default": "lat_lon" }
        }
      },
      "NearestResult": {
        "type": "object",
        "properties": {
          "input": { "type": "string", "description": "The customer as you sent it." },
          "found": { "type": "boolean" },
          "latitude": { "type": "number" },
          "longitude": { "type": "number" },
          "address": { "type": "string", "description": "For a customer sent as an address, the address found." },
          "nearest": {
            "type": "object",
            "nullable": true,
            "description": "The nearest location, or null when the customer was not found.",
            "properties": {
              "index": { "type": "integer", "description": "Its position in your list, from 0." },
              "name": { "type": "string" },
              "latitude": { "type": "number" },
              "longitude": { "type": "number" },
              "address": { "type": "string" }
            }
          },
          "straight_line": { "type": "number", "description": "The distance to it in a straight line." },
          "road_distance": { "type": "number", "nullable": true, "description": "The distance by road; null in a straight line." },
          "travel_time": { "type": "number", "nullable": true, "description": "Minutes by road; null in a straight line." },
          "by_road": { "type": "boolean", "description": "true when matched by road." },
          "reason": { "type": "string", "enum": ["no_road", "unavailable"], "description": "Why a customer asked by road was matched in a straight line." }
        }
      },
      "NearestResponse": {
        "type": "object",
        "properties": {
          "results": {
            "type": "array",
            "description": "One per customer, in the order sent.",
            "items": { "$ref": "#/components/schemas/NearestResult" }
          },
          "location_addresses": {
            "type": "array",
            "description": "The locations you sent as addresses, with the points found. Send those next time and pay nothing for the locations.",
            "items": { "type": "object" }
          },
          "units": { "type": "string", "enum": ["ml", "km"] },
          "cost_usd": { "type": "number", "description": "What the call cost." },
          "balance_usd": { "type": "number", "description": "What is left in your wallet." }
        }
      }
    }
  }
}
