# countries-code

> List of contries data with alpha-2, alpha-3 and number codes

Latest version **1.1.1** (published 2024-02-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install countries-code
pnpm add countries-code
yarn add countries-code
bun add countries-code
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2024-02-02 |
| First published | 2019-05-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 75.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | NirvanaFlame |
| Maintainers | nirvanaflame1 |
| Keywords | countries, countries name in french, ISO 3166-1, alpha-2 code, alpha-3 code, alpha-2 code to alpha-3 code, alpha-3 code to alpha-2 code, alpha2 to alpha3 code, alpha3 to alpha2 code, alpha-2 code to country name, alpha-3 code to country name, alpha-3 code, 2 Char long country code, 3 Char long country code, getCountry by alphaCode 2 or 3, getCountry by alpha2 or alpha3 |

## Links

- npm: https://www.npmjs.com/package/countries-code
- Repository: https://github.com/nirvana-flame/countries-code
- Issues: https://github.com/nirvana-flame/countries-code/issues
- npm.io page: https://npm.io/package/countries-code

## Recent versions

- 1.1.1 (latest) — 2024-02-02
- 1.1.0 — 2020-08-28
- 1.0.9 — 2020-08-28
- 1.0.8 — 2019-06-04
- 1.0.7 — 2019-06-04
- 1.0.6 — 2019-05-19
- 1.0.5 — 2019-05-18
- 1.0.4 — 2019-05-18
- 1.0.2 — 2019-05-18
- 1.0.1 — 2019-05-18
- 1.0.0 — 2019-05-18

## README

# countries-code

[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://opensource.org/licenses/MIT)
[![Known Vulnerabilities](https://snyk.io/test/github/nirvana-flame/countries-code/badge.svg?targetFile=package.json)](https://snyk.io/test/github/nirvana-flame/countries-code?targetFile=package.json)
[![npm](https://img.shields.io/badge/npm-1\.1\.0-yellow.svg)](https://www.npmjs.com/package/countries-code)

Data fetched from https://unstats.un.org/unsd/methodology/m49/ (UN)
and from Wikipedia

List of countries:
With country object containing Alpha-2 code (e.g.`IE`), Alpha-3 code (e.g. `IRL`), and Number codes.

## Example

```js
const countriesQuery = require("countries-code");

console.log(countriesQuery.allCountriesList());
/*
[....,
 {
    "country_name_en": "Ireland",
    "country_name_fr": "Irlande (l')",
    "alpha2": "IE",
    "alpha3": "IRL",
    "number": "372"
},...] 
*/
console.log(countriesQuery.getAllAlphaTwoCodes());
// ["AF",.....]
console.log(countriesQuery.getAllAlphaThreeCodes());
// ["AFG",.....]

// Use getCountry to get country name by alpha code-2 or 3
console.log(countriesQuery.getCountry("IE"));
// "Ireland"
console.log(countriesQuery.getCountry("IRL"));
// "Ireland"

// Use convertAlphaCode to convert alpha code-2 to 3 or vice versa
console.log(countriesQuery.convertAlphaCode("IE"));
// "IRL"
console.log(countriesQuery.convertAlphaCode("IRL"));
// "IE"
```

```js
import { countriesQuery } from "countries-code";

console.log(countriesQuery.allCountriesList());
/*
[....,
 {
    "country_name_en": "Ireland",
    "country_name_fr": "Irlande (l')",
    "alpha2": "IE",
    "alpha3": "IRL",
    "number": "372"
},...] 
*/
console.log(countriesQuery.getAllAlphaTwoCodes());
// ["AF",.....]
console.log(countriesQuery.getAllAlphaThreeCodes());
// ["AFG",.....]

// Use getCountry to get country name by alpha code-2 or 3
console.log(countriesQuery.getCountry("IE"));
// "Ireland"
console.log(countriesQuery.getCountry("IRL"));
// "Ireland"

// Use convertAlphaCode to convert alpha code-2 to 3 or vice versa
console.log(countriesQuery.convertAlphaCode("IE"));
// "IRL"
console.log(countriesQuery.convertAlphaCode("IRL"));
// "IE"
```

# License

MIT

:incoming_envelope: :four_leaf_clover:

---
_Source: https://npm.io/package/countries-code · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
