API Usage

 · 2 min read
 · Rory Hughes

The API has 3 main endpoints of interest.

Live (/api/live)

openpositioning.org/api/live/<route>/?key=<master_api_key>

The live API endpoint is what you should use to submit positioning data to the server and query data that has been submitted. You will need a valid master API key to access these endpoints.

Before you can submit any data you will need to generate a user account as well as a user key. You can first make a call to rg

Endpoints

Create User (POST)

/api/live/users/?key=<master_api_key>

Before you can interact with the other live APIs you will need to generate a user and record the user_key. This is as simple as providing a data payload as follows:

{
  "username": "my_user_name"
}

You should get a return as follows:

{
  "username": "my_user_name",
  "id": 1,
  "is_active": true,
  "date_created": "2023-01-08T16:29:37.744774+00:00",
  "api_key": "mq82k1OfC-9frNyjRLyYCg",
  "trajectories": []
}

Note the api_key here. You will need to save this somewhere. This is your user_key that will be associated with all the data that you submit. It will also allow you to query and download the submitted data on the server

Create Upload File (POST)

/api/live/trajectory/upload/{user_key}/?key=<master_api_key>

Now that you have your user_key you can start submitting trajectories. Trajectories need to be sent as proto files that conform to the proto specification for the server.

You can try something like this

curl -X 'POST' \
  'https://openpositioning.org/api/live/trajectory/upload/mq82k1OfC-9frNyjRLyYCg/?key=<master_api_key>' \
  -H 'accept: application/json' \
  -H 'Content-Type: multipart/form-data' \
  -F 'file=@proto_packet.pkt'

Dummy (/api/dummy)

openpositioning.org/api/dummy/<route>

The dummy API endpoints can be used simply for testing without anything being saved or submitted to the databas and implements the exact same interface as the live endpoint. You don't need an API key to interact on the dummy endpoint.

Browser UI (/docs)

openpositioning.org/docs

Is a browser interface to our api where you can see all the available routes and test the communication with the API through your browser. This can be really useful for debugging and getting familiar with the API before you try to write any applications to query it directly.

The AP

image of the unlock button on the interactive API