JSPM

  • Created
  • Published
  • Downloads 57206
  • Score
    100M100P100Q149428F
  • License AGPL

Data about countries - like their ISO codes and currencies

Package Exports

  • country-data
  • country-data/data/countries.json

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (country-data) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Country Data

Build Status

There are lots of little bits of data that you often need relating to countries, and I couldn't find any easy to use source of it. So I compiled it all here.

The data currently provided for each country is:

Installing

npm install country-data

Example usage

var countries = require('country-data').countries;

console.log( countries.alpha2.BE.name );        // 'Belgium'
console.log( countries.alpha3.FRA.currencies ); // ['EUR']

It is very simple for now - feel free to contribute more helpful accessors.

Adding data

More data for each country is most welcome. Obvious things that it might be nice to add are:

  • Top level domains
  • Wikipedia links
  • Coordinates (centroid, bounding box, etc)
  • International dialing codes

The data is finally stored as JSON, but this is not always easy to manipulate. For this it is easier to edit the CSV files (using spreadsheet software) and then use the scripts in the data directory to convert the CSV to JSON. Please don't edit the JSON directly, but do it via the CSV.

These are the steps required

# Clone the repo (or better your fork of it)
git clone https://github.com/LinkToBooks/country-data.git
cd country-data

# install the dependencies
npm install .

# Edit the countries.csv
open countries.csv

# Convert the CSV to JSON
node data/country_csv_to_json.js > data/countries.json

# Run the tests
mocha

# If all is ok commit and push
git add .
git commit
git push

# Then send a pull request with your changes