Geofencing API Documentation
Service version: 1
Last edit: 2020.05.21
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.
Features
The following features are included in the Geofencing API.
- A Geofencing service available via the developer.tomtom.com online Geofencing API.
- Geofencing configuration that is securely stored by TomTom in the cloud.
- Circles, polygons, corridors, and two-point rectangle fences with labels.
- Objects reported inside or outside of a fence.
- 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 licensing 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
|
|
|
|
|
|
|
|
|
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. |
Interactions with other APIs
Location History API
- The Geofencing API and Location History API share Objects when both are on the same account.
- Each API has access to a view of an Object that is relevant for the given API.
- In the Geofencing API view, the
name
,defaultProject
, andproperties
fields are available for an Object.
- The Geofencing API and Location History API share the
consentForStoringObjectsPositionsHistory
setting.- When this setting is set to
true
both services can save an Objects' positions. - After sending a position through the Geofencing API and triggering a transition calculation, the latest previous position is used, no matter from which service it has been sent.
- When this setting is set to
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 "Geofencing 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'
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.
|
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:
|
Note: Both "Requester" and "Admin" are sometimes called "user" if their respective rights do not conflict. |
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.
|
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.
|
Geofencing Report |
A JSON document that contains the following information for a specified object or point:
The lists:
|
Customer key | 1 ——— 1 | Configuration | 1 ——— 0..* | Project | 1..* ——— 0..* | Fence |
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 | Archive | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
C | R | U | D | C | R | U | D | C | R | U | D | R | C | R | ||||||
Admin |
+ | + | + | + | + | + | + | + | + | + | + | + | + | + | + | |||||
Requestor/Object |
- | + | - | - | - | + | - | - | - | + | - | - | + | - | - |