npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gogoduk/sdk

v0.3.0

Published

Official TypeScript SDK for the GoGoDuk Map API — geocoding, reverse geocoding, autocomplete, and admin boundaries for Vietnam and SEA.

Readme

@gogoduk/sdk

Official TypeScript SDK for the GoGoDuk Map API — geocoding, reverse geocoding, autocomplete, and admin boundaries for Vietnam and Southeast Asia.

npm license

Free forever. 100 requests/day per account, no credit card. Need more? Email us and we'll raise your limit.

Install

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

Requires Node 18+ (global fetch). Works in browsers, Bun, Deno, and edge runtimes.

Quick start

import { GoGoDukClient } from "@gogoduk/sdk";

const client = new GoGoDukClient({ apiKey: process.env.GOGODUK_API_KEY! });

// 1. Autocomplete
const { predictions } = await client.suggest({ input: "Hà Nội" });

// 2. Resolve a place
const { result } = await client.placeResolve({ id: predictions[0].placeId });
console.log(result.address, result.lat, result.lon);

// 3. Reverse geocode (proximity)
const { results } = await client.reverse({ lat: 21.03, lon: 105.85 });

// 4. Reverse geocode (admin boundary)
const { city, district } = await client.reverseGeocode({ lat: 21.03, lng: 105.85 });

// 5. Admin boundary polygons (provinces + districts)
const boundaries = await client.adminBoundaries({ levels: [4, 8] });

Get your API key at app.gogoduk.com.

API

new GoGoDukClient(options)

| Option | Type | Default | Description | |---|---|---|---| | apiKey | string | — | Required. Your API key. Sent as X-API-Key. | | baseUrl | string | "https://api.gogoduk.com" | Override for self-hosted or staging. | | timeoutMs | number | 10000 | Per-request timeout. 0 disables. | | fetch | typeof fetch | global fetch | Inject a polyfill or mock. | | defaultHeaders | Record<string, string> | {} | Extra headers merged into every request. |

client.suggest(params)

Autocomplete predictions. Input must be ≥ 2 characters.

const { predictions } = await client.suggest({
  input: "Hào Nam",
  lang: "vi",           // default "vi"
  country: "VN",        // ISO-3166-1
  sessionToken: "uuid", // reuse on placeResolve to close the billing session
  focusLat: 21.03,      // bias point
  focusLon: 105.85,
});

client.reverse(params)

Proximity-based reverse geocode — returns the nearest known address.

const { results } = await client.reverse({
  lat: 21.03,
  lon: 105.85,
  size: 1,        // max 5
  radiusKm: 0.05, // capped at 0.1
  lang: "vi",
  country: "VN",  // comma-separated ISO-2 codes
});

client.placeResolve(params)

Resolve a placeId (from suggest) into full place details.

const { result } = await client.placeResolve({
  id: "place_abc",
  lang: "vi",
  sessionToken: "uuid", // closes the autocomplete billing session
});

client.reverseGeocode(params)

Admin-boundary reverse geocode — returns the province/district that contains the point (PostGIS ST_Contains). No proximity fallback.

const { city, district } = await client.reverseGeocode({
  lat: 21.03,
  lng: 105.85,
  levels: [4, 8], // OSM: 4 = province, 8 = district
});

Both city and district can be null when no boundary contains the point.

client.adminBoundaries(params)

Province/district polygons as GeoJSON coordinates or WKT.

const boundaries = await client.adminBoundaries({
  levels: [4, 8],
  format: "geojson", // or "wkt"
  countryCode: "VN",
  tolerance: 0.001,  // Douglas-Peucker degrees (lower = more detail)
});

for (const province of boundaries.admin_level_4 ?? []) {
  console.log(
    province.name,
    province.population,
    province.area_km2,
    province.centroid,
  );
}

Errors

All endpoint methods reject with GoGoDukError on non-2xx responses or transport failures:

import { GoGoDukError } from "@gogoduk/sdk";

try {
  await client.suggest({ input: "ab" });
} catch (err) {
  if (err instanceof GoGoDukError) {
    console.error(err.status, err.message, err.requestId, err.body);
  }
}

| Property | Description | |---|---| | status | HTTP status. 0 for network/timeout failures. | | message | Server-provided message or error, falling back to HTTP <status>. | | requestId | x-request-id header value, if the server set it. Include this when reporting bugs. | | body | Parsed JSON or raw text body. |

Versioning

This SDK uses semver. Pre-1.0 (0.x.y), minor bumps (0.1 → 0.2) may include breaking changes.

Contributing

Issues + PRs welcome at gogoduk-io/sdk-ts.

License

MIT