- Notifications
You must be signed in to change notification settings - Fork12
A completely free IP address API
License
NotificationsYou must be signed in to change notification settings
ipqwery/ipapi-py
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A Python library to query IP addresses using theipquery.io API. This library allows you to easily retrieve detailed information about IP addresses, including ISP data, geolocation details, and risk analysis.
- Query detailed information for a specific IP address.
- Fetch your own public IP address.
- Perform bulk queries for multiple IP addresses.
- Includes Pydantic models for easy data validation and parsing.
Install the package using pip:
pip install ipcore
fromipapi.clientimportIPAPIClient
Fetch information about a specific IP address:
fromipapi.clientimportIPAPIClientclient=IPAPIClient()ip_info=client.query_ip("8.8.8.8")print(ip_info)
fromipapi.clientimportAsyncIPAPIClientasyncdefmain():client=AsyncIPAPIClient()ip_info=awaitclient.query_ip("8.8.8.8")print(ip_info)if__name__=="__main__":importasyncioasyncio.run(main())
IPInfo(ip='8.8.8.8', isp=ISPInfo(asn='AS15169', org='Google LLC', isp='Google LLC'),location=LocationInfo(country='United States', country_code='US', city='Mountain View',state='California', zipcode='94035', latitude=37.386, longitude=-122.0838, timezone='America/Los_Angeles', localtime='2024-11-09T12:45:32'),risk=RiskInfo(is_mobile=False, is_vpn=False, is_tor=False, is_proxy=False, is_datacenter=True, risk_score=0))
Retrieve your machine's public IP address:
ip=client.query_own_ip()print(f"Your IP:{ip}")
Your IP: 203.0.113.45
Fetch details for multiple IP addresses in a single request:
ips= ["8.8.8.8","1.1.1.1"]results=client.query_bulk(ips)forip_infoinresults:print(ip_info)
IPInfo(ip='8.8.8.8', ...)IPInfo(ip='1.1.1.1', ...)
If you want to run tests to verify functionality:
pytest tests/
- Python 3.7+
- Pydantic 2.x
- httpx
This project is licensed under the MIT License. See theLICENSE file for more information.
About
A completely free IP address API
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Packages0
No packages published
Contributors3
Uh oh!
There was an error while loading.Please reload this page.