> ## Documentation Index
> Fetch the complete documentation index at: https://docs.shovels.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Get City Details

> Return city details and related location hierarchy.



## OpenAPI

````yaml https://api.shovels.ai/spec/v2/openapi.production.yaml get /cities
openapi: 3.1.0
info:
  title: The Shovels API v2
  description: >

    The Shovels REST API makes it easy for technology developers in the
    property, climate, and

    construction industries to access detailed information about building
    permits, contractors and

    construction activity. Our API is designed to be intuitive and fast. We look
    forward to seeing what

    you build with it:

    [let us
    know](https://docs.google.com/forms/d/e/1FAIpQLSfs5Z6NZyPdnRpL96bMduH95OhfFZgLz9Hkc0-Y7pukUxSLxQ/viewform)

    and we'll check it out!


    ## Key Features

    The API offers access to two primary objects: **Permits** and
    **Contractors**.

    - **Permits**: Official documents issued by city or county authorities
    required before commencing

    construction or alterations to a building.

    - **Contractors**: Skilled professionals in the building trades who
    undertake permitted

    construction projects on various properties.


    And some additional resources:

    - **Lists**: Endpoints for predefined values like tags and property types
    for query parameters.

    - **Addresses**: Endpoint for searching and resolving valid US addresses.

    - **Meta**: Endpoints for metadata about the API and the data behind it.


    ## Getting started


    To begin using the API, please contact our sales team at

    [sales@shovels.ai](mailto:sales@shovels.ai) or grab a

    [free API key](https://app.shovels.ai/create-account/).


    > **Info**: The free API key has a limited number of calls.

    If you hit the limit and need more, please reach out to
    [sales@shovels.ai](mailto:sales@shovels.ai)

    or call us at [1-800-511-7457](tel:+18005117457).


    ### Authentication

    Our API uses a straightforward header-based authentication method:

    ```

    X-API-Key: YOUR_API_KEY_HERE

    ```


    Example Request:


    ```sh

    curl -X GET "https://api.shovels.ai/v2/meta/release" \
            -H "X-API-Key: YOUR_API_KEY_HERE"
    ```


    ## API Details


    ### Quick Overview


    A few quick details about our API:


    | Type                |
    Description                                                                |

    |---------------------|----------------------------------------------------------------------------|

    | SSL only            | We require that all requests are done over
    SSL.                            |

    | UTF-8 encoding      | We use UTF-8
    everywhere.                                                   |

    | Method              | GET for all read
    calls.                                                    |

    | Date format         | All dates in the API are strings in the following
    format: YYYY-MM-DD.      |


    ### Response Types


    The API supports the following response codes:


    | Code | Description |

    |------|-------------|

    | **200 OK** | Everything worked as expected. |

    | **400 Bad Request** | There was something wrong with your request.
    Double-check your input. |

    | **401 Unauthorized** | You need to log in to access this. Make sure your
    API key is correct. |

    | **402 Payment Required** | You will get this error if your reach your
    trial API call limit. |

    | **403 Forbidden** | You don't have permission to access this. |

    | **404 Not Found** | We couldn't find what you're looking for. Check the
    URL or resource ID. |

    | **422 Unprocessable Entity** | There's an issue with the data you
    sent.         Check [Error Handling](#error-handling) if you get this error.
    |

    | **429 Too Many Requests** | You're sending requests too quickly. Slow down
    and try again later. |

    | **500 Internal Server Error** | Yikes, something went wrong on our end.
    Please let us know         at [support@shovels.ai](support@shovels.ai) |


    ### Data Format


    The API returns data in JSON format, either as pages or single objects.


    Paginated responses have the following structure:

    ```json

    {
      "items": [...],
      "size": 50,
      "next_cursor": "eyJkYXR..." | null
    }

    ```

    Where objects are returned as an array in the 'items' field.


    ### Cursor-Based Pagination


    The API uses cursor-based pagination for all paginated endpoints. This
    method uses an opaque

    cursor token to maintain your position in the result set, offering better
    performance,

    consistency, and stability, especially for large datasets.


    ```json

    {
      "items": [...],
      "size": 50,
      "next_cursor": "eyJkYXR.lIjoiMjA.yMy0"
    }

    ```


    To use cursor-based pagination:

    - For the first page: Simply make a request without any pagination
    parameters (or optionally
      specify `size` to control page size)
    - For subsequent pages: Include the `next_cursor` value from the previous
    response using the
      `cursor` parameter

    Example:

    ```

    GET /v2/permits/search?size=10

    GET /v2/permits/search?size=10&cursor=eyJkYXR.lIjoiMjA.yMy0

    ```


    When there are no more results, the `next_cursor` value will be `null`.


    ### Versioning


    The current version of the API is v2, which is reflected in the endpoints
    URL structure:

    `/v2/`. We plan to evolve our API by releasing new versions to ensure
    backward compatibility while

    maintaining a steady pace of continuous improvements.


    ### Error Handling


    Proper error messages and HTTP codes are provided to help you troubleshoot
    issues effectively. Refer

    to the [Response Types](#response-types) section for an overview of HTTP
    error codes and how to

    handle them. Below we describe how to interpret HTTP 422 code.


    #### 422 Unprocessable Entity

    A 422 Unprocessable Entity response occurs when the server understands the
    request but cannot

    process it due to invalid data. This helps you identify issues with your
    input.


    The response includes:


    - **loc**: The location of the error. The first value indicates the location
    and the second
      specifies the problematic field. Common values for the first value include:
        - **body**: The error is in the request body.
        - **query**: The error is in the query parameters.
        - **path**: The error is in the URL path.
        - **header**: The error is in the request headers.
    - **msg**: A message describing the error.

    - **type**: The type of error.


    This information helps you correct your request by pinpointing the exact
    issue. Here are some

    examples:


    **Request Body Error**

    ```json

    {
      "detail": [
        {
          "loc": ["body", "first_name"],
          "msg": "Field is required",
          "type": "value_error.missing"
        }
      ]
    }

    ```


    **Query Parameter Error**

    ```json

    {
      "detail": [
        {
          "loc": ["query", "page"],
          "msg": "Page must be a positive integer",
          "type": "type_error.integer"
        }
      ]
    }

    ```

    **Path Parameter Error**

    ```json

    {
      "detail": [
        {
          "loc": ["path", "id"],
          "msg": "Invalid ID format",
          "type": "value_error.id"
        }
      ]
    }

    ```

    **Header Error**

    ```json

    {
      "detail": [
        {
          "loc": ["header", "X-API-Key"],
          "msg": "API key is missing",
          "type": "value_error.missing"
        }
      ]
    }

    ```

    These examples show how different types of errors are reported, helping you
    to diagnose and fix

    issues in your API requests.


    ## Credit Limits


    API usage is tracked using credits. Each record returned counts as one
    credit.


    ### Response Headers


    Successful JSON responses that return records include credit headers:

    - `X-Credits-Request`: Credits consumed by this request

    - `X-Credits-Limit`: Your monthly credit limit (omitted if unlimited)

    - `X-Credits-Remaining`: Credits remaining in your limit (omitted if
    unlimited)


    ### Checking Usage


    Use `GET /v2/usage` to check your current credit usage:


    ```json

    {
      "credits_used": 847293,
      "credit_limit": 1000000
    }

    ```


    ### Exceeding Limits


    When you exceed your credit limit, the API returns HTTP 402:


    ```json

    {
      "detail": {
        "error": "Monthly credit limit exceeded.",
        "limit": 1000000
      }
    }

    ```


    Credits are calculated on a rolling 30-day window. Usage older than 30 days
    automatically falls off.
  version: 2.0.0
servers:
  - url: https://api.shovels.ai/v2
    description: Shovels API
security: []
tags:
  - name: Meta
    description: Endpoints that provide information about the API and the data.
  - name: Lists
    description: >-
      Predefined lists of values and categories, such as tags and property
      types, which can be utilized as query parameters in other API
      interactions.
  - name: Permits
    description: >-
      Official documents issued by cities or counties before construction or
      alteration of a building can begin.
  - name: Contractors
    description: >-
      Licensed professionals who do permitted work on residential and commercial
      buildings.
  - name: Addresses
    description: US address ID resolution, lookup and metrics endpoints.
  - name: Cities
    description: City ID resolution, lookup and metrics endpoints.
  - name: Counties
    description: County ID resolution, lookup and metrics endpoints.
  - name: Jurisdictions
    description: Jurisdiction ID resolution, lookup and metrics endpoints.
  - name: States
    description: State metrics endpoints.
  - name: Usage
    description: Credit usage tracking.
paths:
  /cities:
    get:
      tags:
        - Cities
      summary: Get City Details
      description: Return city details and related location hierarchy.
      operationId: get_city_details_cities_get
      parameters:
        - name: geo_id
          in: query
          required: true
          schema:
            type: string
            title: Geo Id
            description: Geolocation ID
          description: Geolocation ID
      responses:
        '200':
          description: City details and related location hierarchy.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CitiesDetailsRead'
              example:
                geo_id: Q2l0eV8xMjM0NQ
                name: SAN FRANCISCO, CA
                state: CA
                counties:
                  SAN FRANCISCO: Q291bnR5XzEyMzQ
                jurisdictions:
                  SAN FRANCISCO: SnVyaXNkaWN0aW9uXzEyMzQ
                zipcodes:
                  - '94102'
                  - '94103'
                  - '94104'
                  - '94105'
        '404':
          description: The given geo_id didn't match any cities
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    CitiesDetailsRead:
      properties:
        geo_id:
          type: string
          title: Geo Id
          description: Geolocation ID
        name:
          type: string
          title: Name
          description: Formatted entity name
        state:
          type: string
          title: State
          description: State abbreviation
        counties:
          anyOf:
            - additionalProperties:
                anyOf:
                  - type: string
                  - type: 'null'
              type: object
            - type: 'null'
          title: Counties
          default: {}
        jurisdictions:
          anyOf:
            - additionalProperties:
                anyOf:
                  - type: string
                  - type: 'null'
              type: object
            - type: 'null'
          title: Jurisdictions
          default: {}
        zipcodes:
          anyOf:
            - items:
                anyOf:
                  - type: string
                  - type: 'null'
              type: array
            - type: 'null'
          title: Zipcodes
      type: object
      required:
        - geo_id
        - name
        - state
      title: CitiesDetailsRead
      description: City-specific details read model.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key

````