Coder Social home page Coder Social logo

geoliterestapi's Introduction

GeoLiteRestAPI

A simple API to resolve IP addresses using the GeoLite2 City database. IPV4 and IPV6 compativble.

Installation

  • Clone the repo
  • Install the dependencies npm -i
  • Download the Geolite city database from Maxmind
  • Copy the City database to the /databases folder
  • Run the server - npm run start

API endpoint:

/api/v1/ip/:ipaddress

Example request:

http://localhost:3000/api/v1/ip/185.199.108.0

Example Success response:

{
  "status": {
    "responseCode": "200",
    "message": "Ok"
  },
  "results": {
    "continent": {
      "code": "NA",
      "geonameId": 6255149,
      "names": {
        "de": "Nordamerika",
        "en": "North America",
        "es": "Norteamérica",
        "fr": "Amérique du Nord",
        "ja": "北アメリカ",
        "pt-BR": "América do Norte",
        "ru": "Северная Америка",
        "zh-CN": "北美洲"
      }
    },
    "country": {
      "geonameId": 6252001,
      "isoCode": "US",
      "names": {
        "de": "Vereinigte Staaten",
        "en": "United States",
        "es": "Estados Unidos",
        "fr": "États Unis",
        "ja": "アメリカ",
        "pt-BR": "EUA",
        "ru": "США",
        "zh-CN": "美国"
      }
    },
    "registeredCountry": {
      "geonameId": 6252001,
      "isoCode": "US",
      "names": {
        "de": "Vereinigte Staaten",
        "en": "United States",
        "es": "Estados Unidos",
        "fr": "États Unis",
        "ja": "アメリカ",
        "pt-BR": "EUA",
        "ru": "США",
        "zh-CN": "美国"
      },
      "isInEuropeanUnion": false
    },
    "traits": {
      "isAnonymous": false,
      "isAnonymousProxy": false,
      "isAnonymousVpn": false,
      "isHostingProvider": false,
      "isLegitimateProxy": false,
      "isPublicProxy": false,
      "isResidentialProxy": false,
      "isSatelliteProvider": false,
      "isTorExitNode": false,
      "ipAddress": "185.199.108.0",
      "network": "185.199.108.0/25"
    },
    "location": {
      "accuracyRadius": 1000,
      "latitude": 34.0544,
      "longitude": -118.244,
      "timeZone": "America/Los_Angeles"
    },
    "subdivisions": [
      {
        "geonameId": 5332921,
        "isoCode": "CA",
        "names": {
          "de": "Kalifornien",
          "en": "California",
          "es": "California",
          "fr": "Californie",
          "ja": "カリフォルニア州",
          "pt-BR": "Califórnia",
          "ru": "Калифорния",
          "zh-CN": "加州"
        }
      }
    ]
  }
}

Example invalid request:

http://localhost:3000/api/v1/ip/555.555.555.555

{"status":{"responseCode":"400","message":"Invalid IP address detected"}}

geoliterestapi's People

Contributors

benmcelyea avatar

Watchers

James Cloos avatar  avatar

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.