api-ninjas-com City API

The City API provides useful statistics about tens of thousands of cities around the world.

Operations 1

GET /v1/city Get city data #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/api-ninjas-com:api-ninjas-com-city-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

api-ninjas-com-city-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Ninjas City API
  description: 'Combined OpenAPI specification for every API Ninjas endpoint. Requests go to https://api.api-ninjas.com with an `X-Api-Key` header; get a free key at https://api-ninjas.com/register. Human-readable docs: https://api-ninjas.com/api. Index for LLMs: https://api-ninjas.com/llms.txt.'
  version: 1.0.0
  contact:
    name: API Ninjas
    url: https://api-ninjas.com
  license:
    name: Proprietary
servers:
- url: https://api.api-ninjas.com
  description: API Ninjas Production
security:
- ApiKeyAuth: []
tags:
- name: City
  description: The City API provides useful statistics about tens of thousands of cities around the world.
paths:
  /v1/city:
    get:
      summary: Get city data
      description: Get city data from either a name or population range. Returns a list of cities that satisfies the parameters.
      operationId: getCityData
      parameters:
      - name: name
        in: query
        description: Name of city.
        required: false
        schema:
          type: string
      - name: country
        in: query
        description: Country filter. Must be an ISO-3166 alpha-2 country code (e.g. US).
        required: false
        schema:
          type: string
      - name: min_lat
        in: query
        description: Minimum latitude coordinate.
        required: false
        schema:
          type: number
          format: double
      - name: max_lat
        in: query
        description: Maximum latitude coordinate.
        required: false
        schema:
          type: number
          format: double
      - name: min_lon
        in: query
        description: Minimum longitude coordinate.
        required: false
        schema:
          type: number
          format: double
      - name: max_lon
        in: query
        description: Maximum longitude coordinate.
        required: false
        schema:
          type: number
          format: double
      - name: min_population
        in: query
        description: Minimum city population.
        required: false
        schema:
          type: integer
      - name: max_population
        in: query
        description: Maximum city population.
        required: false
        schema:
          type: integer
      - name: limit
        in: query
        description: How many results to return. Must be between 1 and 30. Default is 1. To get more than 30 results, use the offset parameter. Premium only.
        required: false
        schema:
          type: integer
          default: 1
          minimum: 1
          maximum: 30
      - name: offset
        in: query
        description: Number of results to offset for pagination. Premium only.
        required: false
        schema:
          type: integer
      responses:
        '200':
          $ref: '#/components/responses/CityResponse'
        '400':
          $ref: '#/components/responses/Error400'
        '401':
          $ref: '#/components/responses/Error401'
        '500':
          $ref: '#/components/responses/Error500'
      security:
      - ApiKeyAuth: []
      tags:
      - City
components:
  responses:
    Error500:
      description: Internal Server Error - We had a problem with our server. Try again later.
      content: {}
    CityResponse:
      description: A list of cities matching the query.
      content:
        application/json:
          schema:
            type: array
            items:
              $ref: '#/components/schemas/City'
    Error401:
      description: Unauthorized - No valid API key provided.
      content: {}
    Error400:
      description: Bad Request - The request was unacceptable, often due to missing a required parameter.
      content: {}
  schemas:
    City:
      type: object
      properties:
        name:
          type: string
          description: Name of city.
        latitude:
          type: number
          format: double
          description: Latitude coordinate of the city.
        longitude:
          type: number
          format: double
          description: Longitude coordinate of the city.
        country:
          type: string
          description: ISO-3166 alpha-2 country code.
        population:
          type: integer
          description: Population of the city.
        is_capital:
          type: boolean
          description: Indicates if the city is a capital.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Api-Key
externalDocs:
  description: API Ninjas documentation
  url: https://api-ninjas.com/api