# npm API

> Returns npm packages from search, with versions, dist-tags, licences, dependencies and download counts.

Category: Developer & Tech. Region: global. 8 endpoints at `https://api.hoshime.com/v1/npm/<endpoint>`, `GET` with query parameters, answering `{data, meta}` (see https://hoshime.com/docs/responses.md). Reference: https://hoshime.com/docs/platforms/npm
## GET /v1/npm/search

Packages that match a search, 20 per page, best match first.

Scope: `social:read` · Units: 1 · Cached: 30 min · Paginated: cursor

| Parameter | Type | Required | Description |
|---|---|---|---|
| `query` | string | yes | Search terms. (e.g. react) |
| `cursor` | string | no | meta.pagination.nextCursor of the previous page. Omit it for the first page. |
| `tunnel` | string | no | Id or name of one of your tunnels: the call reads the source from the machine that runs `hoshime tunnel`, through its own connection. Fails with 409 tunnel_unavailable when no machine is connected. Cannot be combined with proxy. |
| `proxy` | string | no | Your own http:// or https:// proxy, such as http://user:pass@proxy.example.com:8080, on a public address. The call reads the source only through it. |
| `profileId` | string | no | Browser profile whose login the call sends (its cookies), so the source answers as that account. Without tunnel or proxy it leaves through the profile's own residential IP. Needs the browser:read scope. Data read logged in is for your account only. |

Response data fields: `description` (string), `keywords` (string[]), `name` (string), `publishedAt` (string), `publisher` (string), `score` (number (double)), `url` (string), `version` (string)

```bash
curl "https://api.hoshime.com/v1/npm/search?query=react" -H "Authorization: Bearer $HOSHIME_TOKEN"
```

## GET /v1/npm/package

Latest version, licence, maintainers and last-week downloads of one package.

Scope: `social:read` · Units: 1 · Cached: 60 min

| Parameter | Type | Required | Description |
|---|---|---|---|
| `name` | string | yes | Package name, scoped names included (@scope/name), or npmjs.com package URL. (e.g. react) |
| `tunnel` | string | no | Id or name of one of your tunnels: the call reads the source from the machine that runs `hoshime tunnel`, through its own connection. Fails with 409 tunnel_unavailable when no machine is connected. Cannot be combined with proxy. |
| `proxy` | string | no | Your own http:// or https:// proxy, such as http://user:pass@proxy.example.com:8080, on a public address. The call reads the source only through it. |
| `profileId` | string | no | Browser profile whose login the call sends (its cookies), so the source answers as that account. Without tunnel or proxy it leaves through the profile's own residential IP. Needs the browser:read scope. Data read logged in is for your account only. |

Response data fields: `author` (string), `dependencyCount` (integer (int64)), `deprecated` (string), `description` (string), `downloadsLastWeek` (integer (int64)), `homepage` (string), `keywords` (string[]), `license` (string), `maintainers` (string[]), `name` (string), `repository` (string), `url` (string), `version` (string)

```bash
curl "https://api.hoshime.com/v1/npm/package?name=react" -H "Authorization: Bearer $HOSHIME_TOKEN"
```

## GET /v1/npm/versions

Published versions of one package, newest first, 30 per page, with the publish time and any deprecation message.

Scope: `social:read` · Units: 1 · Cached: 60 min · Paginated: cursor

| Parameter | Type | Required | Description |
|---|---|---|---|
| `name` | string | yes | Package name, scoped names included (@scope/name), or npmjs.com package URL. (e.g. react) |
| `cursor` | string | no | meta.pagination.nextCursor of the previous page. Omit it for the first page. |
| `tunnel` | string | no | Id or name of one of your tunnels: the call reads the source from the machine that runs `hoshime tunnel`, through its own connection. Fails with 409 tunnel_unavailable when no machine is connected. Cannot be combined with proxy. |
| `proxy` | string | no | Your own http:// or https:// proxy, such as http://user:pass@proxy.example.com:8080, on a public address. The call reads the source only through it. |
| `profileId` | string | no | Browser profile whose login the call sends (its cookies), so the source answers as that account. Without tunnel or proxy it leaves through the profile's own residential IP. Needs the browser:read scope. Data read logged in is for your account only. |

Response data fields: `deprecated` (string), `publishedAt` (string), `version` (string)

```bash
curl "https://api.hoshime.com/v1/npm/versions?name=react" -H "Authorization: Bearer $HOSHIME_TOKEN"
```

## GET /v1/npm/version

One version of a package: its licence, dependencies, tarball and integrity hash. latest when no version is given.

Scope: `social:read` · Units: 1 · Cached: 1440 min

| Parameter | Type | Required | Description |
|---|---|---|---|
| `name` | string | yes | Package name, scoped names included (@scope/name), or npmjs.com package URL. (e.g. react) |
| `version` | string | no | Exact version, such as 18.3.1, or a dist-tag such as next. Default latest. (e.g. 18.3.1) |
| `tunnel` | string | no | Id or name of one of your tunnels: the call reads the source from the machine that runs `hoshime tunnel`, through its own connection. Fails with 409 tunnel_unavailable when no machine is connected. Cannot be combined with proxy. |
| `proxy` | string | no | Your own http:// or https:// proxy, such as http://user:pass@proxy.example.com:8080, on a public address. The call reads the source only through it. |
| `profileId` | string | no | Browser profile whose login the call sends (its cookies), so the source answers as that account. Without tunnel or proxy it leaves through the profile's own residential IP. Needs the browser:read scope. Data read logged in is for your account only. |

Response data fields: `dependencies` (Dependency[]), `dependencies[].name` (string), `dependencies[].range` (string), `deprecated` (string), `description` (string), `fileCount` (integer (int64)), `integrity` (string), `license` (string), `name` (string), `tarball` (string), `unpackedSize` (integer (int64)), `version` (string)

```bash
curl "https://api.hoshime.com/v1/npm/version?name=react&version=18.3.1" -H "Authorization: Bearer $HOSHIME_TOKEN"
```

## GET /v1/npm/distTags

The dist-tags of one package, such as latest, next and beta, with the version each one points to.

Scope: `social:read` · Units: 1 · Cached: 60 min · Paginated: cursor

| Parameter | Type | Required | Description |
|---|---|---|---|
| `name` | string | yes | Package name, scoped names included (@scope/name), or npmjs.com package URL. (e.g. react) |
| `tunnel` | string | no | Id or name of one of your tunnels: the call reads the source from the machine that runs `hoshime tunnel`, through its own connection. Fails with 409 tunnel_unavailable when no machine is connected. Cannot be combined with proxy. |
| `proxy` | string | no | Your own http:// or https:// proxy, such as http://user:pass@proxy.example.com:8080, on a public address. The call reads the source only through it. |
| `profileId` | string | no | Browser profile whose login the call sends (its cookies), so the source answers as that account. Without tunnel or proxy it leaves through the profile's own residential IP. Needs the browser:read scope. Data read logged in is for your account only. |

Response data fields: `tag` (string), `version` (string)

```bash
curl "https://api.hoshime.com/v1/npm/distTags?name=react" -H "Authorization: Bearer $HOSHIME_TOKEN"
```

## GET /v1/npm/downloads

Downloads of one package over a period: its total and the count of each day.

Scope: `social:read` · Units: 1 · Cached: 60 min

| Parameter | Type | Required | Description |
|---|---|---|---|
| `name` | string | yes | Package name, scoped names included (@scope/name), or npmjs.com package URL. (e.g. react) |
| `period` | string | no | last-day, last-week, last-month or last-year. Default last-week. (one of last-day, last-week, last-month, last-year; default last-week; e.g. last-month) |
| `tunnel` | string | no | Id or name of one of your tunnels: the call reads the source from the machine that runs `hoshime tunnel`, through its own connection. Fails with 409 tunnel_unavailable when no machine is connected. Cannot be combined with proxy. |
| `proxy` | string | no | Your own http:// or https:// proxy, such as http://user:pass@proxy.example.com:8080, on a public address. The call reads the source only through it. |
| `profileId` | string | no | Browser profile whose login the call sends (its cookies), so the source answers as that account. Without tunnel or proxy it leaves through the profile's own residential IP. Needs the browser:read scope. Data read logged in is for your account only. |

Response data fields: `daily` (DailyCount[]), `daily[].day` (string), `daily[].downloads` (integer (int64)), `end` (string), `package` (string), `start` (string), `total` (integer (int64))

```bash
curl "https://api.hoshime.com/v1/npm/downloads?name=react&period=last-month" -H "Authorization: Bearer $HOSHIME_TOKEN"
```

## GET /v1/npm/maintainerPackages

Packages one npm user maintains, as the registry search ranks them, 20 per page.

Scope: `social:read` · Units: 1 · Cached: 30 min · Paginated: cursor

| Parameter | Type | Required | Description |
|---|---|---|---|
| `username` | string | yes | npm username, such as sindresorhus. (e.g. sindresorhus) |
| `cursor` | string | no | meta.pagination.nextCursor of the previous page. Omit it for the first page. |
| `tunnel` | string | no | Id or name of one of your tunnels: the call reads the source from the machine that runs `hoshime tunnel`, through its own connection. Fails with 409 tunnel_unavailable when no machine is connected. Cannot be combined with proxy. |
| `proxy` | string | no | Your own http:// or https:// proxy, such as http://user:pass@proxy.example.com:8080, on a public address. The call reads the source only through it. |
| `profileId` | string | no | Browser profile whose login the call sends (its cookies), so the source answers as that account. Without tunnel or proxy it leaves through the profile's own residential IP. Needs the browser:read scope. Data read logged in is for your account only. |

Response data fields: `description` (string), `keywords` (string[]), `name` (string), `publishedAt` (string), `publisher` (string), `score` (number (double)), `url` (string), `version` (string)

```bash
curl "https://api.hoshime.com/v1/npm/maintainerPackages?username=sindresorhus" -H "Authorization: Bearer $HOSHIME_TOKEN"
```

## GET /v1/npm/orgPackages

Packages of one npm organization (scope such as @sveltejs), sorted by name, 100 per page.

Scope: `social:read` · Units: 1 · Cached: 30 min · Paginated: cursor

| Parameter | Type | Required | Description |
|---|---|---|---|
| `org` | string | yes | npm organization name without the @, such as sveltejs or types. (e.g. sveltejs) |
| `limit` | integer | no | Items per page, 1 to 500. (default 100) |
| `cursor` | string | no | meta.pagination.nextCursor of the previous page. Omit it for the first page. |
| `tunnel` | string | no | Id or name of one of your tunnels: the call reads the source from the machine that runs `hoshime tunnel`, through its own connection. Fails with 409 tunnel_unavailable when no machine is connected. Cannot be combined with proxy. |
| `proxy` | string | no | Your own http:// or https:// proxy, such as http://user:pass@proxy.example.com:8080, on a public address. The call reads the source only through it. |
| `profileId` | string | no | Browser profile whose login the call sends (its cookies), so the source answers as that account. Without tunnel or proxy it leaves through the profile's own residential IP. Needs the browser:read scope. Data read logged in is for your account only. |

Response data fields: `name` (string), `url` (string)

```bash
curl "https://api.hoshime.com/v1/npm/orgPackages?org=sveltejs" -H "Authorization: Bearer $HOSHIME_TOKEN"
```
