@lat-lng/sdk
v0.3.1
Published
Official Node/TypeScript SDK for the Lat·Lng geospatial conversion API (lat-lng.com).
Maintainers
Readme
@lat-lng/sdk
Official Node/TypeScript SDK for the Lat·Lng geospatial conversion API.
Install
npm install @lat-lng/sdkUsage
import { LatLngClient } from '@lat-lng/sdk';
import * as fs from 'node:fs';
const client = new LatLngClient(process.env.LATLNG_API_KEY!); // latlng_live_…
const result = await client.convert(
await fs.promises.readFile('input.kml'),
{ to: 'geojson' },
);
const bytes = await result.download();
fs.writeFileSync('output.geojson', bytes);Supported formats: geojson, kml, csv, wkt, gpx, topojson, wkb, shapefile, gml, flatgeobuf, geoparquet.
Errors are typed: AuthError, ValidationError, RateLimitError (auto-retried on 429), QuotaExceededError, ConversionFailedError.
Async (large files via URL)
import { LatLngClient } from '@lat-lng/sdk';
const client = new LatLngClient(process.env.LATLNG_API_KEY!);
const job = await client.convertAsync({ inputUrl: 'https://example.com/big.shp.zip', outputFormat: 'geojson' });
const done = await client.waitForJob(job.jobId);
const bytes = await done.download();Async takes a public URL, not a local upload.
Webhook verification
import { verifyWebhookSignature } from '@lat-lng/sdk';
// In your webhook handler — use the RAW request body string, not a re-serialized object.
const ok = verifyWebhookSignature(rawBody, req.headers['x-webhook-signature'], webhookSecret);Pass the same webhookSecret to convertAsync({ …, webhookUrl, webhookSecret }) to have callbacks signed.
