ImportOS · Docs

TypeScript SDK

@importos/sdk: a typed Data API client on openapi-fetch, ImportOsApiError errors, retries after 429.

@importos/sdk is a thin typed client for the REST API. Types are generated from openapi.json (openapi-typescript), and calls are made by openapi-fetch (about 6 KB).

In the monorepo only for now

The package is private: it is not in the npm registry. Publishing it (and choosing the name and registry) is up to the owner Waiting on the owner. Inside the RVAuto2 monorepo it is added as "@importos/sdk": "workspace:*". Until it is published, external projects should use REST directly or generate types themselves from /openapi.json.

Creating a client

import { createImportOsClient, ImportOsApiError } from '@importos/sdk';

const api = createImportOsClient({
  apiKey: process.env.IMPORTOS_API_KEY!, // server only, never in the browser of a public site
  baseUrl: 'https://api.importos.app',
  maxRetries: 2, // retry after 429 if Retry-After is not above maxRetryDelaySec
  maxRetryDelaySec: 30,
});
OptionValue
apiKeythe rv_live_… key
baseUrlthe API address without a trailing /
fetcha custom fetch implementation (tests, proxies)
maxRetrieshow many times to retry after 429 (default 0: do not retry)
maxRetryDelaySecthe longest Retry-After the client is willing to wait (default 30)

Methods

MethodEndpoint
api.landedCost(body)POST /v1/landed-cost
api.marketPrice(query)GET /v1/market-price
api.decodeVin(vin)GET /v1/vin/{vin}
api.searchListings(query)GET /v1/listings/search
api.customsRules(country, date?)GET /v1/rules/{country}
api.fxRate(query)GET /v1/fx
api.clientthe low-level openapi-fetch client, all paths typed

The types LandedCostRequest, LandedCostResponse, MarketPriceResponse, VinResponse, SearchListingsResponse, RulesResponse, FxResponse and Problem are also exported.

const cost = await api.landedCost({
  lot_price: 8000,
  auction: 'copart',
  vehicle: { vin: '4T1B11HK5JU000001', year: 2018, fuel: 'petrol', engine_cc: 2487, damage: 'FRONT END' },
  from: { auction_yard: 'NJ - TRENTON' },
  to: { country: 'UA', city: 'Київ' },
  fee_model: { model: 'fixed', amount: 700, currency: 'USD' },
  date: '2026-10-17',
});
console.log(cost.total, cost.warnings);

Errors

Any non-2xx response throws ImportOsApiError:

try {
  await api.marketPrice({ make: 'Toyota', model: 'Camry', year: 2018, market: 'ua' });
} catch (e) {
  if (e instanceof ImportOsApiError) {
    console.error(e.status, e.code, e.requestId); // 429 'rate_limited' '...'
    if (e.retryAfterSec) await new Promise((r) => setTimeout(r, e.retryAfterSec! * 1000));
  } else {
    throw e;
  }
}
FieldDescription
statusthe HTTP status
codethe stable code from problem+json, see the code table
problemthe whole problem+json body
requestIdrequest_id or the X-Request-Id header
retryAfterSecset for 429

Regenerating the types

The types live in packages/sdk/src/generated/schema.d.ts and are committed together with openapi.json. After the API changes:

pnpm --filter @importos/sdk generate

Tests fail if the spec or the types are stale.

On this page