This is the documentation of version 0.48.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

Places Services

Search, geocoding, and reverse geocoding functionality:

import { search, geocode, reverseGeocode } 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 optimization:

import { calculateRoute } from '@tomtom-org/maps-sdk/services';

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

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