Load Market
Getting started

Quickstart

This walkthrough uses a test partner key, so no driver is contacted and nothing is billed. You need curl and a terminal (bash or zsh). jq is optional.

1. Get your keys

You need two keys (see Get API access):

  • YOUR_API_KEY - your test partner key (x-api-key), issued by Load Market.
  • YOUR_CLIENT_KEY - your organization's client key (x-api-client-key), copied by an organization admin or manager from Settings > API Key in the Load Market web app (https://app.load-market.com).
TerminalCode
export LM_API_KEY="YOUR_API_KEY" export LM_CLIENT_KEY="YOUR_CLIENT_KEY" export LM_BASE="https://api.load-market.com/v1"

2. Create a test tracking

Phone 5555550100 simulates a driver who already has the Load Market driver app. The expiration date is 23 hours from now, in epoch milliseconds (a test tracking may last at most 24 hours).

TerminalCode
EXP_DATE=$(( ($(date +%s) + 23 * 3600) * 1000 )) curl -s -X POST "$LM_BASE/create-tracking" \ -H "x-api-key: $LM_API_KEY" \ -H "x-api-client-key: $LM_CLIENT_KEY" \ -H "Content-Type: application/json" \ -d "{\"driverPhone\": 5555550100, \"refId\": \"QUICKSTART-1\", \"expDate\": $EXP_DATE}"

Expected response:

JSONCode
{ "message": "Tracking request created", "trackingId": "api-test-Zr8pL3nW6yQ1cV5kT9xB", "customId": null, "status": { "value": "request", "description": "Pending driver's approval" }, "driverHasApp": true, "billingWeight": 1, "apiUsage": { "planName": "Premium", "totalTrackings": 300, "usedTrackings": 128, "currentPeriodEnd": 1794484800000 }, "testMode": true }

Save the id:

TerminalCode
export TRACKING_ID="api-test-Zr8pL3nW6yQ1cV5kT9xB" # use the trackingId from your response

3. Simulate the driver

Accept the request, then send a position:

TerminalCode
curl -s -X POST "$LM_BASE/test/simulate" \ -H "x-api-key: $LM_API_KEY" \ -H "Content-Type: application/json" \ -d "{\"trackingId\": \"$TRACKING_ID\", \"event\": \"driver.accepted\"}" curl -s -X POST "$LM_BASE/test/simulate" \ -H "x-api-key: $LM_API_KEY" \ -H "Content-Type: application/json" \ -d "{\"trackingId\": \"$TRACKING_ID\", \"event\": \"location\", \"coords\": {\"lat\": 39.781721, \"lng\": -89.650148, \"speed\": 28.6, \"heading\": 205, \"battery\": 0.82, \"accuracy\": 6.5, \"locationSource\": \"gps\"}}"

Each call returns the new tracking state and what happened to the webhook:

JSONCode
{ "message": "Ok", "data": { "trackingId": "api-test-Zr8pL3nW6yQ1cV5kT9xB", "status": { "value": "active", "description": "Active" }, "driverCoords": { "lat": 39.781721, "lng": -89.650148, "speed": 28.6, "heading": 205, "battery": 0.82, "accuracy": 6.5, "locationSource": "gps", "lastUpdate": 1793644927000 } }, "webhook": { "attempted": true, "status": 200, "webhookId": "msg_2b7c1f0e-5d3a-4c8e-9b61-7a4f0d2e9c35", "reason": null } }

(data is shortened here.) webhook.attempted is false when webhooks are not enabled on your test key - that is fine for this walkthrough.

4. Read the tracking

TerminalCode
curl -s "$LM_BASE/get-tracking?trackingId=$TRACKING_ID" \ -H "x-api-key: $LM_API_KEY"

The response has status.value: "active" and the position you simulated in data.driverCoords.

5. Clean up

TerminalCode
curl -s -X DELETE "$LM_BASE/delete-tracking?trackingId=$TRACKING_ID" \ -H "x-api-key: $LM_API_KEY"
JSONCode
{ "message": "Ok" }

Test tracking items are deleted automatically after 24 hours anyway.

Next steps

  • Read Test mode for every simulated event and allowed transition.
  • Set up Webhooks and watch webhook.status in the simulate responses.
  • Try the same calls in the Swagger console or import the Postman collection (set its apiKey and clientKey variables, and "Create a tracking" stores the new trackingId for the other requests).
  • Switch to your live key and a real driver phone when you are ready.
Last modified on