• Stars
    star
    120
  • Rank 295,983 (Top 6 %)
  • Language
    JavaScript
  • Created about 10 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[unmaintained] A module for returning data about countries, ISO info and states/provinces within them. Browserify-compatible

[UNMAINTAINED] country.js

NPM NPM

Join the chat at https://gitter.im/therebelrobot/countryjs js-standard-style Dependency Status Code Climate Test Coverage JS.ORG

A Node.js module for returning data about countries, ISO info and states/provinces within them.

Table of Contents

Install

npm install countryjs

Using with browserify

To run in-browser, you'll need the bulkify transform for browserify, as it pairs with bulk-require, to staticly resolve each country JSON.

npm install bulkify
var bulkify = require('bulkify')
var bundle = browserify({
  entries: [...],
})
.transform(bulkify, {
  global: true
})

Usage

To access one of the country properties available, you'll need to use one of the API methods listed below and pass a country in either way:

  • Using the ISO-alpha2 code: country.population('US', 'ISO2') or country.area('JP') (defaults)
  • Using the ISO-alpha3 code: country.capital('GBR', 'ISO3)
  • Using the country name: country.wiki('france', 'name'). The matching is case-insensitive, against the native name, alternative spellings and available transalations.

API

.info()

Returns all available information for a specified country.

var country = require('countryjs');
country.info('US', 'ISO2'); // 'ISO2', 'ISO3', 'name'
country.info('US'); // Defaults to ISO2
// returns object,
// {
//     "name": "United States",
//     "altSpellings": ["US", "USA", "United States of America"],
//     "area": 9629091,
//     "borders": ["CAN", "MEX"],
//     "callingCodes": ["1"],
//     "capital": "Washington D.C.",
//     "currencies": ["USD", "USN", "USS"],
//     "demonym": "American",
//     "flag": "", // Flag API is incomplete
//     "geoJSON": {} //GeoJSON data,
//     "ISO": {
//         "alpha2": "US",
//         "alpha3": "USA"
//     },
//     "languages": ["en"],
//     "latlng": [38, -97],
//     "nativeName": "United States",
//     "population": 319259000,
//     "provinces": [], // State/Province list
//     "region": "Americas",
//     "subregion": "Northern America",
//     "timezones": [], // TimeZone list
//     "tld": [".us"],
//     "translations": {
//         "de": "Vereinigte Staaten von Amerika",
//         "es": "Estados Unidos",
//         "fr": "Γ‰tats-Unis",
//         "ja": "をパγƒͺγ‚«εˆθ‘†ε›½",
//         "it": "Stati Uniti D'America"
//     },
//     "wiki": "http://en.wikipedia.org/wiki/united_states_of_america"
// }

.states()

Returns all states/provinces for a specified country.

var country = require('countryjs');
country.states('USA', 'ISO3'); // 'ISO2', 'ISO3', 'name'
country.states('US'); // Defaults to ISO2
// returns array of states / provinces,
// [
//  "Alabama",
//  ...
// ]

.provinces()

Alias of .states()

.name()

Returns name for a specified country

var country = require('countryjs');
country.name('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.name('US') // Defaults to 'ISO2'
// returns string
// "United States"

.altSpellings()

Returns alternate spellings for the name of a specified country

var country = require('countryjs');
country.altSpellings('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.altSpellings('US') // Defaults to 'ISO2'
// returns array of strings, alternate names
// ["US", "USA", "United States of America"]

.area()

Returns area (kmΒ²) for a specified country

var country = require('countryjs');
country.area('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.area('US') // Defaults to 'ISO2'
// returns number of square kilometer area
// 9629091

.borders()

Returns bordering countries (ISO3) for a specified country

var country = require('countryjs');
country.borders('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.borders('US') // Defaults to 'ISO2'
// returns array of strings, ISO3 codes of countries that border the given country
// ["CAN", "MEX"]

.callingCodes()

Returns international calling codes for a specified country

var country = require('countryjs');
country.callingCodes('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.callingCodes('US') // Defaults to 'ISO2'
// returns array of calling code strings
// ["1"]

.capital()

Returns capital city for a specified country

var country = require('countryjs');
country.capital('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.capital('US') // Defaults to 'ISO2'
// returns string
// "Washington D.C."

.currencies()

Returns official currencies for a specified country

var country = require('countryjs');
country.currencies('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.currencies('US') // Defaults to 'ISO2'
// returns array of strings, currencies
// ["USD", "USN", "USS"]

.demonym()

Returns the demonyms for a specified country

var country = require('countryjs');
country.demonym('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.demonym('US') // Defaults to 'ISO2'
// returns string, name of residents
// "American"

.flag() - INCOMPLETE

Returns SVG link of the official flag for a specified country

var country = require('countryjs');
country.flag('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.flag('US') // Defaults to 'ISO2'
// returns string URL of CC licensed svg flag

.geoJSON()

Returns geoJSON for a specified country

var country = require('countryjs');
country.geoJSON('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.geoJSON('US') // Defaults to 'ISO2'
// returns object of GeoJSON data

.ISOcodes()

Returns ISO codes for a specified country

var country = require('countryjs');
country.ISOcodes('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.ISOcodes('US') // Defaults to 'ISO2'
// returns object of ISO codes
// {
//   "alpha2": "US",
//   "alpha3": "USA"
// }

.languages()

Returns official languages for a specified country

var country = require('countryjs');
country.languages('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.languages('US') // Defaults to 'ISO2'
// returns array of language codes
// ["en"]

.latlng()

Returns approx latitude and longitude for a specified country

var country = require('countryjs');
country.latlng('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.latlng('US') // Defaults to 'ISO2'
// returns array, approx latitude and longitude for country
// [38, -97]

.nativeName()

Returns the name of the country in its native tongue

var country = require('countryjs');
country.nativeName('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.nativeName('US') // Defaults to 'ISO2'
// returns string, name of country in native language
// "United States"

.population()

Returns approximate population for a specified country

var country = require('countryjs');
country.population('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.population('US') // Defaults to 'ISO2'
// returns number, approx population
// 319259000

.region()

Returns general region for a specified country

var country = require('countryjs');
country.region('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.region('US') // Defaults to 'ISO2'
// returns string
// "Americas"

.subregion()

Returns a more specific region for a specified country

var country = require('countryjs');
country.subregion('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.subregion('US') // Defaults to 'ISO2'
// returns string
// "Northern America"

.timezones()

Returns all timezones for a specified country

var country = require('countryjs');
country.timezones('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.timezones('US') // Defaults to 'ISO2'
// returns array of timezones

.tld()

Returns official top level domains for a specified country

var country = require('countryjs');
country.tld('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.tld('US') // Defaults to 'ISO2'
// returns array of top level domains specific to the country
// [".us"]

.translations()

Returns translations for a specified country name in popular languages

var country = require('countryjs');
country.translations('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.translations('US') // Defaults to 'ISO2'
// returns object of translations of country name in major languages
// {
//   "de": "Vereinigte Staaten von Amerika",
//   "es": "Estados Unidos",
//   "fr": "Γ‰tats-Unis",
//   "ja": "をパγƒͺγ‚«εˆθ‘†ε›½",
//   "it": "Stati Uniti D'America"
// }

.wiki()

Returns link to wikipedia page for a specified country

var country = require('countryjs');
country.wiki('USA','ISO3'); // 'ISO2', 'ISO3', 'name'
country.wiki('US') // Defaults to 'ISO2'
// returns string URL of wikipedia article on country
// "http://en.wikipedia.org/wiki/united_states_of_america"

.all()

Returns array of objects containing all available data for all countries. This will be super big. Not recommended.

var country = require('countryjs');
country.all();
// returns array of objects,
// [{
//     "name": "United States",
//     "altSpellings": ["US", "USA", "United States of America"],
//     "area": 9629091,
//     "borders": ["CAN", "MEX"],
//     "callingCodes": ["1"],
//     "capital": "Washington D.C.",
//     "currencies": ["USD", "USN", "USS"],
//     "demonym": "American",
//     "flag": "", // Flag API is incomplete
//     "geoJSON": {} //GeoJSON data,
//     "ISO": {
//         "alpha2": "US",
//         "alpha3": "USA"
//     },
//     "languages": ["en"],
//     "latlng": [38, -97],
//     "nativeName": "United States",
//     "population": 319259000,
//     "provinces": [], // State/Province list
//     "region": "Americas",
//     "subregion": "Northern America",
//     "timezones": [], // TimeZone list
//     "tld": [".us"],
//     "translations": {
//         "de": "Vereinigte Staaten von Amerika",
//         "es": "Estados Unidos",
//         "fr": "Γ‰tats-Unis",
//         "ja": "をパγƒͺγ‚«εˆθ‘†ε›½",
//         "it": "Stati Uniti D'America"
//     },
//     "wiki": "http://en.wikipedia.org/wiki/united_states_of_america"
// }...]

Special Thanks

Special thanks to johan for his work on johan/world.geo.json, who made the geojson portion of this build possible.

Contributing

This project adheres to Javascript Standard style

To contribute code to this module, please follow this workflow:

  1. fork the repo
  2. make sure to install dev dependencies using
npm install --dev
  1. Make the changes you desire
  2. Ensure all changes have a new test in the test/ folder, and run:
npm test

This will check do the following:

  1. After making changes in your fork, open a pull request.

Please note that if your code updates do not pass JS Standard style, mocha tests and code coverage, your PR may be rejected and you'll need to fix any issues listed in it.

Contributors

Changelog

All notable changes to this project will be documented in this file.

This project adheres to Semantic Versioning and Keep A Changelog.

Unreleased

v1.4.2 - 2015-04-14

Added

  • bulk-require to deps

Fixed

  • Browserify compatibility

Removed

  • glob dep (replaced by bulk-require)

v1.4.1 - 2015-04-14

Added

  • Contributor section to README
  • @moimikey to contributor list (package.json and README)

Fixed

  • Undefined ISO tags from certain countries (refer #19)

Removed

  • Yugoslavia from country list, as it's not a country anymore

v1.4.0 - 2015-03-13

Added

  • mocha.opts
  • Added standard dev dep
  • Added Changelog to README
  • .DS_STORE to .gitignore

Changed

  • Updated test script
  • Updated Contributing Doc

Disclaimer

This is being maintained in the contributor's free time, and as such, may contain minor errors in regards to some countries. Most of the information included in this library is what is listed on Wikipedia. If there is an error, please let me know and I will do my best to correct it.

License (ISC)

Copyright (c) 2015, Trent Oswald [email protected]

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

More Repositories

1

awesome-workshopper

A list of CLI workshopper/adventure tutorials for various things. Inspired by awesome.
1,596
star
2

awesome-bootstrap

✨ Awesome - A curated list of amazing Bootstrap tools and themes.
1,149
star
3

google-adwords

A Node.js driver for Google Adwords Reporting API (v201509)
JavaScript
14
star
4

diff-compare

A line-by-line diffing tool that returns adjusted comparison texts
JavaScript
7
star
5

sockbin

⚑ Websocket Requests and Response service. Built in Node.js 🍰 [unmaintained]
HTML
7
star
6

mirror

restriction-less github forking
CSS
7
star
7

multislack-dash

CSS
4
star
8

ghostfacer

A multi-mode ghost detection device, written in CircuitPython for Seeeduino Xiao BLE Sense πŸ‘» πŸ” - EMF detector / FM Scanner / Ovilus+ / EVP detector
Go
4
star
9

multislack

Express middleware that syncs messages to channels on different Slack teams.
JavaScript
4
star
10

Xaddress-node

A Node port of Xaddress - Work in progress
JavaScript
4
star
11

justbuildsomething

Want to build something? Don't really care what? Here's a list of sample project ideas you can freely steal/build/monetize/rule the world with. Handy for learning new tech or new frameworks.
4
star
12

adopt-a-civic-project

A port of adopt-a-drain, built in Node.js
CSS
4
star
13

next-bootstrap

A boilerplate of app configurations I like for future projects. Next.js, React.js, Koa 2, GraphQL. Borrowing heavily from segmentio/create-next-app
JavaScript
3
star
14

npm-standard

WIP - An opinionated NPM module structure format
2
star
15

gpgez

A CLI wrapper for common GPG commands, cuz typing sux
JavaScript
2
star
16

tRRtoolbelt.less

A library of handy LESS-CSS mixins and functions
CSS
2
star
17

addition-therebelrobot

An addition node module
JavaScript
2
star
18

randomart

OpenSSH randomart images library in JS, now with CLI!
JavaScript
2
star
19

mirror-repo

A simple node module that allows you to manually (and cleanly) fork a Github repository into another location. The magic behind therebelrobot/mirror.
JavaScript
2
star
20

roll20-api-boilerplate

An api script boilerplate for the Roll20 API (command-based)
JavaScript
2
star
21

aeros

πŸ¦…Low-friction GraphQL schemas
JavaScript
2
star
22

learn-assembly-with-apis

I'm learning assembly language using APIs.
Assembly
2
star
23

backbone-deep-model-collection-search

A small monkeypatch for backbone collections to make it work with backbone-deep-model
JavaScript
2
star
24

thunderstorm

Pre-release - An on-premise web-based development environment. Build on Node.js + Docker
CSS
2
star
25

burnitdown

1
star
26

gpg-parsekeys

A simple node module to parse PGP key information from an array of string inputs
JavaScript
1
star
27

wrangler-plex-preroll-update

TypeScript
1
star
28

convershun

A small chrome extension to convert stuff I need regularly.
JavaScript
1
star
29

PokeMMOclassic

A Pokemon Red/Blue MMO, inspired by maierfelix/PokeMMO, built in Node.js πŸ‘Ύ
1
star
30

tools

dumb simple tools that should already exist but I can find all in one place.
HTML
1
star
31

gpg-listkeys

A simple node module to list PGP keys on a system, and indicate whether they are private or not. Requires GPG.
JavaScript
1
star
32

gpg-import-remote

A simple node module to import a PGP key from a remote server. Requires GPG.
1
star
33

gpg-listkeys-remote

A simple node module that lists any key corresponding to input email address, queried from a remote keyserver. Requires GPG.
1
star
34

mirror-issues

A node module to mirror a Github repo's issues
1
star
35

manualfork-placeholder

A github pages placeholder to redirect you to mirror
HTML
1
star
36

ossman

A node CLI to bootstrap initial OSS Manifesto essential files
1
star
37

orbchaser

a rebuild of ufostalker using the same apis
1
star
38

mirror-wiki

A Node module that mirrors a Github Repo's Wiki pages
1
star
39

finddeep

A microlib to synchronously and recursively search an object for a key name, returns object path and reference to property
JavaScript
1
star
40

pgp-adventure

A workshopper/adventure CLI tool for learning command-line pgp usage
1
star
41

hublog

A Chrome Extension to streamline making changelogs from Github PRs
1
star
42

flot-browserify

Work in Progress. An attempt to make Flot Browserify compatible and require()-able
1
star
43

tngcp

A modern application template: The next generation of copypasta
TypeScript
1
star
44

segment-analytics.js-test

HTML
1
star
45

gitornot

JavaScript
1
star
46

fontonite

A public API to convert TTF and OTF fonts to Web Fonts - WIP
CSS
1
star
47

remix-bus-scheduling

A coding challenge
TypeScript
1
star
48

learn-x-with-apis

A series of challenges designed to help you learn a new programming language through building a web API.
1
star
49

live.aster.hn

HTML
1
star
50

soxx

⚑ The missing microlib for websocket communication in the modern browser. 🍰
JavaScript
1
star
51

2d-shooter-unity

A tutorial game for the Coursera Unity course
1
star
52

logger

A web app to log food consumption (built on upcdatabase.org)
1
star
53

jquery.keyBinder

WIP - Bind functions to keyboard events (hotkeys, sequences)
JavaScript
1
star
54

react-nyan

Add a hidden nyancat/flappy bird game to your React app! 🌈 😺
JavaScript
1
star
55

code-for-watch

A simple HTML/JS tool to monitor the Github Activity of Code for America Brigades
JavaScript
1
star
56

fvtt-5e-combat-action-drawer

A Foundry VTT module for dnd5e system that provides PCs a simple walkthrough of available actions to take in battle.
TypeScript
1
star
57

code-slide

🀘 Present code with style - without the React cruft. WIP
1
star
58

tierion-api

An API wrapper for the Tierion APIs
1
star
59

test-create

Repo designed to test creating repos
1
star
60

swissarmyknife

WIP - A variety of handy functions
JavaScript
1
star
61

harasser

Send repeated http requests, even indefinitely, if you like. I hereby wash my hands of what you do with this.
JavaScript
1
star
62

fontonite-server

API server for fontonite webfont conversion services
JavaScript
1
star
63

flot.flow

Allow for pseudo-real-time flowing updates to flot charts with configurable FPS and updateInterval
1
star
64

learn-go-with-apis

A Learn-X-With-APIs exercise with Go
1
star
65

atom-audio

Atom package for previewing audio files
CoffeeScript
1
star
66

release-dump

Dump your Github tagged releases into a changelog file. Super stupid, super simple.
JavaScript
1
star
67

trace-debug-log

Add traces and environment context to your console.log in Node.js applications
JavaScript
1
star
68

mapillarydeck

A Mithril-driven example of the Mapillary API
JavaScript
1
star
69

gpg-email2id

A simple node module that takes an email address and returns the ID of the corresponding PGP key. Requires GPG.
JavaScript
1
star
70

nappyco

A basic api consumption library for nappy.co stock images [WIP]
TypeScript
1
star
71

minimal-bio

A reponsive minimalalist bio HTML template
CSS
1
star
72

event-beam

A browser-compatible event emitter that supports asynchronous, synchronous, and queued event listeners.
1
star
73

mithril-chosen

Mithril wrapper for Chosen jQuery.
JavaScript
1
star
74

learn-x-with-apis-badge

A minimal wrapper for shields.io to simplify badges for learn-x-with-apis
JavaScript
1
star
75

learn-node-with-apis

An example API from Learn-X-With-APIs to demonstrate Node.js codebases.
HTML
1
star
76

tinygo-sandbox

Utils and applications for TinyGo on microcontrollers (Bluno Beetle, Seeeduino Xiao, etc.)
Go
1
star
77

segment-dispatcher

A node.js tool / collection of simple docker api servers that dispatch basic data to Segment
JavaScript
1
star
78

rust-playground

learning rust
1
star
79

liquidvoice

An implementation of liquid/delegative voting
TypeScript
1
star
80

red2

A top-down, retro-like rpg for capturing/training monsters. Building towards multiplayer online.
1
star
81

unity-solar-system

1
star
82

superagent-params

visionmedia/superagent middleware to append a param object to the request URL
JavaScript
1
star
83

homebrew-giddy-griffon

A subsection of TheGiddyLimit/homebrew for development
JavaScript
1
star
84

standard.love

The public site for the standard-led configuration standard
TypeScript
1
star
85

wrangler-google-cal

TypeScript
1
star
86

mirror-cli

Command line utility for 1:1 mirroring of Github repos
JavaScript
1
star
87

assemblyscript-playground

futzing around with AssemblyScript
1
star
88

fvtt-5e-item-type-changer

A FVTT/5e system module to convert items from one type to another
TypeScript
1
star
89

astronomy

🌟 Organize your Github Stars with ease - A POC app to learn redux.
JavaScript
1
star
90

coven-links

TypeScript
1
star
91

factorio-mods

a collection of edited mods for factorio, because i can never just let a thing be.
Lua
1
star
92

fvtt-module-template-typescript

A typescript module template for developing Foundry VTT modules
TypeScript
1
star
93

roll20-script-combatactions-5e

A tool to give options for combat turns, divided by turn phase
JavaScript
1
star
94

smartfly

An attempt at using TinyML + Arduino to build an adaptable, learning, micro-drone
1
star
95

whats-my-xaddress

A mobile web app that will determine your Xaddress from your GPS coordinates
1
star
96

simple-blog-server

A demo of a simple blog platform in Node.js and Typescript (RESTful, MongoDB)
TypeScript
1
star
97

letterboxd-party-extension

Filling in the missing features of Letterboxd, namely: collaborative list generation. Uses WebRTC to make a live collab session to add to someone's list.
TypeScript
1
star
98

simple-auth0-react

The missing auth0 react integration (stolen directly from their docs)
JavaScript
1
star