EarthRanger API

EarthRanger API is designed to empower every user with seamless access to real-time tracking and data. 

 

Getting Started

Python Library: Dive into our Python library available on GitHub. Find it here: https://github.com/PADAS/er-client

Examples: https://github.com/PADAS/er-client/tree/main/docs/examples 

Full REST API Documentation: Once logged in to the EarthRanger admin portal, you can access the full REST API, documented here: https://sandbox.pamdas.org/api/v1.0/docs/index.html

Interactive Documentation: Replace "sandbox" in the URL with your server name to interact with the API directly: https://sandbox.pamdas.org/api/v1.0/docs/interactive/

 

Super-Short Quick Start Version

 

Authentication

We use OAuth2 tokens for authentication. You can create a long-lived one here: https://sandbox.pamdas.org/admin/oauth2_provider/accesstoken/ or request one from EarthRanger Support.

 

Create an observation (track location or sensor reading)

The general concept is that a source provider is a service that describes one or more sources that provide location information for a subject.  

For example, a tracking device manufacturer is a source provider, a rhino tracker is a source and the rhino itself the subject.  With that in mind…

 

As is typical, API headers:

  • Authorization: Bearer <token>
  • Accept: application/json
  • Content-Disposition: attachment; filename={}
  • Content-Type: application/json

 

The body of a location request looks like:        

{
  "location": {
    "lat": 47.123,
    "lon": -122.123
  },
  "recorded_at": "2019-02-19T13:59:15.000Z",
  "manufacturer_id": "SomeUniqueIDForTheDevice",
  "subject_name": "Car 4",
  "subject_type": "vehicle",
  "subject_subtype": "car",
  "model_name": "Land Cruiser",
  "source_type": "tracking_device",
  "additional": {
    "anykey": "anyvalue"
  }
}

 

Note: If you pass in an observation where the system hasn’t seen that source-provider / manufacturer_id combination before it’ll create sources and subjects as necessary.

 

 

Create an event

For posting events, here are some sample API calls:

POST to https://sandbox.pamdas.org/api/v1.0/activity/events

 

Headers:

  • Authorization: Bearer xxxxxxxx
  • Accept: application/json
  • Content-Disposition: attachment; filename={}
  • Content-Type: application/json

 

Body example:

{
  "event_type": "mist_rep",
  "time": "2019-01-17T06:18:44.056439",
  "priority": 100,
  "location": {
    "latitude": 47.123,
    "longitude": -122.123
  },
  "event_details": {
    "mistrep_Method": "Air Evac",
    "mistrep_Injury": "Malaria",
    "mistrep_Symptoms": "Fever and sweating",
    "mistrep_Treatment": "Anti malarial medicine"
  }
}

 

Note that event_type and the fields for event_details correspond to the entry in the Django admin’s Activity > Event types page

 


Was this article helpful?