ASGI middleware that logs every IP's geolocation, last visit, reverse DNS and much more!
Project description
WTMA: Who touched my app?
WTMA is an ASGI middleware purposed to log every IP on your web app with detailed info. Version: 0.1.0
Features
- Geolocation logging: Log every IP with their geolocation data, such as country, continent. region and city.
- Proxy checking: Verify whether IPs were associated with proxies.
- Hosting checking: Verify whether IPs were associated with hosting and datacenters.
- Last visit: View the dynamic and exact time when an IP hit your app.
- Multiple formats: Log data in either JSON or TOML format.
- Console logging: View brief IP info in the console as well.
- Framework support: Supports all ASGI frameworks (FastAPI, Starlette etc.)
Quickstart
Install the wtma python package
pip install wtma
Implement it to your app
FastAPI exmaple:
from fastapi import FastAPI
from wtma import WTMA
app = FastAPI()
@app.get("/")
def root():
return {
"message": "Hello, world!"
}
# Wrap the app at the end
app = WTMA(app, log_path="log.json", file_format="JSON", log_to_console=True)
Also, here's the signature of the constructor method:
def __init__(self, app, log_path: str, file_format:Literal["JSON", "TOML"]="JSON", log_to_console:bool=True):
[!NOTE] It's recommended to wrap the app with
WTMAclass at the end instead of usingadd_middlewarebecause Starlette, which FastAPI is built on top of, suppresses exceptions raised in middleware's initialization, making it difficult to debug.
Log samples
JSON
{
"1.1.1.1": {
"country": "Australia",
"continent": "Oceania",
"city": "South Brisbane",
"region": "QLD",
"is_proxy": false,
"is_hosting": true,
"is_mobile": false,
"reverseDNS": "one.one.one.one",
"last_seen": "2026-03-08 15:54:05.067613+00:00"
}
}
TOML
["1.1.1.1"]
country = "Australia"
continent = "Oceania"
city = "South Brisbane"
region = "QLD"
is_proxy = false
is_hosting = true
is_mobile = false
reverseDNS = "one.one.one.one"
last_seen = "2026-03-08 15:54:05.067613+00:00"
Data source
WTMA uses ip-api.com as its data source. The data returned may contain errors or be inaccurate.
If you found this project useful, please consider giving it a star!
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wtma-0.1.4.tar.gz.
File metadata
- Download URL: wtma-0.1.4.tar.gz
- Upload date:
- Size: 15.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
496d8ac6b2286e73b245b7ca37dc29394f9df1523372eb51be52bcb420f3b6ad
|
|
| MD5 |
cd3b8338e83c0ebb485a8ba8ac1ff577
|
|
| BLAKE2b-256 |
c8a5ea8fef888c6042b2e4ec2b196bd23db62f896f64ba9f6d7b14302a41fdfc
|
Provenance
The following attestation bundles were made for wtma-0.1.4.tar.gz:
Publisher:
python-publish.yml on sudeep-alt/wtma
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wtma-0.1.4.tar.gz -
Subject digest:
496d8ac6b2286e73b245b7ca37dc29394f9df1523372eb51be52bcb420f3b6ad - Sigstore transparency entry: 1065126827
- Sigstore integration time:
-
Permalink:
sudeep-alt/wtma@d63cd82c10362b796b2c97654e21462d059a8f91 -
Branch / Tag:
refs/tags/0.1.4 - Owner: https://github.com/sudeep-alt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d63cd82c10362b796b2c97654e21462d059a8f91 -
Trigger Event:
release
-
Statement type:
File details
Details for the file wtma-0.1.4-py3-none-any.whl.
File metadata
- Download URL: wtma-0.1.4-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd41d61aeac1685902e33c4481990929ca7ef2bace8c42f0a1e7ce50a9c7dfd3
|
|
| MD5 |
90a25b47e8dcb7fe58428f34265b3af0
|
|
| BLAKE2b-256 |
da76d244274e6b96a00feca1dd28079a557cee360740e6959e7c8ed6fa0d4cdf
|
Provenance
The following attestation bundles were made for wtma-0.1.4-py3-none-any.whl:
Publisher:
python-publish.yml on sudeep-alt/wtma
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wtma-0.1.4-py3-none-any.whl -
Subject digest:
bd41d61aeac1685902e33c4481990929ca7ef2bace8c42f0a1e7ce50a9c7dfd3 - Sigstore transparency entry: 1065126828
- Sigstore integration time:
-
Permalink:
sudeep-alt/wtma@d63cd82c10362b796b2c97654e21462d059a8f91 -
Branch / Tag:
refs/tags/0.1.4 - Owner: https://github.com/sudeep-alt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@d63cd82c10362b796b2c97654e21462d059a8f91 -
Trigger Event:
release
-
Statement type: