Skip to main content

Quickstart

Go from an API token to a confirmed hardware operation: list your products, send open, and see the result arrive over the realtime connection.

Prerequisites​

  • A product and a Gateway on the same lot, paired with your account, and an API subscription for the product. See What you need.
  • Your account's Super Admin email and password.
  • For the code: Node.js 24+ with socket.io-client (the Node examples are TypeScript, which Node 24 runs directly: node open.ts), or Python 3 with httpx and python-socketio.

1. Create an API token (once)​

Log in as the Super Admin with POST /v2/auth/login, then create a token with POST /v2/api-tokens. Do this by hand, once: logging in signs that user out of the Connect app.

Create an API token
USER_TOKEN=$(curl -s -X POST https://api.parklio.com/v2/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "admin@example.com", "password": "<your-password>"}' | jq -r .data.token)

curl -s -X POST https://api.parklio.com/v2/api-tokens \
-H "Authorization: Bearer $USER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "quickstart"}' | jq -r .data.token

These commands use jq to pick fields out of the JSON. The last one prints your API token. It's shown only once: store it, and export it for the next steps.

Environment
export PARKLIO_API_TOKEN="<your-api-token>"

More in Authentication.

2. List your products​

List products
curl -s https://api.parklio.com/v2/products \
-H "Authorization: Bearer $PARKLIO_API_TOKEN"
Response (shortened)
{
"success": true,
"data": [
{
"id": 123,
"device_id": "B1A2B3C",
"name": "Spot 12",
"lot_id": 4,
"zone_id": 9,
"product_type_id": 2,
"status": "online",
"power_type": "battery",
"battery_status": 87,
"rssi": -71,
"barrier": {
"state": "closed",
"is_autoclose": 1,
"is_car_on_top": 0,
"autoclose_time": 30
},
"product_error": null
}
],
"meta": { "total": 1, "per_page": 10, "current_page": 1, "last_page": 1 }
}

Pick a product and check two things:

  • status is online. A Gateway can see it, so a command can reach it.
  • The type block. Each product has exactly one: barrier, gate, chain, bollard or brain, with its current state. See Products and operations.
Environment
export PRODUCT_ID=123

3. Connect, send open, and wait for the result​

Results arrive only over the realtime connection, so connect first, then send the command, then wait for the event carrying your event_id.

On a barrier, open lowers the arm so the spot can be used. On a gate, chain, bollard or brain, open opens the passage.

curl can't hold the realtime connection, so this sends the command only. Use the Node or Python version to see the result.

Send open
curl -s -X POST "https://api.parklio.com/v2/products/$PRODUCT_ID/state" \
-H "Authorization: Bearer $PARKLIO_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"operation": "open"}'
Response
{ "success": true, "data": { "event_id": "a1b2c3d4" } }

Verify it worked​

  • The script prints the event_id from the response, then Done once a lot_change with the same event_id arrives.
  • The type block in that event shows the new state, for example "state": "opened".
  • On site, the product has moved: a barrier's arm is down, a gate is open.

Common errors​

CodeWhereMeaningFix
1HTTP 401The token is missing, invalid or revoked.Check the Authorization: Bearer <token> header.
30HTTP 403The product has no API subscription that includes remote control.Subscribe it; see What you need.
214HTTP 403An earlier operation on this product hasn't finished.Wait for its result, then try again.
704HTTP 403No Gateway has seen the product recently.Check the Gateway is online, on the same lot and in range.
gateway_errorrealtimeThe command reached the Gateway but failed, for example the arm is jammed or a car is on top. type: "Timeout" means no Gateway answered.See the type table in Events.

Nothing arrives at all? Make sure you connected before sending the command, with the same API token. See Troubleshooting.

Next​