Skip to main content

Resolves public (WAN) IP from supported providers.

Project description

CheckIP

Resolves public (WAN) IP from supported providers.

Providers

Code URL
cloudflare https://cloudflare.com/cdn-cgi/trace
dyndns http://checkip.dyndns.org/
freedns https://freedns.afraid.org/dynamic/check.php
googledomains https://domains.google.com/checkip
he http://checkip.dns.he.net/
httpbin https://httpbin.org/ip
ip4only http://ip4only.me/api/
ipfy https://api.ipify.org/
loopia http://dns.loopia.se/checkip/checkip.php
myip https://api.myip.com
myonlineportal https://myonlineportal.net/checkip
noip http://ip1.dynupdate.no-ip.com/
nsupdate http://ipv4.nsupdate.info/myip
zoneedit http://dynamic.zoneedit.com/checkip.html

Installation

pip install checkip

Usage

Get IP

Use provider's code to fetch your public IP from that provider.

from checkip import get_ip

get_ip('cloudflare')

Resolve IP

Use multiple provider's codes to resolve your most commonly returned public IP.

from checkip import resolve_ip

resolve_ip(['cloudflare', 'dyndns', 'freedns'])

Register Custom Provider

You can create your own custom providers by extending the BaseProvider base class.

Attribute code must be defined on each custom provider which can not match any already registered code.

To succesfully get an IP from a custom provider you can either:

  1. Define attribute URL on your custom provider class. By default the IP address will be parsed from that URL's response.
from checkip.providers import BaseProvider, register_provider
from checkip import get_ip

class MyProvider(BaseProvider):
    code = 'myprovider'
    url = 'https://example.com/ip'

register_provider(MyProvider)

get_ip('myprovider')
  1. Overwrite the provider's get_ip method for even more customization:
from checkip.providers import BaseProvider, register_provider
from checkip import get_ip

class MyProvider(BaseProvider):
    code = 'myprovider'
    
    def get_ip(self):
        response = requests.get('https://example.com/ip.json')
        response.raise_for_status()
        return response.json()['ip']

register_provider(MyProvider)

get_ip('myprovider')

CLI Usage

Get IP

Use provider's code to fetch your public IP from that provider.

$ checkip get cloudflare

Resolve IP

Use multiple provider's codes to resolve your most commonly returned public IP.

$ checkip resolve cloudflare dyndns freedns

License

CheckIP is a free software under terms of the MIT License.

Copyright (C) 2021 by Toni Sredanović, toni.sredanovic@gmail.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

checkip-1.2.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

checkip-1.2.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file checkip-1.2.0.tar.gz.

File metadata

  • Download URL: checkip-1.2.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.7.9

File hashes

Hashes for checkip-1.2.0.tar.gz
Algorithm Hash digest
SHA256 e68b67ac82b27a12a8bc3e5778e578a390eb7de88a2888b256d7a4c8a15684e4
MD5 fad60678d42422b32b03d143018b2751
BLAKE2b-256 eceadd0a0efd09c1674569a473361a3c916a32575a4d80aad10ce41575eb3944

See more details on using hashes here.

File details

Details for the file checkip-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: checkip-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.7.9

File hashes

Hashes for checkip-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eebff86bc9ee2487069bd9bd4b47d2c83672578b8786b6d45c83c0afb22e5177
MD5 8c97d26278a327a6ac888df832415f30
BLAKE2b-256 e6fda2043ad1d3fdc5d34ff8187f518ad954f7fd05099ee89b64d5ec4ac2c03f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page