This is the documentation of version 0.50.1. Go to the latest version, 1.0.0-rc.5.

Services quickstart

The Services bundle provides a comprehensive set of GeoJSON-based functions for accessing TomTom's location APIs. These services can be used in any JavaScript-based application, from web browsers to Node.js servers.

Installing Dependencies

# npm or Yarn - automatic peer dependency installation
npm install @tomtom-org/maps-sdk

# pnpm - enable auto-install-peers for easiest setup
echo "auto-install-peers=true" >> .npmrc
pnpm install @tomtom-org/maps-sdk

Peer dependencies (installed automatically with above commands):

For more details, see the Project setup guide.

Setup

import { TomTomConfig } from '@tomtom-org/maps-sdk/core';

TomTomConfig.instance.put({
    apiKey: 'YOUR_API_KEY_HERE'
});

Available Services

All services are imported from @tomtom-org/maps-sdk/services and return GeoJSON.

Places Services

Search, geocoding, POIs, and EV charging:

import {
    search,             // free-form and category search
    geocode,            // address → coordinates
    reverseGeocode,     // coordinates → address
    autocompleteSearch, // type-ahead suggestions
    alongRouteSearch,   // search along a route geometry
    explorationSearch,  // browse POIs by category
    placeById,          // look up a place by its id
    getPOICategories,   // POI category tree
    geometryData,       // administrative / geometry boundaries
    evChargingStationsAvailability, // live EV connector availability
} from '@tomtom-org/maps-sdk/services';

// Search for places
const results = await search({
    query: 'restaurants',
    position: [4.9041, 52.3676]
});

// Geocode address
const location = await geocode({
    query: 'Dam Square, Amsterdam'
});

// Reverse geocode coordinates
const address = await reverseGeocode({
    position: [4.9041, 52.3676]
});

Routing Services

Route calculation and reachable areas (isochrones):

import {
    calculateRoute,           // point-to-point route calculation
    calculateReachableRanges, // isochrone / reachable-range polygons
} from '@tomtom-org/maps-sdk/services';

const route = await calculateRoute({
    locations: [
        [4.9041, 52.3676], // Amsterdam
        [2.3522, 48.8566]  // Paris
    ]
});

Traffic Services

Traffic incidents and area analytics:

import {
    trafficIncidentDetails, // incidents within a bounding box
    trafficAreaAnalytics,   // aggregated traffic statistics for an area
} from '@tomtom-org/maps-sdk/services';

const incidents = await trafficIncidentDetails({
    bbox: [4.728, 52.278, 5.08, 52.479] // [minLon, minLat, maxLon, maxLat]
});

Node.js Usage

The services work identically in Node.js environments:

const { TomTomConfig } = require('@tomtom-org/maps-sdk/core');
const { search, calculateRoute } = require('@tomtom-org/maps-sdk/services');

TomTomConfig.instance.put({
    apiKey: process.env.TOMTOM_API_KEY
});

const results = await search({
    query: 'coffee shops',
    position: [4.9041, 52.3676]
});

Next Steps