This code sample shows how to get OSM data using the Geoapify Places API. You can query cities and places by specifying a city and places category.
Important! Sign up on Geoapify, generate an API key and replace "YOUR_API_KEY" with your API key.
You can run the Python code either locally or through an online compiler. For example, Programiz.
To run the code sample locally:
- Install Python3 from the official page >>
- Install the "requests" module. You can find detailed instructions here >>
- Execute the Python file with "
python3 city_find.py
"
You can download up to 60000 places/day with your API key for free. Learn Geoapify Pricing policies here >>
- Choose a place category and put it to the
placeCategory
variable. You can find a list of categories here >> - Set the
city
variable. - Adjust the
limitPerRequest
andtotalLimit
variables. - Run the Code Sample
- Geoapify Location Platform - APIs and geodata for Location-aware apps
- Places API playground - try the API without registration
- Places API documentation - learn more about API options and parameters