Git Product home page Git Product logo

ipfinder's Introduction

IP Finder API

This is a simple backend API built with Express that provides detailed information about a given IP address. It uses MaxMind's GeoLite2 database for geolocation, geo-tz for timezone information, and ip-api for additional connection details.

Features

  • Retrieve detailed information about an IP address including location, timezone, country details, currency, and connection information.
  • Supports both IPv4 and IPv6 addresses.

Prerequisites

  • Node.js (v12.x or later)
  • npm (v6.x or later)

Setup

  1. Clone the repository:

    git clone <repository_url>
    cd <repository_directory>
  2. Install the dependencies:

    npm install
  3. Ensure you have the MaxMind GeoLite2-City database file. Download it from MaxMind's website and place it in the data directory with the name GeoLite2-City.mmdb.

  4. Make sure you have the following JSON data files in the data directory:

    • country_flag_and_emojis/by-code.json: Contains flag images, emojis, and unicode by country code.
    • currency_details.json: Contains currency details including code, name, plural name, symbol, and native symbol.
  5. For each country, there should be a JSON file in the data/countries directory named with the country's ISO code (e.g., US.json) containing country-specific details like languages spoken and currency code.

Running the Server

Start the server with the following command:

npm start

The server will run on http://localhost:3000.

API Endpoint

Get IP Details

Endpoint: /api/location/:ip

Method: GET

Description: Retrieve detailed information about a given IP address.

Parameters:

  • ip: The IP address to lookup (IPv4 or IPv6).

Example Request:

curl http://localhost:3000/api/location/8.8.8.8

Example Response:

{
    "error": false,
    "data": {
        "ip": "8.8.8.8",
        "hostname": "8.8.8.8",
        "type": "IPv4",
        "continent_code": "NA",
        "continent_name": "North America",
        "country_code": "US",
        "country_name": "United States",
        "region_code": "CA",
        "region_name": "California",
        "city": "Mountain View",
        "zip": "94035",
        "latitude": 37.386,
        "longitude": -122.0838,
        "location": {
            "geoname_id": 6252001,
            "capital": "Washington D.C.",
            "languages": ["English"],
            "country_flag": "πŸ‡ΊπŸ‡Έ",
            "country_flag_emoji": "πŸ‡ΊπŸ‡Έ",
            "country_flag_emoji_unicode": "U+1F1FA U+1F1F8",
            "calling_code": "1",
            "is_eu": false,
            "name": "United States"
        },
        "time_zone": {
            "id": "America/Los_Angeles",
            "current_time": "2024-06-15T10:00:00-07:00",
            "gmt_offset": -25200,
            "code": "PDT",
            "is_daylight_saving": true
        },
        "currency": {
            "code": "USD",
            "name": "United States Dollar",
            "plural": "United States dollars",
            "symbol": "$",
            "symbol_native": "$"
        },
        "connection": {
            "asn": null,
            "isp": "Google LLC",
            "org": "Google LLC",
            "as": "AS15169 Google LLC",
            "query": "8.8.8.8"
        },
        "security": {
            "is_proxy": false,
            "proxy_type": null,
            "is_crawler": false,
            "crawler_name": null,
            "crawler_type": null,
            "is_tor": false,
            "threat_level": "low",
            "threat_types": null
        }
    }
}

Error Handling

If there is an error in fetching the IP details, the API will return a JSON response with error set to true and the data field containing the error details.

Example Error Response:

{
    "error": true,
    "data": "{\"error\":\"IP address not found\"}"
}

License

This project is licensed under the MIT License.

Acknowledgements

  • MaxMind GeoLite2
  • geo-tz
  • ip-api

Powered By glitchfy

ipfinder's People

Contributors

thuyiya avatar

Watchers

 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.