GithubHelp home page GithubHelp logo

ip_location's Introduction

IP Location

Fetches the latitude and longitude of a given IP address from IPStack.

 Usage: main.py [OPTIONS] [IP_ADDRESS]                                                                                                                                                                         
                                                                                                                                                                                                               
╭─ Arguments ──────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│   ip_address      [IP_ADDRESS]    The IP address to query. Omit or use '-' to read from stdin.                       │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --api-key                   TEXT  Your IPStack API key. Can also be provided via IPSTACK_API_KEY environment variable│
│ --help                            Show this message and exit.                                                        │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Example usage:

docker run -it --rm ip_location 8.8.8.8

Example output:

40.5369987487793,-82.12859344482422

Security Notice

The IPstack free plan does not allow https requests. Responses from IPStack could be manipulated by a man-in-the-middle attack.

Setup

Sign up for an IPStack API key if you haven't already at https://ipstack.com.

Create .env and add your API key.

touch .env
echo "IPSTACK_API_KEY=your_api_key" >> .env

Run with Docker

Build the image using:

docker build -t ip_location .

Run the container to get the coordinates for an IP address (replace 8.8.8.8 with your choice of IP):

docker run -it --rm ip_location 8.8.8.8

To pass an API key as an environment variable (replace 8.8.8.8 with your choice of IP):

docker run -e "IPSTACK_API_KEY=your_api_key" -it --rm ip_location 8.8.8.8

Library Choices

  • Typer: Easier to use than the builtin argparse.
  • HTTPX: Easier to use than the builtin urllib.
  • python-dotenv: Allows the use of a .env to set environment variables.
  • Pydantic: Robust parser and data validator.

ip_location's People

Contributors

robbyronk avatar

Watchers

 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.