Most components of each geocoding response include a unique identifier in the form of a gid.
For example, if you search for an address, you may want to get details about the localadmin.
You can get more information by looking up the result's localadmin_gid with the place endpoint.
The Stadia Maps JavaScript/TypeScript SDK is available for any package manager that supports the npm registry.
npminstall@stadiamaps/api
yarnadd@stadiamaps/api
bunadd@stadiamaps/api
import{GeocodingApi,Configuration}from'@stadiamaps/api';// If you are writing for a backend application or can't use domain-based auth,// then you'll need to add your API key like so:// // const config = new Configuration({ apiKey: "YOUR-API-KEY" }); // You can also use our EU endpoint to keep traffic within the EU using the basePath option:// const config = new Configuration({ basePath: "https://api-eu.stadiamaps.com" });// const api = new GeocodingApi(config);constapi=newGeocodingApi();constres=awaitapi.place({ids:["openstreetmap:address:way/109867749"]});
Installation Instructions
The Stadia Maps Python SDK is available through any package manager that supports PyPi.
pipinstallstadiamaps
poetryaddstadiamaps
importosimportstadiamapsfromstadiamaps.restimportApiException# You can also use our EU endpoint to keep traffic within the EU like so:# configuration = stadiamaps.Configuration(host="https://api-eu.stadiamaps.com")configuration=stadiamaps.Configuration()# Configure API key authentication (ex: via environment variable). configuration.api_key['ApiKeyAuth']=os.environ["API_KEY"]withstadiamaps.ApiClient(configuration)asapi_client:# Create an instance of the API classapi_instance=stadiamaps.GeocodingApi(api_client)try:res=api_instance.place(["openstreetmap:address:way/109867749"])exceptApiExceptionase:# Add your error handling hereprint("Exception when calling the Stadia Maps API: %s\n"%e)
Installation Instructions
If aren't already using Maven Central,
add the repository in your Gradle build script.
repositories{mavenCentral()}
Then, add the API package and its dependencies.
build.gradle.kts
dependencies{valretrofitVersion="2.11.0"// API packageimplementation("com.stadiamaps:api:4.0.0")// Dependenciesimplementation("com.squareup.moshi:moshi-kotlin:1.14.0")implementation("com.squareup.moshi:moshi-adapters:1.14.0")implementation("com.squareup.okhttp3:logging-interceptor:4.10.0")implementation("com.squareup.retrofit2:retrofit:$retrofitVersion")implementation("com.squareup.retrofit2:converter-moshi:$retrofitVersion")implementation("com.squareup.retrofit2:converter-scalars:$retrofitVersion")}
build.gradle
dependencies{defretrofitVersion="2.11.0"// API packageimplementation'com.stadiamaps:api:4.0.0'// Dependenciesimplementation'com.squareup.moshi:moshi-kotlin:1.15.1'implementation'com.squareup.moshi:moshi-adapters:1.15.1'implementation'com.squareup.okhttp3:logging-interceptor:4.10.0'implementation"com.squareup.retrofit2:retrofit:${retrofitVersion}"implementation"com.squareup.retrofit2:converter-moshi:${retrofitVersion}"implementation"com.squareup.retrofit2:converter-scalars:${retrofitVersion}"}
Our API package is available on Maven Central.
All you need to do is add a few dependencies to your pom.xml.
pom.xml
<properties><retrofit.version>2.9.0</retrofit.version></properties><dependencies><!-- API package --><dependency><groupId>com.stadiamaps</groupId><artifactId>api</artifactId><version>4.0.0</version></dependency><!-- Dependencies --><dependency><groupId>com.squareup.moshi</groupId><artifactId>moshi-kotlin</artifactId><version>1.15.1</version></dependency><dependency><groupId>com.squareup.moshi</groupId><artifactId>moshi-adapters</artifactId><version>1.15.1</version></dependency><dependency><groupId>com.squareup.okhttp3</groupId><artifactId>logging-interceptor</artifactId><version>4.10.0</version></dependency><dependency><groupId>com.squareup.retrofit2</groupId><artifactId>retrofit</artifactId><version>${retrofit.version}</version></dependency><dependency><groupId>com.squareup.retrofit2</groupId><artifactId>converter-moshi</artifactId><version>${retrofit.version}</version></dependency><dependency><groupId>com.squareup.retrofit2</groupId><artifactId>converter-scalars</artifactId><version>${retrofit.version}</version></dependency></dependencies>
// Imports (at the top of your source file; we've used some wildcard imports for simplicity)importcom.stadiamaps.api.*importcom.stadiamaps.api.auth.ApiKeyAuthimportcom.stadiamaps.api.infrastructure.*importcom.stadiamaps.api.models.*// Set your API key (from an environment variable in this case) valapiKey=System.getenv("STADIA_API_KEY")?:throwRuntimeException("API Key not set")// 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:// val client = ApiClient(baseUrl = "https://api-eu.stadiamaps.com")valclient=ApiClient()client.addAuthorization("ApiKeyAuth",ApiKeyAuth("query","api_key",apiKey))// Configure a service for the group of APIs we want to talk tovalservice=client.createService(GeocodingApi::class.java)// Set up the request.// Note: this code is blocking for demonstration purposes.// If you're using Kotlin with coroutines,// you can also use these asynchronously within suspend functions.// Synchronous code can enqueue a callback to avoid blocking// (you'll definitely want to do one of these instead when on the main thread of an app).// See the docs for details: https://square.github.io/retrofit/2.x/retrofit/retrofit2/Call.htmlvalres=service.place(CollectionFormats.CSVParams("openstreetmap:address:way/109867749")).execute()if(res.isSuccessful){println("Found result: ${res.body()}")}else{println("Request failed with error code ${res.code()}")}
Installation Instructions
Our Swift SDK is distributed using the Swift Package Manager (SPM).
Apple's documentation
shows how to add a Swift Package dependency to your Xcode project.
On the Add Package screen, you can find our package by its repository URL: https://github.com/stadiamaps/stadiamaps-api-swift.
importStadiaMaps// This setup code can go anywhere before you actually make an API call (typically in your app init)funcsetupStadiaMapsAPI(){// Set your API key StadiaMapsAPI.customHeaders=["Authorization":"Stadia-Auth YOUR-API-KEY"]// Optionally use our EU endpoint to keep traffic within the EU// StadiaMapsAPI.basePath = "https://api-eu.stadiamaps.com"}// This function demonstrates how to call the Stadia Maps API.// If you have not yet adopted async/await in your Swift codebase, you can use the Task API// to call async functions in a non-async context: https://developer.apple.com/documentation/swift/task.funcmyFunction()asyncthrows{letres=tryawaitGeocodingAPI.place(ids:["openstreetmap:address:way/109867749"])// Do something with the response...print(res)}
Installation Instructions
Composer
To install the package via Composer,
add stadiamaps/stadiamaps-api-php to your composer.json:
<?php// use or require, depending on your installation method.// Configure API key authorization (replace with your Stadia Maps API key) $config=OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key','YOUR-API-KEY');// You can also use our EU endpoint to keep traffic within the EU using setHost:// $config = Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR-API-KEY')->setHost('https://api-eu.stadiamaps.com');$apiInstance=newOpenAPI\Client\Api\GeocodingApi(newGuzzleHttp\Client(),$config);try{$result=$apiInstance->place(['openstreetmap:address:way/109867749']);}catch(Exception$e){// Add your error handling hereecho'Exception when calling the Stadia Maps API: ',$e->getMessage(),PHP_EOL;}
Unlike most vendors, we won't charge you 10x the standard fee per request to store geocoding results long-term!
However, we do require an active Standard, Professional, or Enterprise subscription
to permanently store results (e.g. in a database).
Temporary storage in the normal course of your work is allowed on all plans.
See our terms of service for the full legal terms.
Interpolated addresses are derived data and are not searchable directly by GID at this time
(but other attributes of the response, such as the localadmin and region generally will).
Some sources do not guarantee stability of IDs over time, so caching them may lead to unexpected results.
In general, Geonames and Who's on First are more curated and try to ensure IDs remain stable, but OpenAddresses
and OpenStreetMap IDs are inherently unstable.
All geocoding, autocomplete, and search endpoints share a common response format.
See the response format documentation for details.
This endpoint will likely be extended in the future.