Barq Global API Reference v1
Guides

Step-by-Step Guides

Short, practical walkthroughs for the most common integrations. Every request below uses an endpoint from the API reference.

Quickstart

Set Up Your Development Environment

Configure your credentials, confirm your account access and read your first device. You will use a device ID from the inventory response in a second request.

Download Quickstart (PDF)

Before You Begin

  • A terminal with cURL, or Python 3 for the server example below. The reference also includes JavaScript examples for Node.js 22 or newer.
  • An API token issued to your company by Barq and an active account/subscription. Request access through the button in the header.
  • At least one assigned device to complete the status read. Start with the inventory to discover its Barq ID.

These examples use standard HTTP tools. Browser Tracking sign-in and API-token authorization are separate; signing in to Tracking does not authorize an API request.

  1. Configure Your API Token

    Save the token as BARQ_API_TOKEN in your server’s environment or secret settings. For this quickstart, use Bash and enter it at a hidden prompt:

    Bash · Local Configuration
    read -r -s -p "Barq API token: " BARQ_API_TOKEN
    export BARQ_API_TOKEN
    printf '\n'

    Keep the token out of source control, frontend bundles and request URLs.

  2. Confirm Your Access and Limits

    Read your credential’s permissions and your company’s actual shared quotas. A successful read returns HTTP 200. A read-only token does not grant command or asset-management access.

    cURL · Account Access
    curl --include --get "https://api.barqglobal.com/api/v1/auth/me/" \
      --header "Authorization: Bearer $BARQ_API_TOKEN"

    This response does not include token expiry or your history-access cutoff. Confirm those details with Barq.

  3. Read Your Assigned Devices

    Start with the inventory, follow each next link until it is null, and copy a returned device id. Send your Bearer header only to the Barq API origin. The base path /api/v1/ groups the endpoints; use a complete endpoint for your request.

    cURL · First Read
    curl --include --get "https://api.barqglobal.com/api/v1/devices/" \
      --header "Authorization: Bearer $BARQ_API_TOKEN"

    Look for HTTP 200 and a JSON object containing count, next, previous and results. An empty results array means no devices are available to this credential; contact Barq to check assignments.

  4. Use the Device ID in Your Next Request

    Paste an id from your own inventory when prompted. This is a Barq UUID, not a serial number or vehicle plate.

    Bash + cURL · Device Status
    read -r -p "Device ID from results: " DEVICE_ID
    curl --include --get "https://api.barqglobal.com/api/v1/devices/$DEVICE_ID/status/" \
      --header "Authorization: Bearer $BARQ_API_TOKEN"

    Confirm HTTP 200 and the same device id in the response. Check report timestamps: a successful API response can contain older device telemetry, and null means unavailable or unverified.

  5. Connect Your Application

    Use the Python example below, or copy a language example from the Devices reference. Keep credentials in your backend. Check the HTTP status before processing data, and follow the pagination and polling limits.

Run Your First Python Request

Save this as quickstart.py and run python3 quickstart.py in the same terminal where you exported the token. It uses Python’s standard library.

Python 3 · quickstart.py
import json
import os
from urllib.request import Request, urlopen

request = Request(
    "https://api.barqglobal.com/api/v1/devices/",
    headers={"Authorization": "Bearer " + os.environ["BARQ_API_TOKEN"]},
)
with urlopen(request, timeout=20) as response:
    print("HTTP", response.status)
    data = json.load(response)
print(json.dumps(data, indent=2))

If a Request Fails

  • 401: check for an invalid, revoked or expired token.
  • 403: check credential permissions, account/subscription access and any history boundary.
  • 404: check the endpoint path and use an assigned device ID. Opening /api/v1/ alone returns 404.
  • 429 or 503: pause before retrying reads; respect the response’s Retry-After header when present.

The API hostname serves your company’s live account data. Documentation response examples are illustrative. Device commands require separate permissions and a deliberate action.

Next Steps

Poll positions within your limits, read history and reports, or explore the authentication reference. To try a read in the reference, choose API Authorization, enter only the token, then use Send GET Request on the endpoint. Clear the token or reload the page when finished.

Guide

Poll Positions within Rate Limits

Request the device status or position endpoint with your issued Bearer token. Poll each device at most once every 60 seconds. Keys share the customer budget of 240 reads and 30 report reads per minute. Check recorded_at and received_at to distinguish device time from data receipt.

If a read returns 429 or 503, pause until Retry-After expires. Keep missing readings and unconfirmed position sources as unavailable. Do not turn missing telemetry into a zero or an online status.

  1. List Your Devices

    Each device has a Barq id. Use it in every device read.

    Request
    curl --get "https://api.barqglobal.com/api/v1/devices/" \
      --header "Authorization: Bearer $BARQ_API_TOKEN"
  2. Read the Position at Most Once a Minute

    Compare recorded_at and received_at before showing the position as current.

    Request
    curl --get "https://api.barqglobal.com/api/v1/devices/$DEVICE_ID/position/" \
      --header "Authorization: Bearer $BARQ_API_TOKEN"
  3. Wait for Retry-After

    On HTTP 429 or 503, wait the number of seconds in the Retry-After header before the next read.

Position Endpoint and Examples
Guide

Safe Lock/Unlock with Idempotency Keys

Check the device’s command capabilities and current assignment first. For each deliberate command intent, create a fresh UUID Idempotency-Key and retain the command ID returned by the API.

Acceptance means the request was acknowledged; physical execution remains unverified. Read the saved receipt within the rate limits. Pending commands block further submissions until delivery is resolved. Never automatically resubmit an uncertain command.

  1. Check the Device Capabilities

    Request
    curl --get "https://api.barqglobal.com/api/v1/devices/$DEVICE_ID/command-capabilities/" \
      --header "Authorization: Bearer $BARQ_API_TOKEN"
  2. Submit One Command with a Fresh Key

    Create a new UUID for this intent only. Keep it if you need to check a retry.

    Request
    curl --request POST "https://api.barqglobal.com/api/v1/devices/$DEVICE_ID/commands/" \
      --header "Authorization: Bearer $BARQ_API_TOKEN" \
      --header "Idempotency-Key: $BARQ_IDEMPOTENCY_KEY" \
      --header "Content-Type: application/json" \
      --data '{"kind": "lock", "action": "lock"}'
  3. Read the Command Result

    Use the command ID from the previous response. A saved receipt never establishes physical execution in this release.

    Request
    curl --get "https://api.barqglobal.com/api/v1/devices/$DEVICE_ID/commands/$COMMAND_ID/" \
      --header "Authorization: Bearer $BARQ_API_TOKEN"
Command Workflow And Examples
Guide

Build Trip Replay from 24-Hour History Windows

Build the range in the customer’s IANA timezone, then send ISO 8601 timestamps with offsets. Start is included and end is excluded. Split into windows no longer than 24 hours; daylight-saving days may need an extra window.

Fetch windows sequentially, respecting Retry-After. Combine and sort points by recorded_at, remove exact duplicates and draw coordinates as latitude, longitude. Do not bridge missing positions or imply GPS accuracy when the source is unconfirmed. Actual travelled distance may differ.

  1. Fetch One Window

    Request
    curl --get "https://api.barqglobal.com/api/v1/devices/$DEVICE_ID/history/" \
      --header "Authorization: Bearer $BARQ_API_TOKEN" \
      --data-urlencode "start=2026-10-09T00:00:00+05:00" \
      --data-urlencode "end=2026-10-10T00:00:00+05:00"
  2. Repeat for Each Window

    Move the window forward until the range is covered, one request at a time. Then combine, sort and remove exact duplicates.

  3. Or Download a Date-Range Report as CSV

    Reports accept whole dates (from and to, at most seven days) and an optional IANA timezone.

    Request
    curl --get "https://api.barqglobal.com/api/v1/devices/$DEVICE_ID/reports/history/" \
      --header "Authorization: Bearer $BARQ_API_TOKEN" \
      --data-urlencode "from=2026-10-09" \
      --data-urlencode "to=2026-10-10" \
      --data-urlencode "download=csv" \
      --output trip.csv
History Endpoint and Examples