# Packages

List, install, pin and remove a project's npm and PyPI packages with the REST API.

Packages are normally installed automatically: the first time code imports one, Wisp locks its latest version. These routes let you manage them yourself. Guide: [Packages](/packages).

```http
GET    /api/projects/:id/packages
POST   /api/projects/:id/packages
PUT    /api/projects/:id/packages/:language/:name
DELETE /api/projects/:id/packages/:language/:name
```

`:language` is `javascript` or `python`; `:name` is the npm or PyPI name (scoped npm names like `@acme/greet` work as is).

## List packages

`GET /packages` returns every package the project's code imports or has locked:

```json
{ "packages": [{ "language": "javascript", "name": "dayjs", "version": "1.11.13", "pinned": false, "usedBy": ["orders"] }] }
```

## Install a package

`POST /packages` locks a package before any code imports it:

| Field | Type | Default | Description |
| --- | --- | --- | --- |
| `language` | string | — | `javascript` or `python` |
| `name` | string | — | npm or PyPI package name |
| `version` | string | `latest` | An exact version pins it; `latest` locks the newest release |

```bash
curl -X POST https://wispfn.com/api/projects/$PROJECT/packages \
  -H "Authorization: Bearer $WISP_API_KEY" -H "content-type: application/json" \
  -d '{"language":"python","name":"requests","version":"2.32.3"}'
```

Unknown packages and versions return `400`. Functions pick it up when they import it.

## Change the version

`PUT /packages/:language/:name` with `{ "version": "4.17.21" }` pins a version, or `{ "version": "latest" }` moves to the newest release. The draft's functions are rebuilt with it.

## Remove a package

`DELETE /packages/:language/:name` forgets the package's lock. If code still imports it, the latest version is locked again on the next build — remove the import to uninstall it for good.

Python packages need prebuilt wheels (pure Python or Linux arm64). Scope: `functions:write` (reading: `functions:read`).
