# all-country-data

> This package provides extra functionality like list of countries and their capitals. Primary language, ISD Codes, Country Codes, Currency Name, Country Flags, Currency Codes will also be provided.

Latest version **1.0.4** (published 2023-12-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install all-country-data
pnpm add all-country-data
yarn add all-country-data
bun add all-country-data
```

## 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.0.4 |
| Published | 2023-12-27 |
| First published | 2021-06-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 1.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | shanuraj715 |
| Maintainers | regalrahul, shanuraj715 |
| Keywords | all country data, countries capitals, isd code, Country currency, country currency code, currency codes |

## Links

- npm: https://www.npmjs.com/package/all-country-data
- npm.io page: https://npm.io/package/all-country-data

## Dependencies (1)

- [zlib](https://npm.io/package/zlib.md) ^1.0.5

## Recent versions

- 1.0.4 (latest) — 2023-12-27
- 1.0.3 — 2022-10-07
- 1.0.2 — 2022-08-14
- 1.0.1 — 2022-08-14
- 0.2.3 — 2022-08-06
- 0.2.2 — 2022-03-23
- 0.2.1 — 2022-03-23
- 0.2.0 — 2022-03-23
- 0.1.1 — 2021-06-08
- 0.1.0 — 2021-06-07
- 0.0.5 — 2021-06-07
- 0.0.4 — 2021-06-07
- 0.0.3 — 2021-06-07
- 0.0.21 — 2021-06-07
- 0.0.2 — 2021-06-07
- … 1 more at https://npm.io/package/all-country-data/versions

## README

# All Country Data

### Installation

```sh
npm i all-country-data
```

## **Newly Added**

##### `Flags images are now compressed. Package size reduced from 3.03 MB to ~899 KB.`
##### `Country Capital Geo: Lattitude and Longitude`

##

---

## Features

##### `Country Flags, Country Capitals, Capital Lattitude/Longitude, Country List, ISD Code, Official Languages, etc...`

### Usage

```js
import country from "all-country-data";

console.log(country.all());
console.log(country.findByCountryCode("+91"));
```

```js
var country = require("all-country-data");

console.log(country.all());
console.log(country.findByCountryCode("+91"));
```

### Use Only Required Function

```js
import search from "all-country-data/dist/search";
or;
var search = require("all-country-data/dist/search");

console.log(search("India"));
```

```js
import countryCapitalList from "all-country-data/dist/countryCapitalList";
or;
var countryCapitalList = require("all-country-data/dist/countryCapitalList");

console.log(countryCapitalList());
```

##### `You can import any particular function by the above method.`

# Functions

| Function Name          | Returns                    | Arguments | Description                                                                                                                                                                                                                                                                                    |
| ---------------------- | -------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| all()                  | Array of Objects           | null      | Returns all countries data including "country", "country_code", "isd_code", "languages", "capital", "currency", "currency_code".                                                                                                                                                               |
| count()                | No. of countries {Integer} | null      | Returns total number of countries in the world.                                                                                                                                                                                                                                                |
| countryCapitalList()   | Array of Objects           | null      | Returns capitals of all the countries.                                                                                                                                                                                                                                                         |
| countryCurrencyList()  | Array of Objects           | null      | Returns every country name with currency name and currency code.                                                                                                                                                                                                                               |
| countryIsdCodeList()   | Array of Objects           | null      | Returns ISD Code of all the countries.                                                                                                                                                                                                                                                         |
| countryLanguageList()  | Array of Objects           | null      | Returns all country names with their languages. returns {"country": `Type` String, "languages": `Type` Array}                                                                                                                                                                                  |
| countryList()          | Array of Objects           | null      | Returns Country names with their Codes. {"country": `Type` String, "country_code": `Type` String }                                                                                                                                                                                             |
| findByCountryCode()    | Single Object              | `String`  | Returns empty object if country code not found or Returns an objects after finding.                                                                                                                                                                                                            |
| findByCountryISD()     | Single Object              | `String`  | Returns empty object if country ISD not found or Returns an objects after finding.                                                                                                                                                                                                             |
| findByCountryName()    | Single Object              | `String`  | Returns empty object if country name not found or returns an object after finding                                                                                                                                                                                                              |
| findCountryByCapital() | Single Object              | `String`  | Returns empty object if country capital not found or returns an object after finding                                                                                                                                                                                                           |
| search()               | Array of Objects           | `String`  | Returns "country", "country_code", "isd_code", "languages", "capital", "currency", "currency_code". It will search in Country Name, Country Code, ISD Code, Capital, Currency, Currency Code. This will not search for Languages. Try `searchByLanguage()` function to search data by language |
| searchByLanguage()     | Array of Objects           | `String`  | Returns "country", "country_code", "isd_code", "languages", "capital", "currency", "currency_code". It only serach in languages. Try `search()` function to search data by country name, code, isd, capital, etc...                                                                            |
| countryFlag()          | String (Base64)            | `String`  | Returns transparent image data in base64 format. It only find the flag by "country name" or "country code".                                                                                                                                                                                    |
| searchFlag()           | Array of Objects           | `String`  | Returns Array of Objects. Object contains 'country name', 'country code' and base64 string for the transparent flag of that country.                                                                                                                                                           |
| `new` **capitalGeo()** | Single Object              | null      | Returns an object with properties "country", "capital", "capital_geo"                                                                                                                                                                                                                          |

## Examples

```js
import countries from "all-country-data";

var allCountries = countries.all();
allCountries.map((item) => {
  console.log(item.country);
  console.log(item.country_code);
});

var totalCountries = countries.count();
console.log(totalCountries);

var capitals = countries.countryCapitalList();
capitals.map((item) => {
  console.log(item.country);
  console.log(item.capital);
});

var currency = countries.countryCurrencyList();
allCountries.map((item) => {
  console.log(item.country);
  console.log(item.currency_code);
});

var base64flag = countries.countryFlag("india");
console.log(base64flag);
// data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cD...

var searchFlag = countries.searchFlag("India");
console.log(searchFalg);
/* [
  { name: 'British Indian Ocean Territory',
    country_code: 'IO',
    flag: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0...' },
  { name: 'India',
    country_code: 'IN',
    flag: 'data:image/svg+xml;base64,PHN2ZyB4bWxu...' }
]
*/
```

##### `Remaining function can also be used like the above explained functions.`

#### GitHub Repository

[Git Repository](https://github.com/shanuraj715/all-country-data)

#### NPM Package

[NPM Package Repository](https://www.npmjs.com/package/all-country-data)

## License

MIT

**Free Package, by shanuraj715!**

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