ipagent is a FastAPI dependency for extracting client IP address, device, browser, and geo-location data effortlessly.
ipagent makes it simple to access detailed client metadata in your FastAPI endpoints, including:
- Automatically detects client IP
- Fetches geolocation info using the IP address
- Device and browser information
- Operating system
- Geolocation (city and country)
- Minimal and easy-to-use FastAPI dependency
This package provides a plug-and-play Depends function that integrates smoothly into any FastAPI project.
pip install ipagentfrom ipagent import get_client_info, ClientInfo
from fastapi import FastAPI, Depends
app = FastAPI()
@app.get('/')
async def user_data(user: ClientInfo = Depends(get_client_info)):
return user{
"ip_client": "31.110.210.10",
"device_type": "Desktop",
"browser": "Safari",
"browser_version": "18.1",
"os": "Mac OS X",
"os_version": "10.15.7",
"country": "Uzbekistan",
"region": "Tashkent",
"city": "Tashkent",
"latitude": 49.2615,
"longitude": 61.2177,
"timezone": "Asia/Tashkent",
"postal": null,
"org": "UNITEL LLC"
}We believe ipagent can grow into a powerful, flexible client metadata toolkit. Here are some feature ideas and
improvements we’re excited about — and if you’d like to contribute, we’d be happy to collaborate!
We’d love to see your ideas in action! Here’s how you can fork the project, add a new feature, and open a pull request:
Go to github.com/allncuz/ipagent and click the Fork button to create your own copy.
git clone https://github.com/your-username/ipagent.git
cd ipagentTogether, let’s make ipagent the most useful and elegant client metadata tool for FastAPI developers.