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

locara-js

v1.0.0

Published

Official JavaScript/TypeScript SDK for the Locara location API

Readme

locara-js

Official JavaScript/TypeScript SDK for the Locara location API. Access countries, states, and cities with full type safety. Works in Node.js 18+ and modern browsers.

Install

npm install locara-js

Quick start

import { LocaraClient } from "locara-js";

const client = new LocaraClient({ apiKey: "loc_live_xxxx" });

// List countries
const countries = await client.countries.list({ page: 1, limit: 10 });
console.log(countries.data[0].name);

// Get a single country
const usa = await client.countries.get("US");
console.log(usa.capital);

// List states in a country
const states = await client.states.list("IN", { page: 1, limit: 50 });

// Get cities in a state
const cities = await client.cities.list("US", "CA", { page: 1, limit: 25 });

Configuration

const client = new LocaraClient({
  apiKey: "loc_live_xxxx",           // required
  baseUrl: "https://www.locara.online/api/v1", // optional, this is the default
  timeout: 30_000,                   // optional, request timeout in ms (default: 30000)
});

API reference

LocaraClient

class LocaraClient {
  constructor(options: { apiKey: string; baseUrl?: string; timeout?: number });

  countries: CountriesResource;
  states: StatesResource;
  cities: CitiesResource;
}

Countries

// GET /countries
client.countries.list(options?: { page?: number; limit?: number }): Promise<PaginatedResponse<Country>>

// GET /countries/:isoCode
client.countries.get(isoCode: string): Promise<Country>

States

// GET /countries/:countryCode/states
client.states.list(countryCode: string, options?: { page?: number; limit?: number }): Promise<PaginatedResponse<State>>

// GET /countries/:countryCode/states/:stateCode
client.states.get(countryCode: string, stateCode: string): Promise<State>

Cities

// GET /countries/:countryCode/states/:stateCode/cities
client.cities.list(countryCode: string, stateCode: string, options?: { page?: number; limit?: number }): Promise<PaginatedResponse<City>>

// GET /countries/:countryCode/states/:stateCode/cities/:cityId
client.cities.get(countryCode: string, stateCode: string, cityId: string): Promise<City>

Types

interface Country {
  id: string;
  name: string;
  isoCode: string;
  iso3: string;
  phoneCode: string;
  capital: string;
  currency: string;
  latitude: string;
  longitude: string;
}

interface State {
  id: string;
  name: string;
  isoCode: string;
  countryCode: string;
  latitude: string;
  longitude: string;
}

interface City {
  id: string;
  name: string;
  stateCode: string;
  countryCode: string;
  latitude: string;
  longitude: string;
}

interface PaginatedResponse<T> {
  success: boolean;
  data: T[];
  pagination: {
    total: number;
    page: number;
    limit: number;
    totalPages: number;
  };
}

Error handling

Non-2xx responses throw a LocaraError with status, message, and code fields:

import { LocaraClient, LocaraError } from "locara-js";

const client = new LocaraClient({ apiKey: "loc_live_xxxx" });

try {
  const country = await client.countries.get("XX");
} catch (error) {
  if (error instanceof LocaraError) {
    console.error(error.status);  // e.g. 404
    console.error(error.message); // e.g. "Country not found."
    console.error(error.code);    // e.g. "NOT_FOUND"
  } else {
    throw error;
  }
}

Documentation

For full API documentation, authentication details, and pagination guides, visit:

https://www.locara.online/docs

License

MIT