Sorry, you need to enable JavaScript to visit this website.

Geofencing API Documentation

 

Service version: 1
Last edit: 2019.10.08

The TomTom Geofencing API is currently available.

On this page

Important note:

Before a customer can use Geofencing endpoints they must register.

  • Registering creates a configuration for the customer and creates an Admin Key, used to create/edit/delete Geofencing data.
  • Use the Register Admin Key endpoint in the Configuration service to do this.

Purpose

What is TomTom's Geofencing service?

TomTom's Geofencing service is intended to define virtual barriers on real geographical locations. Together with the location of an object, you can determine whether that object is located within, outside, or close to a predefined geographical area.

Any object that has connectivity can be geofenced. It can be:

  • A person
  • A vehicle
  • A package
  • A telephone

Libraries of fences and objects

For Geofencing to work, you need to create your own library of fences.

  • Fences can be arranged into projects for easier administration.
  • Fences can have multiple user-defined attributes.
  • Fences can be of any shape or size.

You can also create a library of your objects and optionally define their attributes.

Location report

A location report for a given radius contains a list of fences that:

  • The object is in.
  • The object is outside of.

Regardless of the selected radius, a user will always receive the nearest outside fence, if available.

▲ Return to top

Features

The following features are included in the Geofencing API.

  1. A Geofencing service available via the developer.tomtom.com online Geofencing API.
  2. Geofencing configuration that is securely stored by TomTom in the cloud.
  3. Circles, polygons, corridors, and two-point rectangle fences with labels.
  4. Objects reported inside or outside of a fence.
  5. The distance from an object to the nearest border of a fence.

Current limits include:

  • 1k objects
  • 10k projects
  • 1k fences in each project
  • 1k vertices per polygon fence
  • Transition history is kept as active data for 3 months.
  • Transition history is kept as a cold archive 6 months after the active period.

To change any of these limits, please contact your TomTom licencing assistant.

There are no surface size limits on polygons used as fences, except precision. Coordinates with difference smaller than 0.000001 degree between them are indistinguishable.
Surface size of polygons has little impact on response speed, but the number of vertices impacts speed significantly. To receive response faster - one should consider simplifying polygons used as fences.

Services with endpoints

Objects service
The Objects service provides a client-side reporting device acting as a representation of the item to be geofenced.
GETList objects
GETGet object details
POSTAdd new object
PUTEdit object
DELETEDelete object
Projects service
The Projects service provides a collection of fences identified by a unique ID.
GETList projects
GETGet project details
POSTAdd new project
PUTEdit projects
DELETEDelete projects
Report service
The Report service provides a JSON document that contains information for a specified object or point:
GETReport request
 
Configuration service
The Configuration service is responsible for managing one's options. It is essential to create and work with one's account.
POSTRegister Admin Key
POSTRegenerate Admin Key
POSTChange customer secret
Fences service
The Fences service enables you to create fences (areas) with geometries of a certain type, such as "CIRCLE".
GETList fences for a given project
GETGet fence details
PUTEdit fence
POSTAdd new fence to a project
POSTCreate new fence & assign to multiple projects
DELETEDelete fence
DELETEDelete fence from project
Note: The Fences service also contains a chapter Custom fence shapes, describing what fence shapes (apart from GeoJSON polygon/multipolygon) can be used in the Geofencing API.

▲ Return to top

Quick start guide

Configuration

Your API and Admin Keys

You need to have two keys to work with Geofencing:

  • An API Key: This allows you to work with any TomTom Maps API, including Geofencing.
  • An Admin Key: This is used by Geofencing to administer (create, edit, delete) your projects, fences and objects.

Getting started

Follow these steps to start working with the Geofencing API:

Step 1. Register for an API Key

This key will let you read data from the service and request reports. In addition, it will let you register for an Admin Key.

Step 2. Register an Admin Key

To register for an Admin Key, use the Configuration service "Register Admin Key" endpoint. An Admin Key is used to manage objects/fences/projects within the Geofencing API.

Register for your Admin Key using this URL:

URL format

https://api.tomtom.com/geofencing/1/register?key=Your_API_Key
{
  “secret”: “your_secret”
}

or use the curl command:

curl command

curl -XPOST "Content-type: application/json" -d
'{
   “secret”: “your_secret”
 }'
'https://api.tomtom.com/geofencing/1/register?key=Your_API_Key'

The secret has to be between 10 and 30 characters. The secret is a password used to regenerate a stolen or lost Admin Key. It will not be asked for in any other circumstances.

The endpoint returns a generated Admin Key. For example:

{
  "adminKey": "ooCP41LoslEhThwNPyCFjtTsgCDyJgTaoz9JJFpVJvW8MjA3"
}

You should save your Admin Key for administrative calls. You can fully manage your account in the Geofencing API when you have both the API Key and Admin Key.

Step 3. Create a Project

Fences must be added to at least one project, so you need to create a project before creating fences. A Project is created using the Project service "Add new project" endpoint.

URL formt

https://api.tomtom.com/geofencing/1/projects?key=Your_API_Key&adminKey=Your_Admin_Key
{ 
  "name": "A unique project name"
}

curl command

curl -XPOST "Content-type: application/json" -d 
'{
   "name": "A unique project name"
 }'
'https://api.tomtom.com/geofencing/1/projects?key=Your_API_Key&adminKey=Your_Admin_Key'

The endpoint returns project details including a project id.

{
  "id": "57dc2cad-85a3-439a-8224-2730d7822133",
  "name": "A unique project name"
}

This project id is required for future calls (i.e., adding a fence to a project).

Step 4. Creating fences

Fences can be created and added to a project using the Fence service "Add new fence to a project" endpoint.

URL format

https://api.tomtom.com/geofencing/1/projects/projectId?key=Your_API_Key&adminKey=Your_Admin_Key
{
  "name": "Flemish diamond"
  "type": "Polygon",
  "coordinates": [
    [
      [3.55, 51.08],
      [4.36, 50.73],
      [4.84, 50.85],
      [4.45, 51.30],
      [3.55, 51.08]
    ]
  ]
}

curl command

curl -XPOST "Content-type: application/json" -d '
{
  "name": "Flemish diamond"
  "type": "Polygon",
  "coordinates": [
    [
      [3.55, 51.08],
      [4.36, 50.73],
      [4.84, 50.85],
      [4.45, 51.30],
      [3.55, 51.08]
    ]
  ]
}'
'https://api.tomtom.com/geofencing/1/projects/projectId?key=Your_API_Key&adminKey=Your_Admin_Key'

For your convenience, TomTom has a web app to create your fences which can be downloaded "geofences-creator" from our GitHub repository.

The endpoint returns fence details.

{
  "id": "e33f7aee-2e86-4485-af82-631debd73d86",
  "name": "Flemish diamond",
  "type": "Feature",
  "geometry": {
    "type": "Polygon",
    "coordinates": [
      [
        [3.55, 51.08],
        [4.36, 50.73],
        [4.84, 50.85],
        [4.45, 51.30],
        [3.55, 51.08]
      ]
    ]
  },
  "properties": {}
}

Step 5. Creating objects

For each entity to be geofenced (person, vehicle, package, telephone, etc.) an object can be created using the Object service "Add new object" endpoint.

Note: Creating an object currently is not mandatory to get a report based on a position. In future releases we will include support for an object's history where creating an object is required to use the history feature.

URL format

https://api.tomtom.com/geofencing/1/objects?key=Your_API_Key&adminKey=Your_Admin_Key
{
  "name": "A Volvo Car"
}

curl command

curl -XPOST "Content-type: application/json" -d 
'{
   "name": "A Volvo Car"
 }'
'https://api.tomtom.com/geofencing/1/objects?key=Your_API_Key&adminKey=Your_Admin_Key'

Step 6. Reporting

Pass an object location to the Report service "Report request" endpoint to get:

  • A list of fences the object is inside of.
  • a list of fences the object is outside of.

URL format

https://api.tomtom.com/geofencing/1/report/projectId?key=Your_API_Key&point=lon,lat

curl command

curl 'https://api.tomtom.com/geofencing/1/report/projectId?key=Your_API_Key&point=4.055737,51.030168'

▲ Return to top

Roles in Geofencing

Each Geofencing API user has a Role assigned to them. Roles define activities that a user can perform within the service.

Entity Description
Customer The owner of the API Key.

  • The Customer is an abstract entity that can be a Requester, an Admin, or just the owner of an account.
  • The Customer has no assigned role in the system.
Requester A client-side entity with read-only rights for data within a configuration. The Requester only requires an API Key to query the service.
Admin A client-side entity with rights to create, read, update and delete data belonging to an account (identified by an API Key) that it is assigned to. To perform administrative functions, the Admin requires both an API Key and an Admin Key.
Object A client-side reporting device that acts as a representation of the thing to be geofenced (a person, drone, vehicle, etc.). It is defined on the customer side by an Admin.
An Object has the following characteristics:

  • It is uniquely identifiable.
  • It can only be linked to a single Configuration at a time.
  • It has a certain connectivity capability.
  • It does not have to always be connected to the Geofencing service.
  • It has a position. It may also have other user-defined properties.

To query the service, an Object only requires an API Key.

Note: Both "Requester" and "Admin" are sometimes called "user" if their respective rights do not conflict.

▲ Return to top

Entities in Geofencing

Entities are manageable elements within the Geofencing API.

Entity Description
Point The object's coordinate on earth, obtained by GPS sensors or otherwise.
Configuration A series of projects, fences, and objects with their attributes, referred to by an API Key.

  • Configurations are defined on the customer side.
  • There can be only one configuration per customer key.
Project A collection of fences identified by a unique ID. A Configuration can have multiple Projects, but each Project is attached to only one Configuration.
Fence A virtual representation of a certain geographic area.

  • Fences can have various shapes and can have multiple user-defined properties.
  • A Project can have one Fence. It can also have multiple Fences.
  • A Fence must belong to at least one Project (it can belong to more).
Report A JSON document that contains the following information for a specified object or point:

  • A list of fences the object/point is inside of.
  • A list of the fences within a specified radius that the object/point is not inside of.
  • The lists can be empty if no fences match the Request parameters.

The lists:

  • Can be empty if no fences match the Request parameters.
  • Will always show the closest outside fence, even if it is outside of the search radius.
  • The outside fences list can only be empty if there are no more fences left in the project.

Customer key 1 ——— 1 Configuration 1 ——— 0..* Project 1..* ——— 0..* Fence

▲ Return to top

Rights in Geofencing

Rights describe types of actions that a user can perform within the Geofencing API.

Legend to the following data table
(C)reate: an entity can create new projects, fences, objects.
(R)ead: an entity can generate reports, list projects/fences/objects, get details about a project/fence/object.
(U)pdate: an entity can change attributes and properties of projects/fences/objects, and assign a fence to a project
(D)elete: an entity can delete projects/fences/objects, remove a fence relation to a project, or an object relation to a project.
  Fence Object Project Report
C R U D C R U D C R U D R
Admin + + + + + + + + + + + + +
Requestor/Object - + - - - + - - - + - - +

▲ Return to top

You are here