portmap
Scrape the Wikipedia list of TCP/UDP port numbers into a local NDJSON database with revision tracking. Only fetches from Wikipedia when the article has actually changed.
Install
pip install portmapper
Python Library
from portmap import PortMap
pm = PortMap(data_dir='~/.local/share/portmap')
# Fetch/update from Wikipedia (only if stale)
records = pm.update()
# Force a fresh pull
records = pm.update(force=True)
# Load cached data without hitting the network
records = pm.load()
# Look up specific ports — returns matching record dicts
results = pm.lookup(80, 443, 6667)
# Search descriptions by keyword
results = pm.search('minecraft')
# Fetch the last year of revision history
revisions = pm.history(days=365)
Every method returns plain list[dict] values you can work with directly:
for rec in pm.lookup(22, 80):
port = rec['port'] # int or "start-end" str
for svc in rec['services']:
print(port, svc['tcp'], svc['udp'], svc['description'])
CLI Usage
| Flag | Description |
|---|---|
ports |
Comma-separated port numbers to look up |
-s TERM |
Search descriptions for a keyword |
-j |
Output as NDJSON (pipeable to jq) |
-md |
Output as Markdown (ports + history) |
-u |
Force update from Wikipedia |
-d |
Enable debug logging |
--data-dir DIR |
Directory for data files (default: .) |
--history [DAYS] |
Fetch revision history (default: 365 days) |
--serve |
Start the JSON API server |
--host ADDR |
API bind address (default: 127.0.0.1) |
--port PORT |
API bind port (default: 6660) |
Examples
# Look up ports
portmap 80,443,6667
# Search for a keyword
portmap -s irc
# NDJSON output (pipe to jq)
portmap 80,443 -j
# Store data in a custom directory
portmap -u --data-dir ~/.local/share/portmap
# Fetch revision history
portmap --history 365
# Start the API server
portmap --serve
# Bind to a specific address and port
portmap --serve --host 0.0.0.0 --port 8080
API Server
Start with portmap --serve. Binds to 127.0.0.1:6660 by default.
| Endpoint | Description |
|---|---|
GET / |
API info and available endpoints |
GET /ports |
All ports (query: ?search=TERM&limit=N&offset=N) |
GET /ports/80,443 |
Lookup specific ports (comma-separated, 0–65535) |
GET /history |
Revision history (query: ?limit=N&offset=N) |
curl -s localhost:6660/ports/22,80 | jq .
curl -s 'localhost:6660/ports?search=irc&limit=10' | jq .
curl -s 'localhost:6660/history?limit=5' | jq .
Output
PORT TCP UDP SCTP DCCP DESCRIPTION
────────────────────────────────────────────────────────────────────────
80 Yes Yes Yes -- Hypertext Transfer Protocol (HTTP) uses TCP in versions 1.x and 2.
443 Yes Yes Yes -- Hypertext Transfer Protocol Secure (HTTPS) uses TCP in versions 1.x and 2.
6665-6669 Yes -- -- -- Internet Relay Chat (IRC)
Mirrors: SuperNETs • GitHub • GitLab • Codeberg
Metadata
Release files for portmapper 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| portmapper-1.0.4.tar.gz | 13.3 kB | Without provenance | Details for portmapper-1.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| portmapper-1.0.4-py3-none-any.whl | Python 3 | none | any | Details for portmapper-1.0.4-py3-none-any.whl |
Total release size: 27.6 kB
Release files / portmapper-1.0.4.tar.gz
| Download URL | portmapper-1.0.4.tar.gz |
|---|---|
| Size | 13.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
076a14c4e2c354d1759dbd55c028f18ec86caa81f6920befa222e79207ede439
|
|
BLAKE2b-256 checksum How to use checksums |
f70dacbd0f301e5c28ee1fafc11a0ab79c99dbfd54afec9a1e3874e3b6940d88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / portmapper-1.0.4-py3-none-any.whl
| Download URL | portmapper-1.0.4-py3-none-any.whl |
|---|---|
| Size | 14.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9e566919e052ec3cc5c8c2744d3aba0b86eb203fdb45cb2c8dd62d9d05f0582d
|
|
BLAKE2b-256 checksum How to use checksums |
4714ae390ca48cb2da2d08aa642b598f620769ae0a391489972664dcc6da9980
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for portmapper 1.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.