@terminal49/sdk
v0.1.0
Published
Terminal49 TypeScript SDK (JSON:API, openapi-fetch)
Readme
Terminal49 TypeScript SDK
Typed, server-side client for the Terminal49 JSON:API, built with openapi-fetch, generated OpenAPI types, and JSONA deserialization. Can be used standalone or inside the MCP server.
Installation
# install from npm (recommended)
npm install @terminal49/sdk
# or inside this repo
cd sdks/typescript-sdk
npm installUsage
import { Terminal49Client } from '@terminal49/sdk';
const client = new Terminal49Client({ apiToken: process.env.T49_API_TOKEN! });
const container = await client.getContainer('container-uuid', ['shipment']);
console.log(container); // raw JSON:API document
// Optional: deserialize JSON:API to plain objects
const simplified = client.deserialize<any>(container);Guide
For a full walkthrough (track a container, list shipments, pull events, and routing),
see the SDK quickstart in the docs site: docs/api-docs/getting-started/sdk-quickstart.mdx.
Methods
search(query)getContainer(id, include?)trackContainer({ containerNumber?, bookingNumber?, scac?, refNumbers? })createTrackingRequest({ requestType, requestNumber, scac?, refNumbers?, shipmentTags? })inferTrackingNumber(number)createTrackingRequestFromInfer(number, { scac?, numberType?, refNumbers?, shipmentTags? })getShipment(id, includeContainers?)listShipments(filters?, options?)listContainers(filters?, options?)listTrackingRequests(filters?, options?)/listTrackRequests(filters?, options?)getContainerTransportEvents(id)getContainerRoute(id)listShippingLines(search?)getDemurrage(containerId)(helper)getRailMilestones(containerId)(helper)deserialize<T>(document)→ JSONA-based plain objects
Examples
After building, run:
cd sdks/typescript-sdk
export T49_API_TOKEN=your_token
export T49_CONTAINER_ID=valid_container_uuid
npm run build
npm run exampleexample.ts prints the raw JSON:API response and a simplified view using deserialize.
Development
# Generate types from OpenAPI
npm run generate:types
# Type-check
npm run type-check
# Tests
npm test
# Lint (Biome)
npm run lint
# Build
npm run buildTesting
Unit tests:
cd sdks/typescript-sdk
npm testType checks and lint:
cd sdks/typescript-sdk
npm run type-check
npm run lintSmoke tests (optional, require a token):
cd sdks/typescript-sdk
export T49_API_TOKEN=your_token
export T49_API_BASE_URL=https://api.terminal49.com/v2
export T49_INFER_NUMBER=your_tracking_number
export T49_RUN_SMOKE=1
npm run smokeFixtures
Generate sanitized, production-based fixtures for tests:
cd sdks/typescript-sdk
export T49_API_TOKEN=your_token
export T49_API_BASE_URL=https://api.terminal49.com/v2
npm run fixtures:generateThis writes JSON:API fixtures to src/fixtures/ with redacted IDs and numbers.
Numeric identifiers keep their original prefix while the last few characters are
obfuscated to preserve shape without exposing real values.
List endpoints are captured without include for performance guidance. Single-resource
fixtures include both base and include variants where supported.
Publishing (prep)
- Add a
prepublishOnlyorpreparescript to runnpm run buildsodist/is fresh. - Ensure
files/exportsonly ship built JS/typings (currentlymain/types/exportspoint todist/).
Notes
- Server-only: uses Node fetch (undici types) and targets Node 18+.
- Returns raw JSON:API documents by default; use
deserializefor flattened objects or add your own mappers.
