Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

countries-api

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

countries-api

module to get world countries with ease

  • 2.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
189
decreased by-34.6%
Maintainers
1
Weekly downloads
 
Created
Source

Countries-Api

Module which expose some usefull Api's that can be very handy when dealing with countries

Country JSON object will be like

{
  "name": {
    "common": "Aruba",
    "official": "Aruba",
    "native": {
      "nld": {
        "official": "Aruba",
        "common": "Aruba"
      },
      "pap": {
        "official": "Aruba",
        "common": "Aruba"
      }
    }
  },
  "tld": [".aw"],
  "cca2": "AW",
  "ccn3": "533",
  "cca3": "ABW",
  "cioc": "ARU",
  "currency": ["AWG"],
  "callingCode": ["297"],
  "capital": "Oranjestad",
  "altSpellings": ["AW"],
  "region": "Americas",
  "subregion": "Caribbean",
  "languages": {
    "nld": "Dutch",
    "pap": "Papiamento"
  },
  "translations": {
    "deu": {"official": "Aruba", "common": "Aruba"},
    "fra": {"official": "Aruba", "common": "Aruba"},
    "hrv": {"official": "Aruba", "common": "Aruba"},
    "ita": {"official": "Aruba", "common": "Aruba"},
    "jpn": {"official": "\u30a2\u30eb\u30d0", "common": "\u30a2\u30eb\u30d0"},
    "nld": {"official": "Aruba", "common": "Aruba"},
    "por": {"official": "Aruba", "common": "Aruba"},
    "rus": {"official": "\u0410\u0440\u0443\u0431\u0430", "common": "\u0410\u0440\u0443\u0431\u0430"},
    "spa": {"official": "Aruba", "common": "Aruba"},
    "fin": {"official": "Aruba", "common": "Aruba"},
    "zho": {"official": "\u963F\u9C81\u5DF4", "common": "\u963F\u9C81\u5DF4"}
  },
  "latlng": [12.5, -69.96666666],
  "demonym": "Aruban",
  "landlocked": false,
  "borders": [],
  "area": 180
}

Author: Gaurav Joshi

Start

const Countries = require('Countries-Api');

Uses https://github.com/GJ2511/response-format module for formating results

Methods

findByCountryCode(countryCode)

Returns a 200 Success where:

  • statusCode - 200
  • error - false
  • message - optional message.
  • data - optional payload.
Countries.findByCountryCode('AW');

Generates the following response payload:

{"statusCode":200,"error":false,"data":[{"name":{"common":"Aruba","official":"Aruba","native":{"nld":{"official":"Aruba","common":"Aruba"},"pap":{"official":"Aruba","common":"Aruba"}}},"tld":[".aw"],"cca2":"AW","ccn3":"533","cca3":"ABW","cioc":"ARU","currency":["AWG"],"callingCode":["297"],"capital":"Oranjestad","altSpellings":["AW"],"region":"Americas","subregion":"Caribbean","languages":{"nld":"Dutch","pap":"Papiamento"},"translations":{"deu":{"official":"Aruba","common":"Aruba"},"fra":{"official":"Aruba","common":"Aruba"},"hrv":{"official":"Aruba","common":"Aruba"},"ita":{"official":"Aruba","common":"Aruba"},"jpn":{"official":"アルバ","common":"アルバ"},"nld":{"official":"Aruba","common":"Aruba"},"por":{"official":"Aruba","common":"Aruba"},"rus":{"official":"Аруба","common":"Аруба"},"spa":{"official":"Aruba","common":"Aruba"},"fin":{"official":"Aruba","common":"Aruba"},"zho":{"official":"阿鲁巴","common":"阿鲁巴"}},"latlng":[12.5,-69.96666666],"demonym":"Aruban","landlocked":false,"borders":[],"area":180}],"message":"OK"}

findByCCN3(ccn3)

Returns a 200 Success where:

  • statusCode - 200
  • error - false
  • message - optional message.
  • data - optional payload.
Countries.findByCCN3(533);

Generates the same response as: findByCountryCode(countryCode)

findByCCA3(cca3)

Returns a 200 Success where:

  • statusCode - 200
  • error - false
  • message - optional message.
  • data - optional payload.
Countries.findByCCA3('ABW');

Generates the same response as: findByCountryCode(countryCode)

findByCIOC(cioc)

Returns a 200 Success where:

  • statusCode - 200
  • error - false
  • message - optional message.
  • data - optional payload.
Countries.findByCIOC('ARU');

Generates the same response as: findByCountryCode(countryCode)

findByCapital(capital)

Returns a 200 Success where:

  • statusCode - 200
  • error - false
  • message - optional message.
  • data - optional payload.
Countries.findByCapital('Oranjestad');

Generates the same response as: findByCountryCode(countryCode)

findBySubRegion(subRegion)

Returns a 200 Success where:

  • statusCode - 200
  • error - false
  • message - optional message.
  • data - optional payload.
Countries.findBySubRegion('Caribbean');

Generates the same response as (May have multiple entries): findByCountryCode(countryCode)

findByRegion(region)

Returns a 200 Success where:

  • statusCode - 200
  • error - false
  • message - optional message.
  • data - optional payload.
Countries.findByRegion('Americas');

Generates the same response as (May have multiple entries): findByCountryCode(countryCode)

findByResidentName(name)

Returns a 200 Success where:

  • statusCode - 200
  • error - false
  • message - optional message.
  • data - optional payload.
Countries.findByResidentName('Aruban');

Generates the same response as (May have multiple entries): findByCountryCode(countryCode)

findByLandLock(boolean)

Returns a 200 Success where:

  • statusCode - 200
  • error - false
  • message - optional message.
  • data - optional payload.
Countries.findByLandLock(false);

Generates the same response as (May have multiple entries): findByCountryCode(countryCode)

findByArea(area)

Returns a 200 Success where:

  • statusCode - 200
  • error - false
  • message - optional message.
  • data - optional payload.
Countries.findByArea(180);

Generates the same response as (May have multiple entries): findByCountryCode(countryCode)

findByCurrency(currency)

Returns a 200 Success where:

  • statusCode - 200
  • error - false
  • message - optional message.
  • data - optional payload.
Countries.findByCurrency("AWG");

Generates the same response as (May have multiple entries): findByCountryCode(countryCode)

findByCallingCode(code)

Returns a 200 Success where:

  • statusCode - 200
  • error - false
  • message - optional message.
  • data - optional payload.
Countries.findByCallingCode("297");

Generates the same response as (May have multiple entries): findByCountryCode(countryCode)

findBySpellings(spells)

Returns a 200 Success where:

  • statusCode - 200
  • error - false
  • message - optional message.
  • data - optional payload.
Countries.findBySpellings("ZW", "Republic of Zimbabwe");
Countries.findBySpellings("ZW");

Generates the same response as (May have multiple entries): findByCountryCode(countryCode)

findByBorders(borders)

Returns a 200 Success where:

  • statusCode - 200
  • error - false
  • message - optional message.
  • data - optional payload.
Countries.findByBorders("AGO", "BWA",);
Countries.findByBorders("AGO");

Generates the same response as (May have multiple entries): findByCountryCode(countryCode)

findByLat(latitude)

Returns a 200 Success where:

  • statusCode - 200
  • error - false
  • message - optional message.
  • data - optional payload.
Countries.findByLat(12);

Generates the same response as : findByCountryCode(countryCode)

findByLong(longitude)

Returns a 200 Success where:

  • statusCode - 200
  • error - false
  • message - optional message.
  • data - optional payload.
Countries.findByLong(-69.96666666);

Generates the same response as : findByCountryCode(countryCode)

findByLatLong(array)

Returns a 200 Success where:

  • statusCode - 200
  • error - false
  • message - optional message.
  • data - optional payload.
Countries.findByLatLong([12.5, -69.96666666]);

Generates the same response as : findByCountryCode(countryCode)

findByName(name)

Returns a 200 Success where:

  • statusCode - 200
  • error - false
  • message - optional message.
  • data - optional payload.
Countries.findByName('Aruba');

Generates the same response as : findByCountryCode(countryCode)

findByOfficialName(officialName)

Returns a 200 Success where:

  • statusCode - 200
  • error - false
  • message - optional message.
  • data - optional payload.
Countries.findByOfficialName('Aruba');

Generates the same response as : findByCountryCode(countryCode)

findByLanguage(name)

Returns a 200 Success where:

  • statusCode - 200
  • error - false
  • message - optional message.
  • data - optional payload.
Countries.findByLanguage('Dutch');

Generates the same response as : findByCountryCode(countryCode)

findAll()

Returns a 200 Success where:

  • statusCode - 200
  • error - false
  • message - optional message.
  • data - optional payload.
Countries.findAll();

Generates the same response as (Whole Country data): findByCountryCode(countryCode)

findById(id)

Returns a 200 Success where:

  • statusCode - 200
  • error - false
  • message - optional message.
  • data - optional payload.
Countries.findById(1);

Generates the same response as : findByCountryCode(countryCode)

Keywords

FAQs

Package last updated on 24 Sep 2018

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc