port-detective Python SDK
A lightweight subprocess client for the port-detective CLI. It provides synchronous
and asyncio APIs for port diagnostics, project fingerprinting, and safe cleanup on
Windows, macOS, and Linux.
Install
After a release:
python -m pip install port-detective
From a checkout:
python -m pip install ./python
go build -o port-detective .
The package does not bundle the Go executable. Put a matching CLI on PATH, set
PORT_DETECTIVE_BIN, or pass binary_path to an API call. Keep SDK and CLI versions
aligned because the SDK consumes the CLI JSON contract.
Quickstart
from port_detective import inspect_port, scan_ports, free_port, clean_project
diagnostic = inspect_port(8080)
occupied = scan_ports([3000, 5173, 8080])
preview = free_port(3000, dry_run=True)
project_listeners = clean_project(dry_run=True)
print(diagnostic.status, len(occupied), preview.message, len(project_listeners))
All calls accept an optional timeout in seconds. Process actions default to dry-run;
set dry_run=False only after reviewing the target.
Async API
import asyncio
from port_detective import async_inspect_port, async_scan_ports
async def main():
diagnostic, ports = await asyncio.gather(
async_inspect_port(3000),
async_scan_ports(),
)
print(diagnostic.status, len(ports))
asyncio.run(main())
Models
PortDiagnostic includes port, is_open, protocol, pid,
process_name, cmdline, memory_mb, cpu_percent, status, and optional
project metadata. ProjectInfo includes name, framework, path, and
version.
See the API reference, platform support policy, and quality review for release constraints.
License
MIT.
Metadata
Release files for port-detective 1.1.0
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 |
|---|---|---|---|---|
| port_detective-1.1.0.tar.gz | 8.8 kB | With provenance | Details for port_detective-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| port_detective-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for port_detective-1.1.0-py3-none-any.whl |
Total release size: 15.7 kB
Release files / port_detective-1.1.0.tar.gz
| Download URL | port_detective-1.1.0.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f3a21da034e54cf5c5b9baf90c5c4321331abbae0726c4a1d9a1dd7c065e7d1e
|
|
BLAKE2b-256 checksum How to use checksums |
abb4676aba5533063a22bf4ec87d38694cb0e7c409cab7c9e5affb6aa86d6e79
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logRelease files / port_detective-1.1.0-py3-none-any.whl
| Download URL | port_detective-1.1.0-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
05c180f2c4a845147b06c7b2d6e4821b42f5707459176d12cbb357892646e140
|
|
BLAKE2b-256 checksum How to use checksums |
0af4c7310e6873de8ed9a71577332c9121fb6680835e3b4a057e3b522648ff3d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logSecurity for port-detective 1.1.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for port_detective-1.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logA 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.