Back to Documentation

Public API Reference

v1

REST API for programmatic access to PatternStack package intelligence. Requires a Workspace subscription or higher.

Quick Start

Get started with the PatternStack API in minutes

Base URL

https://api.patternstack.ai/v1

Authentication

Include your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Get your API key from Dashboard → API Keys

Example Request

curl -X GET "https://api.patternstack.ai/v1/packages/search?q=date&ecosystem=npm" \
  -H "Authorization: Bearer ts_live_xxxx"

Rate Limits & Quotas

Daily quotas reset at midnight UTC

TierSearchCompareAI InsightsSecurity
Free
----
Premium
500/day200/day100/day50/day
Workspace
100/day50/day10/day*10/day

* Free tier AI Insights returns truncated previews (150 chars). Upgrade to Workspace for full responses.

Endpoints

GET
/v1/packages/search

Search packages with trend and health signals

workspace+
NameTypeRequiredDescription
qstring
Required
Search query
ecosystemstringOptionalFilter by ecosystem (npm, pypi, etc.)
frameworkstringOptionalFilter by framework context
limitnumberOptionalMax results (default: 20, max: 50)

POST
/v1/packages/compare

Compare 2-10 packages with relative rankings

workspace+
NameTypeRequiredDescription
packagesstring[]
Required
Array of package names (2-10)
ecosystemstringOptionalEcosystem context

POST
/v1/insights/explain

AI-powered package explanations and recommendations

workspace+
NameTypeRequiredDescription
packagesstring[]
Required
Packages to analyze
questionstringOptionalSpecific question to answer
contextobjectOptionalFramework/project context

GET
/v1/migrations/{package}

Get migration paths for declining packages

workspace+
NameTypeRequiredDescription
packagestring
Required
Package name (path parameter)
ecosystemstringOptionalPackage ecosystem

GET
/v1/trends

Trending packages by ecosystem and framework

workspace+
NameTypeRequiredDescription
ecosystemstring
Required
Ecosystem (npm, pypi, etc.)
frameworkstringOptionalFilter by framework
directionstringOptionalrising, declining, or all
limitnumberOptionalMax results (default: 20)

GET
/v1/packages/{name}/alternatives

Find alternatives to a specific package

workspace+
NameTypeRequiredDescription
namestring
Required
Package name (path parameter)
ecosystemstringOptionalPackage ecosystem

POST
/v1/analyze

Stateless analysis for CI/CD pipelines

workspace+
NameTypeRequiredDescription
packageJsonobjectOptionalpackage.json contents
requirementsTxtstringOptionalrequirements.txt contents
goModstringOptionalgo.mod contents

POST
/v1/security/scan

Vulnerability scanning for dependencies

workspace+
NameTypeRequiredDescription
packageJsonobjectOptionalpackage.json with dependencies
requirementsTxtstringOptionalPython requirements
severityFilterstringOptionalcritical, high, medium, or low

GET
/v1/stack/defaults

Get canonical industry-standard stack for a framework (agent-optimized)

free+
NameTypeRequiredDescription
frameworkstringOptionalFramework name (next, django, etc.)
ecosystemstringOptionalFilter by ecosystem
strict_modebooleanOptionalOnly return required packages

POST
/v1/stack/align

Compute how well a project aligns with canonical stack

workspace+
NameTypeRequiredDescription
frameworkstring
Required
Target framework
packagesstring[]
Required
Project packages to analyze
strictModebooleanOptionalEnforce required packages

POST
/v1/stack/generate

Generate recommended stacks based on use-case requirements (agent-optimized)

workspace+
NameTypeRequiredDescription
useCasesstring[]
Required
Use cases: realtime, ai, ecommerce, cms, saas, api, mobile, desktop, cli, data, devtools
frameworkstringOptionalTarget framework (next, django, etc.)
ecosystemstringOptionalTarget ecosystem (npm, pypi, etc.)
scalestringOptionalScale: startup, growth, enterprise
prioritiesstring[]OptionalPriorities: speed, stability, performance, cost

Error Codes

CodeHTTP StatusDescription
INVALID_API_KEY401Missing or invalid API key
INSUFFICIENT_TIER403Your plan doesn't include this endpoint
RATE_LIMIT_EXCEEDED429Too many requests, check Retry-After header
QUOTA_EXCEEDED429Daily quota exhausted, resets at midnight UTC
INVALID_REQUEST400Invalid parameters or request body
INTERNAL_ERROR500Server error, please try again

Response Headers

HeaderDescription
X-RateLimit-LimitYour daily quota for this endpoint
X-RateLimit-RemainingRemaining requests in current period
X-RateLimit-ResetISO 8601 timestamp when quota resets
X-API-VersionAPI version (currently 1.0.0)
Retry-AfterSeconds to wait before retrying (on 429)

Need help? Contact API support