Dynamic Data
To use the Maps SDK in your application you need to obtain a TomTom API key by following these instructions. Remember to keep your API key secure.
This API is unavailable on a Freemium or Pay As You Grow (PAYG) basis.
[Request access]()
to contact our sales team.
The Dynamic Data module is comprised of four APIs: fuel prices, parking availability, parking prices and EV charging availability. These APIs provide up-to-date information and can be useful for drivers to decide where to park, refill and charge.
Initializing
To use our dynamic data feed, you must configure its credentials and add the SDK as a dependency:
- Get your TomTom API Key and configure the project as described in the Project setup guide.
- Add the
Dynamic data
module dependency in thebuild.gradle.kts
of your application module and synchronize the project.implementation("com.tomtom.sdk.search:dynamic-data-online:1.20.0")
Fuel prices
The fuel prices API provides information on the current fuel prices at a specified fuel station. The only required request parameter is the fuel station identifier, which can be fetched from Fuzzy Search. The identifier is in the SearchResultId
of the SearchResult
, labeled fuelPriceId
.
Not every
SearchResult
contains fuel price information.
1val fuelPriceOptions =2 searchResult.searchResultId.fuelPriceId?.let { fuelPriceId ->3 FuelPriceOptions(fuelPriceId)4 }
A successful request returns a FuelPriceResponse
. If the request fails, a SearchFailure
is returned.
1fuelPriceProvider = OnlineDynamicDataProviderFactory.createFuelPriceProvider(context, "YOUR_TOMTOM_API_KEY")2fuelPriceOptions?.let { options ->3 fuelPriceProvider.requestFuelPrices(4 options,5 object : FuelPriceCallback {6 override fun onSuccess(result: FuelPriceResponse) {7 // YOUR CODE GOES HERE8 }910 override fun onFailure(failure: SearchFailure) {11 // YOUR CODE GOES HERE12 }13 },14 )15}
Parking availability
The parking availability API provides up-to-date information about the number of available parking places and the trend in occupancy at a specified parking location. The only required parameter is the parking information identifier.
You can get this identifier from the result of a Fuzzy Search. The identifier is in the SearchResultId
of the SearchResult
, labeled parkingDetailId
.
Not every
SearchResult
contains parking information.
1val parkingAvailabilityOptions =2 searchResult.searchResultId.parkingDetailId?.let { parkingDetailId ->3 ParkingAvailabilityOptions(parkingDetailId)4 }
A successful request returns ParkingAvailabilityResponse
. If the request fails, a SearchFailure
is returned.
1parkingDetailProvider =2 OnlineDynamicDataProviderFactory.createParkingDetailProvider(3 context,4 "YOUR_TOMTOM_API_KEY",5 )6parkingAvailabilityOptions?.let { options ->7 parkingDetailProvider.requestParkingAvailability(8 options,9 object :10 ParkingAvailabilityCallback {11 override fun onSuccess(result: ParkingAvailabilityResponse) {12 // YOUR CODE GOES HERE13 }1415 override fun onFailure(failure: SearchFailure) {16 // YOUR CODE GOES HERE17 }18 },19 )20}
Parking prices
The parking prices API provides up-to-date parking price information of the specified parking location. The only required parameter is the parking information identifier.
You can get this identifier by doing a Fuzzy Search. The identifier is in the SearchResultId
of the SearchResult
, labeled parkingDetailId
.
Not every
SearchResult
contains parking information.
1val parkingPriceOptions =2 searchResult.searchResultId.parkingDetailId?.let { parkingDetailId ->3 ParkingPriceOptions(4 parkingDetailId = parkingDetailId,5 startTime = Calendar.getInstance(),6 duration = 3.hours,7 )8 }
A successful request returns a ParkingPriceResponse
. If the request fails, a SearchFailure
is returned.
1parkingDetailProvider =2 OnlineDynamicDataProviderFactory.createParkingDetailProvider(3 context,4 "YOUR_TOMTOM_API_KEY",5 )6parkingPriceOptions?.let { options ->7 parkingDetailProvider.requestParkingPrice(8 options,9 object : ParkingPriceCallback {10 override fun onSuccess(result: ParkingPriceResponse) {11 // YOUR CODE GOES HERE12 }1314 override fun onFailure(failure: SearchFailure) {15 // YOUR CODE GOES HERE16 }17 },18 )19}
EV charging availability
The EV charging availability API provides information on the availability of Electric Vehicle (EV) charging points at a specific charging park. The only required parameter is the charging availability identifier, which can be fetched from Fuzzy Search. The identifier is in the SearchResultId
of the evChargingAvailabilityId
.
Not every
SearchResult
contains charging station information.
1val evChargingAvailabilityOptions =2 searchResult.searchResultId.evChargingAvailabilityId?.let { chargingAvailabilityId ->3 EvChargingAvailabilityOptions(4 availabilityId = chargingAvailabilityId,5 connectors =6 setOf(7 ConnectorType.Iec62196Type1Ccs,8 ConnectorType.Iec62196Type3,9 ),10 minPower = Power.kilowatts(5),11 maxPower = Power.kilowatts(15),12 )13 }
Additionally, you can pass optional restrictions when constructing
EvChargingAvailabilityOptions
:connectors
,minPower
andmaxPower
.
A successful request returns an EvChargingAvailabilityResponse
. If the request fails, a SearchFailure
is returned.
1evChargingAvailabilityProvider =2 OnlineDynamicDataProviderFactory.createEvChargingAvailabilityProvider(context, "YOUR_TOMTOM_API_KEY")34evChargingAvailabilityOptions?.let { options ->5 evChargingAvailabilityProvider.requestEvChargingAvailability(6 options,7 object : EvChargingAvailabilityCallback {8 override fun onSuccess(result: EvChargingAvailabilityResponse) {9 // YOUR CODE GOES HERE10 }1112 override fun onFailure(failure: SearchFailure) {13 // YOUR CODE GOES HERE14 }15 },16 )17}