Skip to main content

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.)
  • Log continuation: Continue logging in the same file after app restart

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 WTMA class at the end instead of using add_middleware because 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

wtma-0.1.5.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wtma-0.1.5-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file wtma-0.1.5.tar.gz.

File metadata

  • Download URL: wtma-0.1.5.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

Hashes for wtma-0.1.5.tar.gz
Algorithm Hash digest
SHA256 0a8925e8db37ed55dc97ce64da00e26edd3bf2064521b27267f9828896ccef4a
MD5 32d6c65fd6e1ce0381a7a2ece002c625
BLAKE2b-256 47a977f4171e57a6cbe58efdf6ccda659e3fb3c5a3f82b2fa3790f7bbb1ac907

See more details on using hashes here.

Provenance

The following attestation bundles were made for wtma-0.1.5.tar.gz:

Publisher: python-publish.yml on sudeep-alt/wtma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wtma-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: wtma-0.1.5-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

Hashes for wtma-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7e092d72422edad21b39a35465c5c5b2ef87e4b1036ae02df5c023290d9f86ec
MD5 cf4c90c38e8e083384491f13010fcdf3
BLAKE2b-256 a7d4adc9d1c7422dcf3a920c680a7caea7d692a7b321fd890f60805a7a01ae8a

See more details on using hashes here.

Provenance

The following attestation bundles were made for wtma-0.1.5-py3-none-any.whl:

Publisher: python-publish.yml on sudeep-alt/wtma

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page