Dev · npm Downloads API
npm.downloads
- Operation
- POST /v1/capabilities/npm.downloads/execute
- operationId
- executeNpmDownloads
- Typical credits
- 0
- Search deadline
- 15 s server-side
- Paging
- single result
- Availability
- Not checked
GET /v1/catalog (available). The timestamped snapshot describes configuration, not provider uptime or your account's enabled choices. Check the catalog with your own key before a call. Credits are explained under credits and limits.Request
Body of POST /v1/capabilities/npm.downloads/execute, JSON, validated against the NpmDownloadsRequest component of the public OpenAPI document. Defaults are applied server-side, so an omitted optional field behaves exactly as its default.
| Field | Type | Required | Default | Constraints and description |
|---|---|---|---|---|
| package | string | yes | min length 1, max length 214, pattern ^(?:@[a-zA-Z0-9_~][a-zA-Z0-9._~-]*/)?[a-zA-Z0-9_~][a-zA-Z0-9._~-]*$ Public npm package name, including scoped names such as @babel/core. | |
| period | string | no | "last-month" | pattern ^(last-day|last-week|last-month|last-year|[0-9]{4}-[0-9]{2}-[0-9]{2}(:[0-9]{4}-[0-9]{2}-[0-9]{2})?)$ Named period, YYYY-MM-DD, or inclusive YYYY-MM-DD:YYYY-MM-DD range (upstream limit: 18 months). last-month is the last 30 available days, not the previous calendar month. |
| kind | "point" | "range" | no | "point" | point returns a total; range returns daily counts. |
- Unknown keys are rejected with
400 invalid_request.
Rules the schema cannot express
Checked after schema validation; violations return 400 invalid_request with a plain message.
- Explicit dates must be valid calendar dates; the end date must not precede the start date.
Examples
Last 30 available days
curl -s -X POST https://ai-powerups.smalltree.cloud/v1/capabilities/npm.downloads/execute \
-H "Authorization: Bearer $AIPA_API_KEY" -H "Content-Type: application/json" \
-d '{"package":"zod","period":"last-month","kind":"point"}'Daily counts
curl -s -X POST https://ai-powerups.smalltree.cloud/v1/capabilities/npm.downloads/execute \
-H "Authorization: Bearer $AIPA_API_KEY" -H "Content-Type: application/json" \
-d '{"package":"zod","period":"last-month","kind":"range"}'Calendar month
curl -s -X POST https://ai-powerups.smalltree.cloud/v1/capabilities/npm.downloads/execute \
-H "Authorization: Bearer $AIPA_API_KEY" -H "Content-Type: application/json" \
-d '{"package":"zod","period":"2026-08-01:2026-08-31"}'ExecuteResponse component (see sessions and records); the record keys below are what the adapter emits. A first call with the example above returns search_id, the records and the charge.Result record
Every item in results[] carries record_id and title (contract, always present) and usually url and snippet. The keys below are the documented tier: produced deterministically by this capability, omitted when the source has no value, checked against recorded source fixtures in our test suite, and published as the NpmDownloadsRecord component (all optional, extra keys allowed) so generated clients type them. The wire schema itself still validates only the base keys. See stability tiers.
| Key | Type | Presence | Note |
|---|---|---|---|
| package | string | always | |
| kind | "point" | "range" | always | |
| start | string | always | |
| end | string | always | |
| downloads | integer | object[] | always | Total, or daily { day, downloads } entries for range. |
Caveats
- last-month means the last 30 available days. Use returned inclusive start/end dates. npm limits each request to 18 months.
Follow-ups
- Paging: Single result;
moreis refused with400 invalid_request. - Update: not offered.
- Record actions: none.
- Detail behaviour: No record actions.
Record detail objects of this capability are provider-shaped: documented by observation, not by schema. Full follow-up semantics: follow-up.
Typed client
With types generated from the public document (see types, client and samples) the call is path-keyed and the body is checked at compile time:
const { data, error } = await client.POST("/v1/capabilities/npm.downloads/execute", {
body: {
"package": "zod",
"period": "last-month",
"kind": "point"
},
});
if (error) throw new Error(`${error.error.code}: ${error.error.message}`);
for (const record of data.results) console.log(record.record_id, record.title);