Scrape TCP/UDP port assignments from Wikipedia into a local NDJSON database
Project description
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 portmap
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
Project details
Release history Release notifications | RSS feed
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 portmapper-1.0.3.tar.gz.
File metadata
- Download URL: portmapper-1.0.3.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 |
10e7e576a431302708f3e8c87a1b52bc64206c7f273292f9dcb2264129655ac6
|
|
| MD5 |
e647ac448887fdee1519619b3f90afb6
|
|
| BLAKE2b-256 |
4dad2cc19332bf869c34ad41e4442fe5f92bee0fa8fdc6626192d49f74ca35be
|
File details
Details for the file portmapper-1.0.3-py3-none-any.whl.
File metadata
- Download URL: portmapper-1.0.3-py3-none-any.whl
- Upload date:
- Size: 14.2 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 |
8dca70fa33e7973a9f992805a70c4940d2f33676fcaaea1d85595daa802cc4e1
|
|
| MD5 |
090f11e8d02c9a293312cfb85df779fa
|
|
| BLAKE2b-256 |
c339f30b5f818dcbbfa3de0b2d20a2abd5f21f86c93b7aefe667dac6562f26ba
|