Socket
Book a DemoInstallSign in
Socket

ac-countrylist

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ac-countrylist

This is a little helper to retrieve a countrylist and query this countrylist.

1.0.14
latest
Source
npmnpm
Version published
Weekly downloads
196
653.85%
Maintainers
1
Weekly downloads
 
Created
Source

AC CountryList

This is a little helper to retrieve a countrylist and query this countrylist.

The countrylist is forked from https://gist.github.com/stefanbauer/bf0720c6846a3cc9b59e

Usage

You can use the countrylist directly by importing countrylist.js. But it is recommended to use this little helper and require this module.

const acCountryList = require('ac-countrylist')

Fetch country list

Return a short list with iso2, country name and spoken languages.

const list = acCountryList.showList()
// -> [{ name: 'Afghanistan',
    iso2: 'af',
    alpha2Code: 'af',
    languages: [ 'ps', 'uz', 'tk' ] }, ...]

Query list

Query the country list (currently only iso2 and iso3 is supported)

const country = acCountryList.query({ iso2: 'de' })
// OR
const country = acCountryList.query({ iso3: 'deu' })

// -> { name: 'Germany',
  capital: 'Berlin',
  altSpellings:
   [ 'DE',
     'Federal Republic of Germany',
     'Bundesrepublik Deutschland' ],
  relevance: '3',
  region: 'Europe',
  subregion: 'Western Europe',
  translations:
   { de: 'Deutschland',
     es: 'Alemania',
     fr: 'Allemagne',
     ja: 'ドイツ',
     it: 'Germania' },
  population: 81083600,
  latlng: [ 51, 9 ],
  demonym: 'German',
  area: 357114,
  gini: 28.3,
  timezones: [ 'UTC+01:00' ],
  borders:
   [ 'AUT', 'BEL', 'CZE', 'DNK', 'FRA', 'LUX', 'NLD', 'POL', 'CHE' ],
  nativeName: 'Deutschland',
  callingCodes: [ '49' ],
  topLevelDomain: [ '.de' ],
  alpha2Code: 'DE',
  alpha3Code: 'DEU',
  currencies: [ 'EUR' ],
  languages: [ 'de' ] }

Fetch random country

Return a random country

const randomCountry = acCountryList.random()
//
{ name: 'Afghanistan',
  iso2: 'af',
  alpha2Code: 'af',
  languages: [ 'ps', 'uz', 'tk' ] 
}

License

MIT License Copyright © 2009-present, AdmiralCloud, Mark Poepping

FAQs

Package last updated on 30 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.