# pkgscan.dev HTTP API

Base URL: `https://www.pkgscan.dev`

All API responses are JSON. Public report pages and their `GET` endpoints need
no account; starting a scan needs one. This document is the machine-readable
contract for scripts and CI — the interactive developer docs are at
<https://www.pkgscan.dev/docs#developers/api>.

## Authentication

Send an API key on every request:

```
Authorization: Bearer pkg_YOUR_KEY
```

Create up to five keys in Settings on a paid plan. A key is shown once, at
creation, and cannot be read again. The signed-in web app uses its session
cookie instead of a key. Keys stop working if the plan returns to Free and work
again after re-subscribing.

## Quotas and rate limits

| Plan | Scans per calendar month |
|---|---|
| Free | 5 |
| Hunter | 100 |
| Operator | 500 |
| Team | 1,000 |
| Enterprise | Custom |

A quota unit is charged when a scan request is accepted. A request that reuses
an existing report for the same artifact is returned without charging again.
Requests over the plan limit return `402` with `{"error":"quota_exceeded"}` or
`{"error":"free_scan_used"}`.

Scan-start endpoints are limited to 20 requests per minute per IP and 10 per
minute per account. Exceeding either returns `429`:

```json
{ "error": "rate_limited", "message": "Too many requests — please slow down." }
```

## Start a scan

All scan endpoints return `{ jobId, sha256?, purl?, permalink?, status?, ... }`.
Poll `GET /api/scan/{jobId}` until `status` is `completed` or `error`.

| Method | Endpoint | Body |
|---|---|---|
| POST | `/api/scan` | `multipart/form-data` with the artifact file |
| POST | `/api/scan/from-generic-purl` | `{"purl":"pkg:npm/lodash@4.17.21"}` |
| POST | `/api/scan/from-purl` | `{"publisher","name","version","repositoryUrl"?}` for VS Code extensions |
| POST | `/api/scan/from-hash` | `{"sha256":"<64 hex>"}` — reputation lookup, no upload |
| POST | `/api/scan/rescan` | Package identity, `{"purl":"..."}`, or `{"sha256":"..."}` |

`from-generic-purl` accepts npm, PyPI, gem, cargo, maven, nuget, and golang
PURLs. The version is required when starting a scan; the report endpoints below
also accept a versionless PURL and resolve the newest scan.

## Read results

| Method | Endpoint | Notes |
|---|---|---|
| GET | `/api/scan/{jobId}` | Live status, engines, findings |
| GET | `/api/file/{sha256}` | Newest report for a file digest |
| GET | `/api/pkg/{type}/{name}@{version}` | Package report; `vscode-extension` uses `/{publisher}/{name}@{version}` |
| GET | `/api/pkg/{type}/{name}` | Newest scanned version of the package |
| GET | `/api/packages/search?ecosystem=&q=` | Registry typeahead |
| GET | `/api/packages/versions?ecosystem=&name=` | Published versions |
| GET | `/api/search?q=` | Cross-registry package search |
| GET | `/api/scans` | The authenticated account's scan history |

`/api/pkg/{type}/{name}` and `@latest` resolve the same newest report the
crawler page and the README badge show. A package with no scan returns
`status: "unscanned"`; a name or PURL the registry could never publish
(`!!bad!!`) returns `400 invalid_purl`.

`/api/search?q=` resolves a hash or PURL to its report path and includes the
found scan's `verdict`, `flaggedCount`, `reportedCount` and `coverage`, so a
gate does not have to follow the link to answer "is this bad". `reportedCount`
is the roster size (done + errored + unsupported), not a finding count: use
`coverage.reported` for engines that finished, `coverage.warned` for engines
that raised something to review, and `coverage.unsupported` for engines whose
capability profile does not apply to the artifact.

Report endpoints and `/api/search` also return `maliciousVersions[]`: other
scanned versions of the **same package identity** (same PURL type, namespace
and name — plus the same registry for extensions) whose verdict is `malicious`,
each with `version`, `purl`, `path` and `analyzedAt`. On a report the list is
read only for a finished, non-malicious scan of the version being viewed. A
version with no scan of its own still carries it, and an empty array means no
sibling was flagged — not that the package is safe.

Every unscanned response carries the registry check that produced it:

```json
{ "status": "unscanned", "identity": { "status": "missing" } }
```

`identity.status` is `exists` when the registry publishes the name (and the
version, when one was asked for), `missing` when it does not, and `unknown`
when the registry could not be reached. `missing` is scoped to the registry the
URL names — it is not proof the artifact does not exist. A gate can fail on
`missing` without treating an unscanned but real package as a typo. Versionless
lookups check the package name itself.

For VS Code extensions the unscanned response also carries `otherRegistry`:
the same publisher/name/version has a report on the other supported registry
(Marketplace ↔ Open VSX), which is a different artifact and is linked, never
served under this URL:

```json
{
  "status": "unscanned",
  "identity": { "status": "missing", "registry": "VS Code Marketplace" },
  "otherRegistry": {
    "repositoryUrl": "https://open-vsx.org",
    "repositoryLabel": "Open VSX",
    "purl": "pkg:vscode-extension/yeeth/dev-guard@0.1.2?repository_url=https%3A%2F%2Fopen-vsx.org",
    "permalink": "/pkg/vscode-extension/yeeth/dev-guard%400.1.2?repository_url=https%3A%2F%2Fopen-vsx.org"
  }
}
```

`otherRegistry` is `null` when the other registry has no scan of that version
or when the URL has no version. A URL without `repository_url` names the
Visual Studio Marketplace; add the qualifier (or the `?repository_url=` query
parameter) to read the Open VSX report.

Public, no-auth HTML pages: `/pkg/{type}/{name}@{version}` and
`/file/{sha256}`. The README badge is
`/api/badge/{type}/{name}@{version}` (SVG; versionless and `@latest` are
supported).

## Result body

Every report endpoint returns the same result object. Gate on `verdict`; the
other fields say how much of the roster supported it.

| Field | Type | Meaning |
|---|---|---|
| `verdict` | string | `clean`, `suspicious`, `malicious`, `partial`, `unsupported`, `unscanned` or `error`. The single value to gate on. |
| `status` | string | Scan state: `queued`, `scanning`, `completed`, `error` or `unscanned`. Poll until `completed` or `error`. |
| `flaggedCount` | number | Engines whose verdict is `block`. Includes vulnerability engines, so it is not a malware count. |
| `reportedCount` | number | Engines that finished: `done`, `error` or `unsupported`. |
| `coverage` | object | How much of the applicable roster ran. See below. |
| `engines[]` | array | One entry per engine: `id`, `version`, `status`, `verdict`, `findingCount`, and `warnKind` on a warning. |
| `providers[]` | array | Findings per engine: `id`, `version`, `capabilities`, `verdict`, `findings[]`, `startedAt`, `finishedAt`, `error` when one failed. |
| `parentFile` | object | `name`, `size`, `hash` (SHA-256) and `type` when the name has a recognised extension. |
| `sha256`, `purl` | string | Content digest and canonical Package URL. |
| `analyzedAt` | string | When the engines finished. Absent until a scan has finished; never the submission time. |
| `createdAt` | string | When the scan was submitted. Always earlier than `analyzedAt`. |
| `requestedAt` | string | When the newest scan of this artifact was requested. |
| `firstSeen` | string | Earliest scan of this artifact. |
| `related` | object or null | Sibling scanned versions and the publisher link. |
| `maliciousVersions` | array | Other scanned versions of the same package whose verdict is `malicious`: `version`, `purl`, `path`, `analyzedAt`. Empty when none. |
| `package` / `extension` | object or null | Registry identity of the artifact. |
| `platforms[]` | array | Per-build rows for multi-platform extensions: `platform`, `status`, `sha256`, `jobId`, `analyzedAt`. |
| `permalink` | string | Human report path for this result. |

### Verdict values

- `malicious` — a malware engine returned `block`, **or** the findings contain a
  published malware advisory (`MAL-…`). A vulnerability engine can supply the
  advisory; the verdict still means malware.
- `suspicious` — a non-malware engine returned `block` (a CVE, for example), or
  an engine returned a `warn` of kind `security`. Nothing was called malware.
- `clean` — the scan completed, every applicable engine reported, and nothing
  was flagged.
- `partial` — a real coverage gap: an applicable engine produced no assessment,
  or no content-reading engine read the artifact. Never treat it as clean.
- `unsupported` — no engine applies to this artifact type.
- `unscanned` — queued, scanning, or no report exists.
- `error` — the scan failed before a verdict.

`flaggedCount` and `verdict` answer different questions. `flaggedCount` counts
blocked engines; `verdict` applies the policy above. A CVE block is
`flaggedCount: 1` with `verdict: "suspicious"`; a security warning is
`flaggedCount: 0` with `verdict: "suspicious"`. Gate on `verdict` and use
`flaggedCount` only for display.

### Coverage object

| Field | Meaning |
|---|---|
| `total` | Engines in the roster for this scan. |
| `reported` | Engines that completed an assessment (`done`). |
| `unsupported` | Engines whose capability profile does not apply to this artifact type. Not a gap: providers cover each other's artifact types. |
| `errored` | Applicable engines that failed. A gap. |
| `pending` | Still queued or scanning. |
| `warned` | Completed engines that reported a `security` warning. |
| `hygieneWarned` | Release-health notices (publication cooldown, deprecation, low usage). Not a finding about the file. |
| `capabilityWarned` | Low-severity capability matches (filesystem, network, process). Not a malware finding. |
| `eligible` | `total - unsupported`. |
| `gapped` | Applicable engines with no assessment once nothing is pending. |
| `allUnsupported` | No engine applies to this artifact type. |
| `noContentCoverage` | No engine that reads artifact code assessed it. Not a clean result. |
| `complete` | Nothing is still running. |

### Engine entry

`engines[].status` is `queued`, `scanning`, `done`, `error` or `unsupported`.
`engines[].verdict` is `pass`, `warn`, `block`, `unknown`, or `null` before the
engine reports. On a `warn`, `warnKind` is `security` (something to review),
`hygiene` (release health) or `capability` (a low-severity capability match);
only `security` raises the public verdict to `suspicious`.

### Example: malicious by advisory, contents not inspected

`GET /api/pkg/npm/<name>@<version>` where a vulnerability engine matched a
malware advisory and no content engine could run:

```json
{
  "status": "completed",
  "verdict": "malicious",
  "flaggedCount": 1,
  "reportedCount": 6,
  "coverage": {
    "total": 6,
    "reported": 3,
    "unsupported": 3,
    "errored": 0,
    "pending": 0,
    "warned": 0,
    "hygieneWarned": 0,
    "capabilityWarned": 0,
    "eligible": 3,
    "gapped": 0,
    "allUnsupported": false,
    "noContentCoverage": true,
    "complete": true
  },
  "engines": [
    { "id": "osv", "version": "1.2.0", "status": "done", "verdict": "block", "findingCount": 1 },
    { "id": "grype", "version": "0.90.0", "status": "done", "verdict": "pass", "findingCount": 0 },
    { "id": "depsdev", "version": "3.0.0", "status": "done", "verdict": "pass", "findingCount": 0 },
    { "id": "argus", "version": null, "status": "unsupported", "verdict": null, "findingCount": 0 },
    { "id": "guarddog", "version": null, "status": "unsupported", "verdict": null, "findingCount": 0 },
    { "id": "skillspector", "version": null, "status": "unsupported", "verdict": null, "findingCount": 0 }
  ],
  "providers": [
    { "id": "osv", "findings": [{ "id": "MAL-2026-18439", "type": "advisory" }] }
  ],
  "parentFile": { "name": "pipeprobe-1.0.0.tgz", "size": 4096, "hash": "<sha256>", "type": ".tgz" },
  "sha256": "<sha256>",
  "purl": "pkg:npm/example@1.0.0",
  "analyzedAt": "2026-11-09T02:03:45Z",
  "createdAt": "2026-11-09T02:03:20Z",
  "permalink": "/pkg/npm/example@1.0.0"
}
```

### Example: suspicious without a block

A heuristic engine warned; nothing blocked the artifact.

```json
{
  "status": "completed",
  "verdict": "suspicious",
  "flaggedCount": 0,
  "engines": [
    { "id": "guarddog", "version": "2.1.0", "status": "done", "verdict": "warn", "warnKind": "security", "findingCount": 2 }
  ],
  "coverage": { "warned": 1, "gapped": 0, "complete": true }
}
```

A `clean` report has `noContentCoverage: false`, no `block` engine and
`gapped: 0`. A `partial` or `unsupported` report is not a clean result.

## Errors

Errors use one shape, with the HTTP status carrying the class of failure:

```json
{ "error": "invalid_purl", "message": "A versioned Package URL is required." }
```

| Status | Meaning |
|---|---|
| 400 | Invalid input (`invalid_purl`, `invalid_json`) |
| 401 | Missing or invalid credentials |
| 402 | Plan quota exhausted |
| 404 | No artifact or report for an endpoint that requires one (`/api/scan/{jobId}`, `/api/file/{sha256}`). Package lookups return `200` with `identity.status: "missing"` instead. |
| 429 | Rate limited — retry after the window |
| 502 | Upstream scan engine unavailable — retry later |

## PURL and hash lookup

A separate read-only service maps a file hash to every PURL that publishes it,
and a PURL to its published hash. It is not under `/api` and uses
`X-API-Key` on request:

```
GET  /v1/purl?sha256=<hex>             # every PURL for this file
GET  /v1/purl?purl=<pkg:...@version>   # published hash for that version
POST /v1/purl                          # batch, up to 100 keys
```

Only `vscode-extension` PURLs are covered. A PURL needs `@version`; without
`repository_url` it means the Visual Studio Marketplace, and Open VSX must be
named in the PURL.

## MCP

The same scan engine is exposed as a Model Context Protocol server at `/mcp`
for agents that support MCP tools. See `/docs#developers/mcp`.
