Official JavaScript/TypeScript SDK for the TRANSCEND API — route planning, weather, traffic, tolls, fuel stations, POI, vehicles, drivers, and billing.
npm install @transcend/sdk
# or
yarn add @transcend/sdk
# or
pnpm add @transcend/sdkNode.js >= 18 is required (native
fetch). For older versions, pass afetchpolyfill.
import { TranscendClient } from '@transcend/sdk';
const client = new TranscendClient({
apiKey: 'your-api-key-here',
// baseUrl is optional, defaults to:
// https://back.transcend.cargoffer.com/api/v1
});
// Calculate a route
const route = await client.route.calculate({
origin_lat: 40.4168,
origin_lon: -3.7038,
destiny_lat: 41.3851,
destiny_lon: 2.1734,
});
console.log(route.data?.duration, route.data?.distance);All requests are authenticated via a Bearer token in the Authorization header:
Authorization: Bearer <your-api-key>
Pass your API key to the TranscendClient constructor.
The SDK throws TranscendApiError for non-2xx responses:
import { TranscendApiError } from '@transcend/sdk';
try {
const result = await client.weather.current({ lat: 0, lon: 0 });
} catch (err) {
if (err instanceof TranscendApiError) {
console.error(`HTTP ${err.statusCode}: ${err.message}`);
console.error('Body:', err.body);
}
}Calculate routes between locations.
| Parameter | Type | Required | Description |
|---|---|---|---|
origin_lat |
number | Yes | Origin latitude |
origin_lon |
number | Yes | Origin longitude |
destiny_lat |
number | Yes | Destination latitude |
destiny_lon |
number | Yes | Destination longitude |
waypoints |
string | No | Waypoints as "lat,lon;lat,lon" |
vehicle_type |
string | No | Vehicle type |
avoid_tolls |
boolean | No | Whether to avoid toll roads |
date |
string | No | Route date (ISO format) |
const route = await client.route.calculate({
origin_lat: 40.4168,
origin_lon: -3.7038,
destiny_lat: 41.3851,
destiny_lon: 2.1734,
vehicle_type: 'truck',
avoid_tolls: true,
});curl equivalent:
curl -G "https://back.transcend.cargoffer.com/api/v1/route/" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "origin_lat=40.4168" \
--data-urlencode "origin_lon=-3.7038" \
--data-urlencode "destiny_lat=41.3851" \
--data-urlencode "destiny_lon=2.1734" \
--data-urlencode "avoid_tolls=true"Current conditions, forecasts, alerts, and route weather.
const weather = await client.weather.current({ lat: 40.4168, lon: -3.7038 });curl:
curl -G "https://back.transcend.cargoffer.com/api/v1/weather/current" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "lat=40.4168" --data-urlencode "lon=-3.7038"const forecast = await client.weather.forecast({ lat: 40.4168, lon: -3.7038 });curl:
curl -G "https://back.transcend.cargoffer.com/api/v1/weather/forecast" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "lat=40.4168" --data-urlencode "lon=-3.7038"const alerts = await client.weather.alertsCurrent({ lat: 40.4168, lon: -3.7038 });curl:
curl -G "https://back.transcend.cargoffer.com/api/v1/weather/alerts/current" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "lat=40.4168" --data-urlencode "lon=-3.7038"const alerts = await client.weather.alertsRange({
lat: 40.4168,
lon: -3.7038,
start: '2025-01-01T00:00:00Z',
end: '2025-01-07T00:00:00Z',
});curl:
curl -G "https://back.transcend.cargoffer.com/api/v1/weather/alerts/range" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "lat=40.4168" --data-urlencode "lon=-3.7038" \
--data-urlencode "start=2025-01-01T00:00:00Z" \
--data-urlencode "end=2025-01-07T00:00:00Z"const weatherAlongRoute = await client.weather.route({
polyline: 'encoded_polyline_string',
datetime: '2025-06-15T10:00:00Z',
});curl:
curl -X POST "https://back.transcend.cargoffer.com/api/v1/weather/route" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"polyline":"encoded_polyline_string","datetime":"2025-06-15T10:00:00Z"}'Traffic incidents, speed cameras, and blackspots.
const incidents = await client.traffic.nearby({ lat: 40.4168, lon: -3.7038, radius: 5000 });curl:
curl -G "https://back.transcend.cargoffer.com/api/v1/traffic/nearby" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "lat=40.4168" --data-urlencode "lon=-3.7038" \
--data-urlencode "radius=5000"const incidents = await client.traffic.getAlongPath({ polyline: 'encoded_polyline' });curl:
curl -X POST "https://back.transcend.cargoffer.com/api/v1/traffic/getAlongPath" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"polyline":"encoded_polyline"}'const radars = await client.traffic.radarNearby({ lat: 40.4168, lon: -3.7038, radius: 3000 });curl:
curl -G "https://back.transcend.cargoffer.com/api/v1/traffic/radar/nearby" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "lat=40.4168" --data-urlencode "lon=-3.7038" \
--data-urlencode "radius=3000"const blackspots = await client.traffic.blackspotNearby({ lat: 40.4168, lon: -3.7038 });curl:
curl -G "https://back.transcend.cargoffer.com/api/v1/traffic/blackspot/nearby" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "lat=40.4168" --data-urlencode "lon=-3.7038"Toll cost calculation, operators, and highway listings.
const tolls = await client.tolls.calculate({
origin: { lat: 40.4168, lon: -3.7038 },
destination: { lat: 41.3851, lon: 2.1734 },
vehicle_category: 'truck',
});curl:
curl -X POST "https://back.transcend.cargoffer.com/api/v1/tolls/calculate" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"origin":{"lat":40.4168,"lon":-3.7038},"destination":{"lat":41.3851,"lon":2.1734},"vehicle_category":"truck"}'const operators = await client.tolls.operators();curl:
curl "https://back.transcend.cargoffer.com/api/v1/tolls/operators" \
-H "Authorization: Bearer YOUR_API_KEY"const highways = await client.tolls.highways();curl:
curl "https://back.transcend.cargoffer.com/api/v1/tolls/highways" \
-H "Authorization: Bearer YOUR_API_KEY"Fuel station search, pricing, and along-route lookups.
const stations = await client.stations.nearby({
lat: 40.4168,
lon: -3.7038,
radius: 5000,
fuel_type: 'diesel',
});curl:
curl -G "https://back.transcend.cargoffer.com/api/v1/stations/nearby" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "lat=40.4168" --data-urlencode "lon=-3.7038" \
--data-urlencode "radius=5000" --data-urlencode "fuel_type=diesel"const prices = await client.stations.bestPrices({ fuel_type: 'diesel' });curl:
curl -G "https://back.transcend.cargoffer.com/api/v1/stations/best-prices" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "fuel_type=diesel"const stations = await client.stations.province({ province: 'Madrid' });curl:
curl -G "https://back.transcend.cargoffer.com/api/v1/stations/province" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "province=Madrid"const stations = await client.stations.getAlongPath({
polyline: 'encoded_polyline',
radius: 2000,
});curl:
curl -X POST "https://back.transcend.cargoffer.com/api/v1/stations/getAlongPath" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"polyline":"encoded_polyline","radius":2000}'Points of interest search and parking locations.
const pois = await client.poi.searchNearby({
lat: 40.4168,
lon: -3.7038,
type: 'restaurant',
radius: 3000,
});curl:
curl -G "https://back.transcend.cargoffer.com/api/v1/poi/search/nearby" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "lat=40.4168" --data-urlencode "lon=-3.7038" \
--data-urlencode "type=restaurant" --data-urlencode "radius=3000"const pois = await client.poi.searchCity({ city: 'Madrid', type: 'hotel' });curl:
curl -G "https://back.transcend.cargoffer.com/api/v1/poi/search/city" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "city=Madrid" --data-urlencode "type=hotel"const parking = await client.poi.parkingLocation({ lat: 40.4168, lon: -3.7038 });curl:
curl -G "https://back.transcend.cargoffer.com/api/v1/poi/parking/location" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "lat=40.4168" --data-urlencode "lon=-3.7038"Vehicle brands, models, specifications, and search.
const brands = await client.vehicles.brands();curl:
curl "https://back.transcend.cargoffer.com/api/v1/vehicles/brands" \
-H "Authorization: Bearer YOUR_API_KEY"const models = await client.vehicles.models('brand-123');curl:
curl "https://back.transcend.cargoffer.com/api/v1/vehicles/models/brand-123" \
-H "Authorization: Bearer YOUR_API_KEY"const specs = await client.vehicles.specs('model-456');curl:
curl "https://back.transcend.cargoffer.com/api/v1/vehicles/models/model-456/specs" \
-H "Authorization: Bearer YOUR_API_KEY"const types = await client.vehicles.types();curl:
curl "https://back.transcend.cargoffer.com/api/v1/vehicles/types" \
-H "Authorization: Bearer YOUR_API_KEY"const results = await client.vehicles.search({ q: 'Volvo FH' });curl:
curl -G "https://back.transcend.cargoffer.com/api/v1/vehicles/search" \
-H "Authorization: Bearer YOUR_API_KEY" \
--data-urlencode "q=Volvo FH"Driver management, tracking, limits, and compliance.
const drivers = await client.drivers.list();curl:
curl "https://back.transcend.cargoffer.com/api/v1/drivers/" \
-H "Authorization: Bearer YOUR_API_KEY"const position = await client.drivers.position('driver-123');curl:
curl "https://back.transcend.cargoffer.com/api/v1/drivers/driver-123/position" \
-H "Authorization: Bearer YOUR_API_KEY"const limits = await client.drivers.dailyLimits('driver-123');curl:
curl "https://back.transcend.cargoffer.com/api/v1/drivers/driver-123/daily-limits" \
-H "Authorization: Bearer YOUR_API_KEY"const compliance = await client.drivers.compliance('driver-123');curl:
curl "https://back.transcend.cargoffer.com/api/v1/drivers/driver-123/compliance" \
-H "Authorization: Bearer YOUR_API_KEY"Pricing plans and checkout sessions.
const plans = await client.pay.pricingPlans();curl:
curl "https://back.transcend.cargoffer.com/api/v1/pay/pricing-plans" \
-H "Authorization: Bearer YOUR_API_KEY"const session = await client.pay.createCheckoutSession({
plan_id: 'plan-123',
billing_mode: 'monthly',
});
// Redirect user to session.data.urlcurl:
curl -X POST "https://back.transcend.cargoffer.com/api/v1/pay/create-checkout-session" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"plan_id":"plan-123","billing_mode":"monthly"}'For environments without native fetch, pass a polyfill:
import fetch from 'node-fetch';
import { TranscendClient } from '@transcend/sdk';
const client = new TranscendClient({
apiKey: 'your-api-key',
fetch: fetch as unknown as typeof globalThis.fetch,
});This SDK is written in TypeScript and ships with full type definitions. All request parameters and response objects are fully typed.
import type {
RouteCalculateResponse,
WeatherCurrentResponse,
TrafficNearbyResponse,
TollsCalculateResponse,
StationsNearbyResponse,
PoiSearchNearbyResponse,
VehiclesBrandsResponse,
DriversListResponse,
} from '@transcend/sdk';MIT