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

@abdoseadaa/country-flags

v1.0.0

Published

TypeScript SDK for the Country Flags API — ISO country codes, flags, cities, and dialling codes.

Readme

@abdoseadaa/country-flags

TypeScript SDK for the Country Flags API — ISO country codes, SVG flags, city data, and dialling codes.

  • Universal: works in Node.js 18+ and modern browsers
  • Zero dependencies — uses the native fetch API
  • Dual ESM + CJS output with full TypeScript declarations
  • Default instance points to https://iso.api.gbstr.io — no config needed

Install

npm install @abdoseadaa/country-flags

Quick start

import ISO from '@abdoseadaa/country-flags';

// List countries
const { data, total } = await ISO.getCountries({ search: 'egypt', limit: 5 });

// Get a flag URL (sync — no HTTP call)
const url = ISO.getFlagUrl('EG');           // https://iso.api.gbstr.io/v1/flags/EG

// Fetch SVG markup
const svg = await ISO.getFlagSvg('EG');

// Cities for a country
const cities = await ISO.getCities('EG', { search: 'cairo' });

// Countries with dialling codes + flag URLs
const phones = await ISO.getPhoneCodes();

// Health check
const health = await ISO.getHealth();

Custom base URL

Point to a self-hosted instance or local dev server:

import { CountryFlagsClient } from '@abdoseadaa/country-flags';

const client = new CountryFlagsClient({ baseUrl: 'http://localhost:54032' });
const { data } = await client.getCountries();

API Reference

ISO (default export)

All methods are also available on CountryFlagsClient instances.


ISO.getHealth()

getHealth(): Promise<HealthResponse>

Returns server status and uptime.

const { status, uptime, timestamp } = await ISO.getHealth();

ISO.getCountries(params?)

getCountries(params?: CountriesParams): Promise<ListResponse<Country>>

| Param | Type | Description | |-------|------|-------------| | limit | number | Max results to return (default: 20) | | skip | number | Results to skip for pagination (default: 0) | | search | string | Search by country name | | region | string | Filter by region (e.g. "Asia", "Europe") |

const { data, total } = await ISO.getCountries({ region: 'Europe', limit: 10 });

ISO.getFlagUrl(code, style?)

getFlagUrl(code: string, style?: string): string

Synchronous — constructs and returns the flag URL without making an HTTP call.

const url = ISO.getFlagUrl('GB');         // https://iso.api.gbstr.io/v1/flags/GB
const flat = ISO.getFlagUrl('GB-ENG');   // sub-national flag

ISO.getFlagSvg(code, style?)

getFlagSvg(code: string, style?: string): Promise<string>

Fetches and returns the raw SVG markup for a flag.

const svg = await ISO.getFlagSvg('US');
document.getElementById('flag')!.innerHTML = svg;

ISO.getCities(code, params?)

getCities(code: string, params?: CitiesParams): Promise<ListResponse<City>>

| Param | Type | Description | |-------|------|-------------| | limit | number | Max results to return (default: 40) | | skip | number | Results to skip for pagination (default: 0) | | search | string | Search by city name |

const { data, total } = await ISO.getCities('DE', { search: 'berlin' });

ISO.getPhoneCodes()

getPhoneCodes(): Promise<ListResponse<PhoneCode>>

Returns all countries that have a dialling code, sorted alphabetically. Each entry includes flagUrl.

const { data } = await ISO.getPhoneCodes();
// data[0] → { code: 'AF', name: 'Afghanistan', callingCode: '+93', flagUrl: '...' }

Types

type CountryCode =
  | 'AF' | 'AX' | 'AL' | 'DZ' | 'AS' | 'AD' | /* ... all 250+ codes */ | 'ZW';

interface Country {
  code: CountryCode;
  name: string;
  region: string;
  subregion: string;
  callingCode: string | null;
  capital: string | null;
  currency: string | null;
  languages: string[];
  flagUrl: string;
}

interface City {
  name: string;
  lat: number;
  lng: number;
  country: CountryCode;
  admin1?: string;
  admin2?: string;
  population?: number;
}

interface PhoneCode {
  code: CountryCode;
  name: string;
  callingCode: string;
  flagUrl: string;
}

interface HealthResponse {
  status: string;
  uptime: number;
  timestamp: string;
}

interface ListResponse<T> {
  data: T[];
  total: number;
}

interface CountriesParams {
  limit?: number;
  skip?: number;
  search?: string;
  region?: string;
}

interface CitiesParams {
  limit?: number;
  skip?: number;
  search?: string;
}

interface ClientOptions {
  baseUrl?: string;
}

License

MIT