ipify2


Nameipify2 JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://github.com/nwithan8/ipify2
SummaryGet IP address information via ipify.org
upload_time2023-09-20 20:13:05
maintainer
docs_urlNone
authorNate Harris
requires_python>=3.0
licenseUNLICENSE
keywords python api client ipify ipify2 ip address public ipv4 ipv6 service
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ipify2
============

An updated unofficial clone of the now-deprecated `ipify` library, allowing you to determine your IPv4 and IPv6 programmatically via [ipify.org](https://www.ipify.org)

.. image:: https://img.shields.io/pypi/v/ipify2.svg
    :alt: ipify2 Release
    :target: https://pypi.python.org/pypi/ipify2

.. image:: https://img.shields.io/pypi/dm/ipify2.svg
    :alt: ipify2 Downloads
    :target: https://pypi.python.org/pypi/ipify2


Meta
----

### Original

- Author: Randall Degges
- Email: r@rdegges.com
- Site: http://www.rdegges.com

### Maintainer

- Author: Nate Harris
- Email: n8gr8gbln@gmail.com
- Site: https://nateharr.is


Purpose
-------

[ipify.org](https://www.ipify.org) is a reliable IP address lookup service, an easy way to get your public IP address in Python.

This library will retrieve your public IP address from ipify's API service, and return it as a string.

Additional features:

- If a request fails for any reason, it is re-attempted 3 times using an exponential backoff algorithm for maximum effectiveness.
- This library handles exceptions properly, and usage examples below show you how to deal with errors in a foolproof way.
- This library only makes API requests over HTTPS.


Installation
------------

To install ``ipify2``, simply run:

```shell
pip install ipify2
```

This will install the latest version of the library automatically.


Usage
-----

Using this library is very simple.  Here's a simple example:

```python
from ipify2 import get_ipv4

ip = get_ipv4()
print(ip) # '96.41.136.144'
```

```python
from ipify2 import get_ipv6
ip = get_ipv6()
print(ip) # '2001:0db8:85a3:0000:0000:8a2e:0370:7334'
```

### Error Handling
There are several reasons a request fail:
- The ipify service is down
- Your machine is unable to get the request to ipify because of a network error
  of some sort (DNS, no internet, etc.).

To handle these errors, you can do the following:

```python
from ipify2 import get_universal_ip
from ipify2.exceptions import ConnectionError, ServiceError

try:
    ip = get_universal_ip()
except ConnectionError:
    # If you get here, it means you were unable to reach the ipify service,
    # most likely because of a network error on your end.
except ServiceError:
    # If you get here, it means ipify is having issues, so the request
    # couldn't be completed :(
except:
    # Something else happened (non-ipify related). Maybe you hit CTRL-C
    # while the program was running, the kernel is killing your process, or
    # something else all together.
```

If you want to simplify the above error handling by catching all errors, you could also do the following:

```python
from ipify2 import get_universal_ip
from ipify2.exceptions import IpifyException

try:
    ip = get_universal_ip()
except IpifyException:
    # If you get here, then some ipify exception occurred.
except:
    # If you get here, some non-ipify related exception occurred.
```

One thing to keep in mind: regardless of how you decide to handle exceptions,  the ipify library will retry any failed requests 3 times before ever raising exceptions -- so if you *do* need to handle exceptions, just remember that retry logic has already been attempted.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/nwithan8/ipify2",
    "name": "ipify2",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.0",
    "maintainer_email": "",
    "keywords": "Python,API,client,ipify,ipify2,ip,address,public,ipv4,ipv6,service",
    "author": "Nate Harris",
    "author_email": "n8gr8gbln@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/8e/99/037f7c32de8ac892b4479266890ab73b94e44e24f4093b424c8877884b91/ipify2-1.1.0.tar.gz",
    "platform": null,
    "description": "ipify2\n============\n\nAn updated unofficial clone of the now-deprecated `ipify` library, allowing you to determine your IPv4 and IPv6 programmatically via [ipify.org](https://www.ipify.org)\n\n.. image:: https://img.shields.io/pypi/v/ipify2.svg\n    :alt: ipify2 Release\n    :target: https://pypi.python.org/pypi/ipify2\n\n.. image:: https://img.shields.io/pypi/dm/ipify2.svg\n    :alt: ipify2 Downloads\n    :target: https://pypi.python.org/pypi/ipify2\n\n\nMeta\n----\n\n### Original\n\n- Author: Randall Degges\n- Email: r@rdegges.com\n- Site: http://www.rdegges.com\n\n### Maintainer\n\n- Author: Nate Harris\n- Email: n8gr8gbln@gmail.com\n- Site: https://nateharr.is\n\n\nPurpose\n-------\n\n[ipify.org](https://www.ipify.org) is a reliable IP address lookup service, an easy way to get your public IP address in Python.\n\nThis library will retrieve your public IP address from ipify's API service, and return it as a string.\n\nAdditional features:\n\n- If a request fails for any reason, it is re-attempted 3 times using an exponential backoff algorithm for maximum effectiveness.\n- This library handles exceptions properly, and usage examples below show you how to deal with errors in a foolproof way.\n- This library only makes API requests over HTTPS.\n\n\nInstallation\n------------\n\nTo install ``ipify2``, simply run:\n\n```shell\npip install ipify2\n```\n\nThis will install the latest version of the library automatically.\n\n\nUsage\n-----\n\nUsing this library is very simple.  Here's a simple example:\n\n```python\nfrom ipify2 import get_ipv4\n\nip = get_ipv4()\nprint(ip) # '96.41.136.144'\n```\n\n```python\nfrom ipify2 import get_ipv6\nip = get_ipv6()\nprint(ip) # '2001:0db8:85a3:0000:0000:8a2e:0370:7334'\n```\n\n### Error Handling\nThere are several reasons a request fail:\n- The ipify service is down\n- Your machine is unable to get the request to ipify because of a network error\n  of some sort (DNS, no internet, etc.).\n\nTo handle these errors, you can do the following:\n\n```python\nfrom ipify2 import get_universal_ip\nfrom ipify2.exceptions import ConnectionError, ServiceError\n\ntry:\n    ip = get_universal_ip()\nexcept ConnectionError:\n    # If you get here, it means you were unable to reach the ipify service,\n    # most likely because of a network error on your end.\nexcept ServiceError:\n    # If you get here, it means ipify is having issues, so the request\n    # couldn't be completed :(\nexcept:\n    # Something else happened (non-ipify related). Maybe you hit CTRL-C\n    # while the program was running, the kernel is killing your process, or\n    # something else all together.\n```\n\nIf you want to simplify the above error handling by catching all errors, you could also do the following:\n\n```python\nfrom ipify2 import get_universal_ip\nfrom ipify2.exceptions import IpifyException\n\ntry:\n    ip = get_universal_ip()\nexcept IpifyException:\n    # If you get here, then some ipify exception occurred.\nexcept:\n    # If you get here, some non-ipify related exception occurred.\n```\n\nOne thing to keep in mind: regardless of how you decide to handle exceptions,  the ipify library will retry any failed requests 3 times before ever raising exceptions -- so if you *do* need to handle exceptions, just remember that retry logic has already been attempted.\n\n\n",
    "bugtrack_url": null,
    "license": "UNLICENSE",
    "summary": "Get IP address information via ipify.org",
    "version": "1.1.0",
    "project_urls": {
        "Download": "https://github.com/nwithan8/ipify2/archive/1.1.0.tar.gz",
        "Homepage": "https://github.com/nwithan8/ipify2"
    },
    "split_keywords": [
        "python",
        "api",
        "client",
        "ipify",
        "ipify2",
        "ip",
        "address",
        "public",
        "ipv4",
        "ipv6",
        "service"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ed1110fe882cd3b49344245b778e7285b8a25237ebb57dd4a0f6c9099c71e608",
                "md5": "893cbade6455c20886ef87b36e48d66a",
                "sha256": "7bf03bb7984ce14782a7cb707a77d6c777b97f5c06a2f0939a8a130de674462e"
            },
            "downloads": -1,
            "filename": "ipify2-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "893cbade6455c20886ef87b36e48d66a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.0",
            "size": 5932,
            "upload_time": "2023-09-20T20:13:04",
            "upload_time_iso_8601": "2023-09-20T20:13:04.428603Z",
            "url": "https://files.pythonhosted.org/packages/ed/11/10fe882cd3b49344245b778e7285b8a25237ebb57dd4a0f6c9099c71e608/ipify2-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8e99037f7c32de8ac892b4479266890ab73b94e44e24f4093b424c8877884b91",
                "md5": "76ab0321d843edfe87ec18b85d505e34",
                "sha256": "4210044443ee3924a41d38a33ee138e64d495deeec903cb08ba76696d7a77f35"
            },
            "downloads": -1,
            "filename": "ipify2-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "76ab0321d843edfe87ec18b85d505e34",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.0",
            "size": 5798,
            "upload_time": "2023-09-20T20:13:05",
            "upload_time_iso_8601": "2023-09-20T20:13:05.926808Z",
            "url": "https://files.pythonhosted.org/packages/8e/99/037f7c32de8ac892b4479266890ab73b94e44e24f4093b424c8877884b91/ipify2-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-20 20:13:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "nwithan8",
    "github_project": "ipify2",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "ipify2"
}
        
Elapsed time: 1.12903s