apyhub
Back
▣ VERIFICATION KIT · SAFETY KIT

Check Package Safety API

What it does

The Package Safety Check API tells you if an npm or PyPI package is safe to install. Send a list of packages and get back a verdict, a risk score and the reasons for each one.

Send packages with 1 to 25 items. Each item is a name with an optional version and prefix, such as [email protected], npm:[email protected] or pypi:requests==2.19.0. Without a version, the latest one is checked. Set ecosystem (npm or pypi, default npm) for items that have no prefix.

Each result has a verdict of ok, caution, avoid or not_found, plus a riskScore from 0 to 100. The reasons list explains it in plain words. The check looks for known vulnerabilities from OSV.dev, typosquat names such as expresss, and deprecated or yanked releases. It also flags npm install scripts, versions published in the last 72 hours and packages with no source repository.

Teams use this package safety check in CI to block risky dependencies before install. AI coding agents use it to catch mistyped or hallucinated package names, which come back as not_found. Security teams use it to review new npm and PyPI dependencies.

For a full advisory list across more ecosystems, use the Check Package Vulnerabilities API. To find outdated libraries on a live site, use the Website Security Scan API.

POST
Package Safety Check API - npm and PyPI before you install
https://api.eu.apyhub.com/martin10291/check-package-safety

QUICKSTART

GUIDE

Quickstart

Check the safety of a package version before you install it.

curl -X POST "https://api.eu.apyhub.com/martin10291/check-package-safety" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "packages": ["[email protected]"],
    "ecosystem": "npm"
  }'

What you'll get back

Returns a JSON object with count and items, one safety report per package. Here express 4.18.2 gets caution: it has 2 known vulnerabilities, listed in vulnerabilities with the versions that fix them. The report also shows the latest version, downloads, maintainers, licence, install scripts and the data sources.

{
  "count": 1,
  "items": [
    {
      "attribution": "Vulnerability data: OSV.dev (CC BY 4.0). Package metadata: npm public registry API / PyPI JSON API.",
      "checkedAt": "2026-11-26T10:10:18Z",
      "deprecated": false,
      "deprecatedMessage": null,
      "ecosystem": "npm",
      "exists": true,
      "hasInstallScripts": false,
      "homepage": "http://expressjs.com/",
      "installScripts": {},
      "latestVersion": "5.3.0",
      "license": "MIT",
      "maintainersCount": 3,
      "message": null,
      "name": "express",
      "packageAgeDays": 5810,
      "packageCreatedAt": "2010-12-29T19:38:25Z",
      "reasons": [
        "2 known vulnerabilities in 4.18.2, worst MODERATE (GHSA-rv95-896h-c2vc; fixed in 5.0.0-beta.3)"
      ],
      "repositoryUrl": "https://github.com/expressjs/express",
      "requestedVersion": "4.18.2",
      "riskScore": 27,
      "sources": [
        "npm registry API",
        "npm downloads API",
        "OSV.dev"
      ],
      "typosquatOf": null,
      "verdict": "caution",
      "version": "4.18.2",
      "versionAgeHours": 36229.9,
      "versionPublishedAt": "2022-10-08T20:14:32Z",
      "versionsCount": 320,
      "vulnCount": 2,
      "vulnerabilities": [
        {
          "fixedIn": [
            "4.19.2",
            "5.0.0-beta.3"
          ],
          "id": "GHSA-rv95-896h-c2vc",
          "severity": "MODERATE",
          "summary": "Express.js Open Redirect in malformed URLs"
        },
        {
          "fixedIn": [
            "4.20.0",
            "5.0.0"
          ],
          "id": "GHSA-qw6h-vgh9-j6wx",
          "severity": "LOW",
          "summary": "express vulnerable to XSS via response.redirect()"
        }
      ],
      "weeklyDownloads": 209877980,
      "yanked": null,
      "yankedReason": null
    }
  ]
}
TRY ITLIVE · 100 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body
packages*
Packages to check, 1 to 25 per call. Each item is a package name with an optional version and ecosystem prefix: `express`, `[email protected]`, `npm:[email protected]`, `pypi:requests==2.19.0`. Without a version, the latest version is checked.
Default ecosystem for items in `packages` that have no `npm:` or `pypi:` prefix: `npm` or `pypi` (default `npm`).

About this endpoint

What it does

Checks npm or PyPI packages for safety information and returns a row per requested package with metadata such as existence, verdict, risk-related signals, and version details. Send a list of 1 to 25 packages, each with an optional version and ecosystem prefix.

Request Body

ParameterTypeMandatoryDescription
packagesString ArrayYesPackages to check, 1 to 25 per call. Each item is a package name with an optional version and ecosystem prefix, e.g. express, [email protected], npm:[email protected], pypi:requests==2.19.0. Without a version, the latest version is checked.
ecosystemENUMNoDefault ecosystem for items in packages without an npm: or pypi: prefix. Allowed values: npm, pypi. Default: npm.

Response

Returns a JSON object with a count integer and an items array with one safety report per package. Each report has a verdict (ok, caution, avoid or not_found), a riskScore from 0 to 100 and the reasons behind it, plus the package metadata and known vulnerabilities used to decide.

ParameterTypeDescription
countIntegerNumber of rows in items, one per package in packages.
itemsObject ArrayOne safety report per package, in the order you sent them.
items[].ecosystemStringnpm or pypi.
items[].nameStringPackage name.
items[].requestedVersionStringThe version you asked for, or null if you sent none.
items[].versionStringVersion that was checked (the latest if you sent none).
items[].existsBooleanfalse if the package does not exist in the registry, often a mistyped or AI-hallucinated name.
items[].verdictStringOverall result: ok, caution, avoid or not_found.
items[].riskScoreIntegerRisk from 0 (no issues found) to 100 (highest risk).
items[].reasonsString ArrayPlain-language reasons behind the verdict, e.g. known vulnerabilities, typosquat, deprecated, install scripts, very new version.
items[].messageStringExtra note, e.g. that the requested version does not exist. null otherwise.
items[].vulnCountIntegerNumber of known vulnerabilities affecting this version (OSV.dev).
items[].vulnerabilitiesObject ArrayKnown vulnerabilities affecting this version.
items[].vulnerabilities[].idStringAdvisory id, e.g. GHSA-jf85-cpcp-j695.
items[].vulnerabilities[].severityStringLOW, MODERATE, HIGH or CRITICAL.
items[].vulnerabilities[].summaryStringShort description of the vulnerability.
items[].vulnerabilities[].fixedInString ArrayVersions that fix it.
items[].typosquatOfStringPopular package this name looks like a typosquat of, e.g. express for expresss. null otherwise.
items[].deprecatedBooleantrue if the package or version is deprecated.
items[].deprecatedMessageStringDeprecation message from the registry. null if not deprecated.
items[].yankedBooleanPyPI only. true if the release was yanked.
items[].yankedReasonStringPyPI only. Reason given for the yank.
items[].hasInstallScriptsBooleannpm only. true if the package runs scripts on install (preinstall, install, postinstall).
items[].installScriptsObjectnpm only. The install scripts, e.g. {"postinstall": "node install.js"}.
items[].latestVersionStringLatest published version.
items[].versionPublishedAtStringWhen the checked version was published (ISO 8601 UTC).
items[].versionAgeHoursNumberAge of the checked version in hours. Very new versions get a caution.
items[].packageCreatedAtStringWhen the package was first published.
items[].packageAgeDaysIntegerAge of the package in days.
items[].versionsCountIntegerNumber of published versions.
items[].maintainersCountIntegerNumber of maintainers.
items[].weeklyDownloadsIntegernpm downloads in the last 7 days. null for PyPI.
items[].licenseStringDeclared licence, e.g. MIT.
items[].homepageStringPackage homepage.
items[].repositoryUrlStringSource repository URL. Missing repositories add to the risk.
items[].sourcesString ArrayData sources used, e.g. npm registry API, npm downloads API, OSV.dev.
items[].attributionStringAttribution text: OSV.dev (CC BY 4.0), npm registry API, PyPI JSON API.
items[].checkedAtStringWhen the check ran (ISO 8601 UTC).
▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.