Package: checkip
CheckIPResolves public (WAN) IP from supported providers.ProvidersCodeURLcloudflarehttps://cloudflare.com/cdn-cgi/tracedyndnshttp://checkip.dyndns.org/freednshttps://freedns.afraid.org/dynamic/check.phpgoogledomainshttps://domains.google.com/checkiphehttp://checkip.dns.he.net/httpbinhttps://httpbin.org/ipip4onlyhttp://ip4only.me/api/ipfyhttps://api.ipify.org/loopiahttp://dns.loopia.se/checkip/checkip.phpmyiphttps://api.myip.commyonlineportalhttps://myonlineportal.net/checkipnoiphttp://ip1.dynupdate.no-ip.com/nsupdatehttp://ipv4.nsupdate.info/myipzoneedithttp://dynamic.zoneedit.com/checkip.htmlInstallationpipinstallcheckipUsageGet IPUse provider's code to fetch your public IP from that provider.fromcheckipimportget_ipget_ip('cloudflare')Resolve IPUse multiple provider's codes to resolve your most commonly returned public IP.fromcheckipimportresolve_ipresolve_ip(['cloudflare','dyndns','freedns'])Register Custom ProviderYou can create your own custom providers by extending theBaseProviderbase class.Attributecodemust 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:Define attributeURLon your custom provider class. By default the IP address will be parsed from that URL's response.fromcheckip.providersimportBaseProvider,register_providerfromcheckipimportget_ipclassMyProvider(BaseProvider):code='myprovider'url='https://example.com/ip'register_provider(MyProvider)get_ip('myprovider')Overwrite the provider'sget_ipmethod for even more customization:fromcheckip.providersimportBaseProvider,register_providerfromcheckipimportget_ipclassMyProvider(BaseProvider):code='myprovider'defget_ip(self):response=requests.get('https://example.com/ip.json')response.raise_for_status()returnresponse.json()['ip']register_provider(MyProvider)get_ip('myprovider')CLI UsageGet IPUse provider's code to fetch your public IP from that provider.$checkipgetcloudflareResolve IPUse multiple provider's codes to resolve your most commonly returned public IP.$checkipresolvecloudflaredyndnsfreednsLicenseCheckIPis a free software under terms of theMIT License.Copyright (C) 2021 byToni Sredanović,toni.sredanovic@gmail.comPermission 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.