Code Monkey home page Code Monkey logo

ip-to-country's Introduction

IP to Country

Build Status Test Covarage Greenkeeper Latest Version

Get country from IP address using MaxMind GeoLite2 binary database.

Installation

$ npm install @risan/ip-to-country

Usage

const ipToCountry = require("@risan/ip-to-country");

(async () => {
  try {
    const result = await ipToCountry("123.45.6.7");

    if (result) {
      console.log(result);
    } else {
      console.log("IP address not found.");
    }
  } catch(error) {
    console.error(error.message);
  }
})();

API

ipToCountry(ip)

Parameters

  • ip (String): The IP address to lookup.

Returns

It returns a Promise which when resolved contains undefined or an Object. undefined means the given IP address is not found in the database. Here's an example of the resolved country object:

{
  code: "ID",
  name: "Indonesia",
  flag_emoji: "🇮🇩",
  geoname_id: 1643084,
  names: {
    de: "Indonesien",
    en: "Indonesia",
    es: "Indonesia",
    fr: "Indonésie",
    ja: "インドネシア共和国",
    "pt-BR": "Indonésia",
    ru: "Индонезия",
    "zh-CN": "印度尼西亚"
  },
  continent: {
    name: "Asia",
    code: "AS",
    geoname_id: 6255147,
    names: {
      de: "Asien",
      en: "Asia",
      es: "Asia",
      fr: "Asie",
      ja: "アジア",
      "pt-BR": "Ásia",
      ru: "Азия",
      "zh-CN": "亚洲"
    }
  }
}
  • code: Two-letter country code in ISO 3166-1 alpha-2 format.
  • name: The country name.
  • flag_emoji: The country flag emoji.
  • geoname_id: The GeoNames id.
  • names: The country name in various language.
  • continent: The continent data.

License

CC-BY-SA 4.0 · Risan Bagja Pradana

This product includes GeoLite2 data created by MaxMind, available from https://www.maxmind.com. GeoLite2 Database and Contents Copyright (c) 2018 MaxMind, Inc.

The MaxMind GeoLite2 database incorporates GeoNames geographical data, which is made available under the Creative Commons Attribution 3.0 License.

ip-to-country's People

Contributors

greenkeeper[bot] avatar risan avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ip-to-country's Issues

An in-range update of prettier is breaking the build 🚨

The devDependency prettier was updated from 1.18.2 to 1.19.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

prettier is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for Prettier 1.19: Long awaited Vue option, TypeScript 3.7 and new JavaScript features

diff

🔗 Release Notes

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint-plugin-prettier is breaking the build 🚨

The devDependency eslint-plugin-prettier was updated from 3.1.1 to 3.1.2.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-prettier is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint-plugin-import is breaking the build 🚨

The devDependency eslint-plugin-import was updated from 2.18.2 to 2.19.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-import is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 46 commits.

  • 9b76635 Bump to v2.19.0
  • 47a232e [resolvers/webpack] v0.12.0
  • 26ad476 [resolvers/webpack] [deps] update debug, enhanced-resolve, has, interpret, lodash, resolve, semver
  • 3f0e8f3 [resolvers/node] [Deps] update resolve
  • 7190c3e bump utils to v2.5.0
  • a60e5c6 [New] no-commonjs: add allowConditionalRequire option
  • 414c923 [New] enable passing cwd as an option to eslint-import-resolver-webpack
  • 8224e51 [New] order/no-extraneous-dependencies: Alphabetize imports within groups
  • f12ae59 [New] no-duplicates: add a considerQueryString option to handle false positives when using some webpack loaders.
  • 2d3d045 [fix] importType: Accept '@example' as internal
  • 0426f16 [New] order: add pathGroups option to add support to order by paths
  • 99b3fbf [Fix] no-extraneous-dependencies: Add support for export from
  • 21bf8c6 [Fix] no-cycle: should not warn for Flow imports
  • 0cd5e43 [Fix] no-unused-modules: fix crash due to export *
  • 05085bb [flow] no-unused-modules: add flow type support

There are 46 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of country-flag-emoji is breaking the build 🚨

The dependency country-flag-emoji was updated from 1.0.2 to 1.0.3.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

country-flag-emoji is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 29 commits.

  • bc2529b Merge pull request #14 from risan/remove-greenkeeper
  • 3095740 Patch version v1.0.3
  • 520fae8 Remove greenkeeper and update website url
  • aa46ccb Update license year
  • c3144b7 Update minimum nodejs requirement
  • 207a186 Merge pull request #13 from risan/greenkeeper/eslint-config-airbnb-base-14.0.0
  • afe3f3a Merge branch 'master' into greenkeeper/eslint-config-airbnb-base-14.0.0
  • 70b9c23 Merge pull request #12 from risan/greenkeeper/eslint-6.0.0
  • d6e184e Merge pull request #11 from risan/greenkeeper/eslint-config-prettier-5.0.0
  • b15c2ff Merge pull request #10 from risan/greenkeeper/rollup-plugin-terser-5.0.0
  • bf384c0 Merge branch 'master' into greenkeeper/rollup-plugin-terser-5.0.0
  • 51bcdcb Merge pull request #9 from risan/greenkeeper/rollup-plugin-node-resolve-5.0.0
  • 1a19a3e Merge branch 'master' into greenkeeper/rollup-plugin-node-resolve-5.0.0
  • 32cd32f Merge pull request #8 from risan/greenkeeper/rollup-plugin-commonjs-10.0.0
  • c0cb99f chore(package): update eslint-config-airbnb-base to version 14.0.0

There are 29 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.