Python developers can install our official package to jump start their geospatial projects using our APIs. The SDK core is generated from our official OpenAPI spec, so you get a strongly typed interface that's always up-to-date with our latest features.
First, install the package via your favorite package manager.
pip install stadiamaps
poetry add stadiamaps
Getting an API Key¶
You'll need an API key to use the client in your project.
- Sign in to the client dashboard. (If you don't have an account yet, sign up for free; no credit card required!)
- Click "Manage Properties."
- If you have more than one property (ex: for several websites or apps), make sure you have selected the correct property from the dropdown at the top of the page.
- Under "Authentication Configuration," you can generate, view or revoke your API key.
Video: How to generate your API key¶
Here's a quick usage example of how to set up a client and do some geocoding.
import os import stadiamaps from stadiamaps.rest import ApiException from pprint import pprint # Defining the host is optional and defaults to https://api.stadiamaps.com # You can also use our EU endpoint to keep traffic within the EU like so: # configuration = stadiamaps.Configuration(host="https://api-eu.stadiamaps.com") # See configuration.py for a list of all supported configuration parameters. configuration = stadiamaps.Configuration() # Configure API key authentication. This example assumes it is injected via an environment # variable. configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"] # Enter a context with an instance of the API client with stadiamaps.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = stadiamaps.GeocodingApi(api_client) text = "Põhja pst 27a" # str | The place name (address, venue name, etc.) to search for. try: # Search and geocode quickly based on partial input. res = api_instance.autocomplete(text) print("The response of GeocodingApi->autocomplete:\n") pprint(res) except ApiException as e: print("Exception when calling GeocodingApi->autocomplete: %s\n" % e)
You can find additional usage examples on the endpoint documentation pages.
Our Python SDK is completely open source! You can find the source code and class documentation on GitHub.