OxinionDevelopers
Location

Geofencing

Create and manage geographic zones, and react to entry, exit, and dwell events.

Overview

Geofencing lets you define circular zones on a map. When a user enters, exits, or dwells inside a zone, the SDK fires a typed event you can act on.

Create a geofence

typescript
1import { createOxinion } from 'oxinion';
2
3const oxinion = createOxinion({ apiKey: process.env.OXINION_API_KEY! });
4
5const { success, geofence } = await oxinion.geofencing.create({
6 name: 'Flagship Store',
7 lat: 40.758,
8 lng: -73.985,
9 radius: 150, // metres
10 triggerType: 'enter', // 'enter' | 'exit' | 'dwell'
11});

List geofences

typescript
1const { success, geofences } = await oxinion.geofencing.list();
2
3for (const geo of geofences) {
4 console.log(geo.name, geo.lat, geo.lng, geo.radius);
5}

Methods

geofencing.create(payload)
Create a new geofence. Returns the created geofence with its ID.
geofencing.list()
List all geofences for your API key.

Response shape

typescript
1// geofencing.list()
2const { success, geofences, error } = await oxinion.geofencing.list();
3
4// geofencing.create()
5const { success, geofence, error } = await oxinion.geofencing.create({ ... });
6
7if (!success) {
8 console.error(error);
9}