TypeScript
Use @open-geocode/client for native OpenGeocode GeoJSON from Node.js, Bun, Deno, or the browser. If your app already reads a Google, Mapbox, HERE or Precisely response, see Compatibility for the matching import and migration steps.
Serve the example Pack
Section titled “Serve the example Pack”The native example uses Monaco. Use the USA Pack for the requests in the vendor guides.
From an OpenGeocode checkout, build the CLI, then build and serve Monaco. See Serve the API for options.
cargo build --locked --release --features tui --bin og
./target/release/og build --region monaco
./target/release/og serve monaco --bind 127.0.0.1:8080Install the client
Section titled “Install the client”Build the client from the SDK source using Bun.
git clone https://github.com/open-geocode-rs/og-sdk-js.git
cd og-sdk-js
bun install --frozen-lockfile
bun run --filter '@open-geocode/client' build
npm pack ./packages/clientIn your app, pass the path to the tarball printed by npm pack to npm install.
Geocode an address
Section titled “Geocode an address”This native request asks for one address-level result.
import { createClient } from "@open-geocode/client";
const client = createClient({ baseUrl: "http://127.0.0.1:8080" });
const { features } = await client.geocode({
q: "2 Avenue de Monte-Carlo, Monaco",
layer: "address",
limit: 1,
});
const match = features[0];
if (match) {
const [longitude, latitude] = match.geometry.coordinates;
console.log({ longitude, latitude, ...match.properties });
}Response
Section titled “Response”The excerpt shows the fields used above from the Monaco Pack. GeoJSON coordinates are longitude first.
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [7.4270688, 43.7377547] },
"properties": {
"label": "2 Avenue de Monte-Carlo, Monaco, 98000, MC",
"accuracy": "rooftop"
}
}
]
}When there is no match, the API returns HTTP 200 with features: []. Use accuracy to decide whether to place a pin.
Handle errors
Section titled “Handle errors”Every client throws a GeocoderError on failure. Use its code for application logic and requestId for troubleshooting. The error’s body holds the original response. With the native client, problem also exposes the OpenGeocode problem document.
See the geocoding reference for the full response schema.

