# Slopsquatting Checker - Catch AI-Invented npm & PyPI Packages (`that_red_bird/hallucinated-package-checker`) Actor

Stop npm install / pip install of packages an AI made up. Paste code, package.json, requirements.txt or an LLM answer: every package is checked on npm and PyPI and flagged NOT_FOUND, LOOKALIKE, BRAND_NEW or LOW_ADOPTION. No API key needed.

- **URL**: https://apify.com/that_red_bird/hallucinated-package-checker.md
- **Developed by:** [mohamed alaya](https://apify.com/that_red_bird) (community)
- **Categories:** Developer tools, AI, Open source
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.00 / 1,000 package checkeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Slopsquatting Checker - Catch AI-Invented npm & PyPI Packages

Paste code, a package.json, a requirements.txt or an AI chat answer. This Actor finds every package it imports or installs and tells you which ones **do not exist**, are **brand new**, are **look-alikes of popular names**, or have almost no users, before anyone runs `npm install` or `pip install`.
Built for security teams and for people who build AI coding agents that install what the model suggests.

### Why it exists

Coding assistants regularly recommend packages that were never published. Researchers call the attack that follows **slopsquatting**: an attacker registers the invented name, and the next developer or agent that installs it runs the attacker's code. The same invented names tend to repeat across runs, so they are easy to pre-register. A one-line check against the registry before install closes the gap.

### Input examples

**1. Check a pasted AI answer or source file** (imports, requires and install commands are extracted for you)

```json
{ "code": "import express from 'express';\nconst x = require('react-fast-xml-pro');\n// pip install requestz\nimport pandas" }
```

**2. Check a list of names**

```json
{ "packages": ["npm:left-pad", "npm:lodsah", "pypi:requests", "pypi:numpyy"] }
```

**3. Check a whole manifest, show only the dangerous ones**

```json
{ "packageJson": "{\"dependencies\":{\"react\":\"^18\",\"react-super-hooks-pro\":\"^1.0.0\"}}", "onlyRisky": true }
```

Run with no input at all and the run succeeds with a status message asking for input. Nothing is checked and nothing is charged.

### Input guide

| Field | What it does |
|---|---|
| `code` | Any text. JS/TS `import`, `require`, dynamic `import()`, Python `import`/`from ... import`, and `npm/yarn/pnpm/pip install` commands are extracted. Node built-ins and the Python standard library are skipped. |
| `packages` | Plain names. Prefix `npm:` or `pypi:` to set the registry per name. |
| `packageJson`, `requirementsTxt` | Paste the file contents. |
| `newPackageDays` | Packages first published more recently than this are `BRAND_NEW` (default 30). |
| `lowDownloadsPerWeek` | npm packages below this weekly download count are `LOW_ADOPTION` (default 100). |
| `checkLookalikes` | Compare existing, low-adoption names with popular packages to catch typosquats. |
| `onlyRisky` | Hide `risk: none` rows (they are also not charged). |

### Output

One row per distinct package.

| Field | Meaning |
|---|---|
| `verdict` | `NOT_FOUND`, `LOOKALIKE`, `SECURITY_HOLDING`, `BRAND_NEW`, `LOW_ADOPTION`, `DEPRECATED` or `OK` |
| `risk` | `high`, `medium`, `low` or `none` |
| `flags` | All signals that fired, for example `BRAND_NEW`, `LOW_DOWNLOADS`, `NO_REPOSITORY`, `SINGLE_RELEASE`, `INSTALL_SCRIPT_ON_UNPROVEN_PACKAGE` |
| `reason`, `action` | Plain-English explanation and what to do |
| `suggestions` | Likely real package names for a misspelling |
| `createdAt`, `ageDays`, `latestVersion`, `versionCount`, `weeklyDownloads` | Registry facts (downloads: npm only) |
| `foundIn` | `import`, `install-command`, `packages`, `package.json` or `requirements.txt` |

Sample row:

```json
{
  "type": "package", "name": "numpyy", "ecosystem": "pypi", "verdict": "NOT_FOUND", "risk": "high",
  "flags": ["NOT_ON_REGISTRY"],
  "reason": "\"numpyy\" does not exist on PyPI. Installing it would either fail or, if someone registers the name later, pull attacker code (slopsquatting).",
  "action": "Do not install. Did you mean: numpy?", "suggestions": ["numpy"], "foundIn": "import"
}
```

Errors (registry unreachable) come out as `type: "error"` rows and are never charged. A run summary is stored under the `SUMMARY` key.

### Use it with

- **AI coding agents:** call this Actor with the model's proposed code before the install step and block on `risk: high`.
- **CI:** run it on every pull request's `package.json` / `requirements.txt` diff.
- **Package Intelligence** (npm & PyPI Package Scraper): after a package passes this check, feed it there for licence, maintainers and vulnerability data.

### FAQ

**Does it install or execute anything?** No. It only reads public registry metadata.

**Why is a Python package marked NOT_FOUND when I use it every day?** Python import names can differ from the PyPI name (for example `cv2` is `opencv-python`) or the import can be one of your own modules. Common renames are mapped; for the rest, check the row's `foundIn: import` note.

**Where do the download numbers come from?** The public npm downloads API. PyPI has no keyless equivalent, so PyPI rows use age, release count and look-alike checks instead.

### Honest limits

- A package that exists is not proven safe. `OK` means no slopsquatting signal, not a malware scan.
- Look-alike detection compares against a built-in list of popular names, not the full registry.
- Only npm and PyPI. Private registries and scoped packages behind a login are reported as not found.

### Price

Pay per event: **$0.001 per package checked** (`package-checked`). Checking 200 dependencies costs **$0.20**. Failed lookups are free.

# Actor input Schema

## `packages` (type: `array`):

Package names to check, one per line. Optional prefix 'npm:' or 'pypi:' sets the registry for that name (for example 'pypi:requests'); names without a prefix use the Default registry below. Or paste code, package.json or requirements.txt below. Empty input checks nothing and is not charged.

## `ecosystem` (type: `string`):

Registry used for names in 'Package names' that have no npm: or pypi: prefix. Code, package.json and requirements.txt are detected automatically.

## `code` (type: `string`):

Paste source code, a chat answer or a README. Every JavaScript/TypeScript import and require, Python import, and npm/pip install command in it is extracted and checked.

## `packageJson` (type: `string`):

Paste a package.json. Its dependencies, optionalDependencies and peerDependencies are checked (devDependencies only if enabled below).

## `requirementsTxt` (type: `string`):

Paste a requirements.txt. Every pinned or unpinned PyPI requirement is checked.

## `includeDevDependencies` (type: `boolean`):

Also check the devDependencies block of a pasted package.json.

## `newPackageDays` (type: `integer`):

A package first published fewer days ago than this gets the BRAND_NEW verdict. Fresh names are how slopsquatting packages show up.

## `lowDownloadsPerWeek` (type: `integer`):

npm packages with fewer weekly downloads than this get the LOW_ADOPTION verdict. PyPI has no keyless download API, so this applies to npm only.

## `checkLookalikes` (type: `boolean`):

Compare each existing, low-adoption package with a list of well-known packages and flag near-miss spellings (typosquats), suggesting the likely real one.

## `onlyRisky` (type: `boolean`):

Skip rows for packages with risk 'none'. Skipped packages are not charged.

## `maxPackages` (type: `integer`):

Upper bound on how many distinct packages are checked in one run (hard limit 1000).

## `concurrency` (type: `integer`):

How many registry lookups run in parallel. Keep it low to stay polite to the public registries.

## Actor input object example

```json
{
  "packages": [
    "express",
    "axios",
    "lodash",
    "react-native-fast-xml-parser-pro",
    "pypi:requests",
    "pypi:flask-restful-ultra-pro"
  ],
  "ecosystem": "npm",
  "code": "",
  "packageJson": "",
  "requirementsTxt": "",
  "includeDevDependencies": false,
  "newPackageDays": 30,
  "lowDownloadsPerWeek": 100,
  "checkLookalikes": true,
  "onlyRisky": false,
  "maxPackages": 200,
  "concurrency": 4
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `downloadCsv` (type: `string`):

No description

## `summary` (type: `string`):

No description

## `count` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "packages": [
        "express",
        "axios",
        "lodash",
        "react-native-fast-xml-parser-pro",
        "pypi:requests",
        "pypi:flask-restful-ultra-pro"
    ],
    "ecosystem": "npm",
    "code": "",
    "packageJson": "",
    "requirementsTxt": "",
    "includeDevDependencies": false,
    "newPackageDays": 30,
    "lowDownloadsPerWeek": 100,
    "checkLookalikes": true,
    "onlyRisky": false,
    "maxPackages": 200,
    "concurrency": 4
};

// Run the Actor and wait for it to finish
const run = await client.actor("that_red_bird/hallucinated-package-checker").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "packages": [
        "express",
        "axios",
        "lodash",
        "react-native-fast-xml-parser-pro",
        "pypi:requests",
        "pypi:flask-restful-ultra-pro",
    ],
    "ecosystem": "npm",
    "code": "",
    "packageJson": "",
    "requirementsTxt": "",
    "includeDevDependencies": False,
    "newPackageDays": 30,
    "lowDownloadsPerWeek": 100,
    "checkLookalikes": True,
    "onlyRisky": False,
    "maxPackages": 200,
    "concurrency": 4,
}

# Run the Actor and wait for it to finish
run = client.actor("that_red_bird/hallucinated-package-checker").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "packages": [
    "express",
    "axios",
    "lodash",
    "react-native-fast-xml-parser-pro",
    "pypi:requests",
    "pypi:flask-restful-ultra-pro"
  ],
  "ecosystem": "npm",
  "code": "",
  "packageJson": "",
  "requirementsTxt": "",
  "includeDevDependencies": false,
  "newPackageDays": 30,
  "lowDownloadsPerWeek": 100,
  "checkLookalikes": true,
  "onlyRisky": false,
  "maxPackages": 200,
  "concurrency": 4
}' |
apify call that_red_bird/hallucinated-package-checker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,that_red_bird/hallucinated-package-checker"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/3MguO7iwCbuSUe9ef/builds/cQXdhC11cTvgX1cO0/openapi.json
