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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
portmapper-1.0.4.tar.gz
(13.3 kB
view details)
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 portmapper-1.0.4.tar.gz.
File metadata
- Download URL: portmapper-1.0.4.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
076a14c4e2c354d1759dbd55c028f18ec86caa81f6920befa222e79207ede439
|
|
| MD5 |
ef89ced1ec0b1149c8ecee33b545001e
|
|
| BLAKE2b-256 |
f70dacbd0f301e5c28ee1fafc11a0ab79c99dbfd54afec9a1e3874e3b6940d88
|
File details
Details for the file portmapper-1.0.4-py3-none-any.whl.
File metadata
- Download URL: portmapper-1.0.4-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e566919e052ec3cc5c8c2744d3aba0b86eb203fdb45cb2c8dd62d9d05f0582d
|
|
| MD5 |
a3f705dbe7f53f12d86fb6130fbb106e
|
|
| BLAKE2b-256 |
4714ae390ca48cb2da2d08aa642b598f620769ae0a391489972664dcc6da9980
|