Skip to content

Repository files navigation

@transcend/sdk

Official JavaScript/TypeScript SDK for the TRANSCEND API — route planning, weather, traffic, tolls, fuel stations, POI, vehicles, drivers, and billing.

Installation

npm install @transcend/sdk
# or
yarn add @transcend/sdk
# or
pnpm add @transcend/sdk

Node.js >= 18 is required (native fetch). For older versions, pass a fetch polyfill.

Quick Start

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);

Authentication

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.

Error Handling

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);
  }
}

API Reference

Route

Calculate routes between locations.

client.route.calculate(params)

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"

Weather

Current conditions, forecasts, alerts, and route weather.

client.weather.current({ lat, lon })

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"

client.weather.forecast({ lat, lon })

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"

client.weather.alertsCurrent({ lat, lon })

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"

client.weather.alertsRange({ lat, lon, start, end })

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"

client.weather.route({ polyline, datetime })

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

Traffic incidents, speed cameras, and blackspots.

client.traffic.nearby({ lat, lon, radius? })

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"

client.traffic.getAlongPath({ polyline })

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"}'

client.traffic.radarNearby({ lat, lon, radius? })

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"

client.traffic.blackspotNearby({ lat, lon })

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"

Tolls

Toll cost calculation, operators, and highway listings.

client.tolls.calculate({ origin, destination, vehicle_category? })

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"}'

client.tolls.operators()

const operators = await client.tolls.operators();

curl:

curl "https://back.transcend.cargoffer.com/api/v1/tolls/operators" \
  -H "Authorization: Bearer YOUR_API_KEY"

client.tolls.highways()

const highways = await client.tolls.highways();

curl:

curl "https://back.transcend.cargoffer.com/api/v1/tolls/highways" \
  -H "Authorization: Bearer YOUR_API_KEY"

Stations

Fuel station search, pricing, and along-route lookups.

client.stations.nearby({ lat, lon, radius?, fuel_type? })

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"

client.stations.bestPrices({ fuel_type })

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"

client.stations.province({ province })

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"

client.stations.getAlongPath({ polyline, radius? })

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}'

POI

Points of interest search and parking locations.

client.poi.searchNearby({ lat, lon, type?, radius? })

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"

client.poi.searchCity({ city, type? })

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"

client.poi.parkingLocation({ lat, lon })

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"

Vehicles

Vehicle brands, models, specifications, and search.

client.vehicles.brands()

const brands = await client.vehicles.brands();

curl:

curl "https://back.transcend.cargoffer.com/api/v1/vehicles/brands" \
  -H "Authorization: Bearer YOUR_API_KEY"

client.vehicles.models(brandId)

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"

client.vehicles.specs(id)

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"

client.vehicles.types()

const types = await client.vehicles.types();

curl:

curl "https://back.transcend.cargoffer.com/api/v1/vehicles/types" \
  -H "Authorization: Bearer YOUR_API_KEY"

client.vehicles.search({ q })

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"

Drivers

Driver management, tracking, limits, and compliance.

client.drivers.list()

const drivers = await client.drivers.list();

curl:

curl "https://back.transcend.cargoffer.com/api/v1/drivers/" \
  -H "Authorization: Bearer YOUR_API_KEY"

client.drivers.position(id)

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"

client.drivers.dailyLimits(id)

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"

client.drivers.compliance(id)

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"

Pay

Pricing plans and checkout sessions.

client.pay.pricingPlans()

const plans = await client.pay.pricingPlans();

curl:

curl "https://back.transcend.cargoffer.com/api/v1/pay/pricing-plans" \
  -H "Authorization: Bearer YOUR_API_KEY"

client.pay.createCheckoutSession({ plan_id, billing_mode })

const session = await client.pay.createCheckoutSession({
  plan_id: 'plan-123',
  billing_mode: 'monthly',
});
// Redirect user to session.data.url

curl:

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"}'

Using with Node.js < 18

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,
});

TypeScript Support

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';

License

MIT

About

Transcend API SDK for JavaScript/TypeScript

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages