---
title: "Wialon TypeScript SDK: Typed Remote API Client | Asset Track"
url: https://theassettrack.com/wialon-api/sdk/
description: "Open-source TypeScript client for the Wialon Remote API: token login, units, trips, drivers, reports and typed errors, for Node and the browser."
---

# Wialon TypeScript SDK: Typed Remote API Client

Reference · last checked November 30, 2026

Open-source TypeScript client for the Wialon Remote API: token login, units, trips, drivers, reports and typed errors, for Node and the browser.

Every Wialon integration begins by writing the same layer: a function that form-encodes svc and params, posts them to ajax.html, attaches the session, and turns `{"error":7}` into something a log line can explain. Written against the documentation alone, that layer takes days to get right, because the rules it has to respect are spread across two documentation sites that no longer agree. `wialon-sdk` is that layer extracted from production code and published under the MIT licence, so an integration can start at the data rather than at the transport.

[Source on GitHub](https://github.com/assettrackhq/wialon-sdk) · [Package on npm](https://www.npmjs.com/package/wialon-sdk)

## Install it and make the first call

The package has no runtime dependencies and needs only a global fetch, so it runs in Node 18 and later, Bun, Deno, Cloudflare Workers and the browser. It ships both ESM and CommonJS builds with type declarations.

`npm install wialon-sdk``import { WialonSdk } from "wialon-sdk"; const sdk = new WialonSdk ({ host: "https://hst-api.wialon.com" }); const session = await sdk.auth. loginWithToken ({ token: process.env. WIALON_TOKEN! }); const units = await sdk.units. list ({ flags: 0x401 }); const trips = await sdk.trips. load ({ unitId: units.items[ 0 ].id, timeFrom: 1711929600, timeTo: 1712016000, }); await sdk.auth. logout ();`

The token in that snippet is the 72-character credential described on the [token and login page](https://theassettrack.com/wialon-api/token/), and the flag it was created with decides what the session can read. A token minted with the authorization form’s default access_type of 0x100 logs in successfully and then fails every data read with error 7, which is the most common reason a first run of any client, this one included, returns nothing useful. Ask for 768 when creating a read-only token.

## Let the SDK handle the wire format

The Remote API accepts only POST requests with a form-encoded body, and its JSON parser does not accept hexadecimal values. The SDK builds the body itself and passes flags as numbers, so `0x401` written in TypeScript reaches the server as 1025 and the hex-versus-decimal mistake cannot happen. The [Postman page](https://theassettrack.com/wialon-api/postman/) shows the same request format by hand, which is still the quickest way to check a credential before writing code.

Sessions are tracked on the client instance. A successful login stores the session id, the separate GIS session id that reverse geocoding requires, and the user id; every later call sends them without the caller passing anything. Three ways in are supported: `loginWithToken` for token/login, `loginWithAuthHash` for core/use_auth_hash when a parent application hands over an auth hash, and `useSession` for adopting a session id obtained elsewhere. `loginWithCredentials` remains for legacy and self-hosted installations, since core/login stopped being the supported scheme in October 2015.

## Know which services are covered

| Service | Covers | Wialon commands |
| --- | --- | --- |
| `auth` | Sessions | token/login, core/use_auth_hash, core/login, core/logout |
| `core` | Raw calls and batching | core/search_items, core/search_item, core/batch |
| `units` | Unit search and lookup | core/search_items, core/search_item |
| `trips` | Trips and trip updates | events/load, unit/update_event_data |
| `events` | Detector events | events/load |
| `drivers` | Drivers and bindings | resource/get_unit_drivers, resource/get_driver_bindings, resource/bind_unit_driver |
| `geofences` | Resources, zones, geocoding | core/search_items, gis_geocode |
| `properties` | Custom item properties | item/update_custom_property |
| `maintenance` | Service intervals | unit/update_service_interval, unit/registry_maintenance_event |
| `files` | File storage, tachograph files | file/list, file/mkdir, file/rm |
| `reports` | Report execution and paging | report/exec_report, report/get_result_rows, report/cleanup_result |
| `messages` | Raw message history | messages/load_interval, messages/load_last, messages/unload |

Anything without a typed wrapper goes through `sdk.core`, which sends an arbitrary svc with the current session attached. The [units page](https://theassettrack.com/wialon-api/units/) explains the data flags passed to units.list, and the [reports page](https://theassettrack.com/wialon-api/reports/) explains why report/cleanup_result has to run before each execution — a rule the reports service follows for you.

## Keep concurrency inside the session’s ceiling

A session allows ten simultaneous requests, of which three may be heavy, and message loading and report execution both count as heavy. A dashboard that renders several widgets at once tends to request the same unit search more than once, and each duplicate uses up part of that allowance. The SDK de-duplicates identical reads that are already in flight, so concurrent callers share one response; writes are never merged, because a second identical mutation is a second mutation. Each request can opt in or out with a `dedupe` option.

De-duplication does not raise the ceiling, and nothing on the client can. Workers that share one session share its three heavy slots, so bulk extraction should give each worker its own SDK instance and its own session, as the [errors page](https://theassettrack.com/wialon-api/errors/) argues in more detail.

## Classify errors before retrying them

Every failure is thrown as a `WialonSdkError` carrying the Wialon code, the svc that produced it and the HTTP status, which is enough to dispatch on:

`import { WialonSdkError } from "wialon-sdk"; try { await sdk.units. list ({ flags: 0x1 }); } catch (error) { if (error instanceof WialonSdkError && error.code === 1) { await sdk.auth. loginWithToken ({ token }); // invalid session: one re-login, then replay } throw error; }`

The SDK deliberately does not retry on its own, because the right response depends on the code. Error 1 needs exactly one re-login; error 7 and error 8 are terminal and retrying them walks into the login ceiling that blocks the whole IP address; error 10 needs less concurrency, not more attempts. The [errors page](https://theassettrack.com/wialon-api/errors/) has the full code table and a retry classification that can be mapped directly onto `error.code`.

## Route calls through your own backend

A browser application should not hold a Wialon token. Setting `apiUrl` sends every authenticated call to your own endpoint instead of the Wialon host, where a server can keep the token, add logging and enforce its own limits before forwarding to ajax.html. The `gisHost` and `geocodeUrl` options do the same for reverse geocoding, and a custom `fetch` can add tracing or retries without touching the SDK.

`const sdk = new WialonSdk ({ apiUrl: "https://your-backend.example.com/api/wialon", timeoutMs: 30_000, });`

For Wialon Local or an account on a regional data centre, set `host` to that installation. The session returned by login carries the account’s own API host from base_url, which is worth storing alongside the token.

The SDK is open source under the MIT licence and is not affiliated with Gurtam. Issues, pull requests and requests for commands that still lack a typed wrapper go to the [GitHub issue tracker](https://github.com/assettrackhq/wialon-sdk/issues).

Work with us

Rather not build this integration yourself?

We connect Wialon to ERP, TMS, CMMS and BI: a fixed quote after a free 30-minute call, from $500, with the source code and a runbook at handover.

What a build includes: [Wialon integration →](https://theassettrack.com/wialon-integration/)

[Book a free call](https://cal.com/sergey.govorunov/call) or send us a message

## Also in this reference

- ### Wialon MCP: Ask Claude About Your Wialon Fleet
 Connect Claude, ChatGPT, Cursor or Codex to Wialon over MCP: the hosted server, read-only sign-in, the agent skill, and when to build an API integration.
 [Wialon MCP: Ask Claude About Your Wialon Fleet](https://theassettrack.com/wialon-api/mcp/)
- ### Wialon API Token and Login: Sessions That Survive
 Wialon authorization end to end: the login form, token/login, token/update, the access-flag table, and the 100-day inaction rule that deletes idle tokens.
 [Wialon API Token and Login: Sessions That Survive](https://theassettrack.com/wialon-api/token/)
- ### Wialon API Errors: Codes 1, 4, 6, 7 and 1004
 The full Wialon Remote API error table, the 1003 reason variants, the quotas that produce each code, and how to classify them for retry logic.
 [Wialon API Errors: Codes 1, 4, 6, 7 and 1004](https://theassettrack.com/wialon-api/errors/)
- ### Wialon API in Postman: Authenticate in 10 Minutes
 The Wialon request format, the two headers and encodings that break every first call, and a Postman setup for an authenticated session.
 [Wialon API in Postman: Authenticate in 10 Minutes](https://theassettrack.com/wialon-api/postman/)
- ### Wialon API: Get a Unit's Last Position and Message
 Data flags, core/search_items, and the difference between last position and last message — the distinction behind the most-asked question on the SDK board.
 [Wialon API: Get a Unit's Last Position and Message](https://theassettrack.com/wialon-api/units/)
- ### Wialon Messages API: load_interval, Flags and Paging
 How the Wialon messages API works: messages/load_interval, flags and flagsMask, paging with get_messages, message parameters, and the limits that bite.
 [Wialon Messages API: load_interval, Flags and Paging](https://theassettrack.com/wialon-api/messages/)
- ### Wialon Drivers API: Bind Drivers to Units
 Create drivers, bind them to units, read binding history over the Wialon Remote API — including the avl_driver auto-binding sensor.
 [Wialon Drivers API: Bind Drivers to Units](https://theassettrack.com/wialon-api/drivers/)
- ### Wialon API Reports: exec_report Without the Errors
 One report per session, the cleanup_result rule, the calls that cannot run alongside it, and the time limit that returns no rows instead of an error.
 [Wialon API Reports: exec_report Without the Errors](https://theassettrack.com/wialon-api/reports/)
- ### Wialon Geofence API: Create, Edit and Query Zones
 How the Wialon geofence API works: resource/update_zone for create, edit and delete, reading zones back, point lookups, groups and the entry/exit trigger.
 [Wialon Geofence API: Create, Edit and Query Zones](https://theassettrack.com/wialon-api/geofences/)
- ### Wialon API Notifications: Create, Edit, Enable
 resource/update_notification end to end — call modes, the trigger and action pair, schedules, and the response fields that make notifications diffable.
 [Wialon API Notifications: Create, Edit, Enable](https://theassettrack.com/wialon-api/notifications/)
- ### Wialon Retranslator: Protocols and Configuration
 The nine retranslation protocols Wialon can forward to, the update_config parameters each one uses, and where retranslation fits against an API pull.
 [Wialon Retranslator: Protocols and Configuration](https://theassettrack.com/wialon-api/retranslator/)
- ### Wialon IPS Protocol (v1.1 and v2.0): Packets and CRC16
 The Wialon IPS device protocol from the Gurtam spec: v1.1 vs v2.0 packets, login, data and black box fields, CRC16, response codes and a worked exchange.
 [Wialon IPS Protocol (v1.1 and v2.0): Packets and CRC16](https://theassettrack.com/wialon-api/ips/)
