City API

I built the City API because I needed a less heavy API compared to something like Google Places. I use Google Places when I want an exact address but for some of projects all I need is a general city. That's how the City API was built and I continue to try an expand the number of cities in it.

As simple as possible to use

List Cities

End Point: https://keithweaver.ca/rest/city-api/v1/city/list

Parameters:

apikey - Your "City API" API Key. It can be found above after logging in.

query - Search query or keyword, ex. "Ott" for "Ottawa" (Optional)

country - The country that the city resides in. (Optional)

Successful Response:

{
    "success" : true,
    "message" : "Returned a list of cities.",
    "cities" : [
        {
            "id" : "city_ABC123",
            "name" : "Ottawa",
            "state" : "Ontario",
            "country" : "Canada"
        }
    ]
}

More docs about this endpoint

Get City

End Point: https://keithweaver.ca/rest/city-api/v1/city/get

Parameters:

apikey - Your "City API" API Key. It can be found above after logging in.

cityId - Reference a city by their unique id to return information about that city.

Successful Response:

{
    "success" : true,
    "message" : "Return information about the city of Ottawa",
    "city" : {
        "id" : "city_ABC123",
        "name" : "Ottawa",
        "state" : "Ontario",
        "country" : "Canada"
    }
}

More docs about this endpoint

List Countries

End Point: https://keithweaver.ca/rest/city-api/v1/country/list

Parameters:

apikey - Your "City API" API Key. It can be found above after logging in.

Successful Response:

{
    "success" : true,
    "message" : "Returned a list of countries.",
    "countries" : [
        "Canada"
    ]
}

More docs about this endpoint

Suggest City

End Point: https://keithweaver.ca/rest/city-api/v1/city/suggest

Parameters:

apikey - Your "City API" API Key. It can be found above after logging in.

city - Name of the city

country - The country the city resides in.

state - The state or province the city resides in. (Optional)

Successful Response:

{
    "success" : true,
    "message" : "Thank you for your suggestion"
}

More docs about this endpoint