Packagist API
Free Packagist API with no key: PHP package metadata, all versions, dependencies, licences and autoload config from the Composer registry. Tested example.
Endpoint tested and returned HTTP 200 on 2026-08-19
What is the Packagist API?
The Packagist API is the free, key-free registry API for PHP Composer packages, providing package metadata, every published version with its dependencies, licences and autoload configuration.
Packagist is the default Composer repository, and its metadata is served from a static CDN endpoint designed for high volume. The `/p2/` path is the one to use — it is the same endpoint Composer itself hits, so it is fast and heavily cached.
Each version entry is essentially the package's composer.json at that release, including `require`, `require-dev`, autoload rules and licence. That makes it useful for dependency analysis without cloning anything.
Quick facts
- Base URL
https://repo.packagist.org- Authentication
- No API key required.
- Rate limit
- The /p2/ metadata endpoints are CDN-served and built for high volume. The search API on packagist.org is more limited.
- Pricing
- Free.
- CORS
- Not enabled — call it from your server
- Official docs
- Read the docs
How to use the Packagist API
Every request below was executed against the live API on 2026-08-19, and the response shown is the real body it returned — not an illustration.
1. Fetch all versions of a PHP package
GET https://repo.packagist.org/p2/monolog/monolog.json
curl 'https://repo.packagist.org/p2/monolog/monolog.json'const res = await fetch("https://repo.packagist.org/p2/monolog/monolog.json");
if (!res.ok) throw new Error(`Request failed: ${res.status}`);
const data = await res.json();
console.log(data);import requests
res = requests.get("https://repo.packagist.org/p2/monolog/monolog.json", timeout=20)
res.raise_for_status()
print(res.json()){
"minified": "composer/2.0",
"packages": {
"monolog/monolog": [
{
"name": "monolog/monolog",
"description": "Sends your logs to files, sockets, inboxes, databases and various web services",
"keywords": [
"log",
"logging",
"psr-3"
],
"homepage": "https://github.com/Seldaek/monolog",
"version": "3.10.0",
"version_normalized": "3.10.0.0",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "https://seld.be"
}
],
"source": {
"url": "https://github.com/Seldaek/monolog.git",
"type": "git",
"reference": "b321dd6749f0bf7189444158a3ce785cc16d69b0"
},
"dist": {
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/b321dd6749f0bf7189444158a3ce785cc16d69b0",
"type": "zip",
"shasum": "",
"reference": "b321dd6749f0bf7189444158a3ce785cc16d69b0"
},
"type": "library",
"support": {
"issues": "https://github.com/Seldaek/monolog/issues",
"source": "https://github.com/Seldaek/monolog/tree/3.10.0"
},
"funding": [
{
"url": "https://github.com/Seldaek",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/monolog/monolog",
"type": "tidelift"
}
],
"time": "2026-01-02TParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
p2/<vendor>/<package>.json | path | Required | Vendor and package name. monolog/monolog |
search.json?q= | path | Optional | Search packages on packagist.org. logging |
Response fields
minifiedstring- Format marker, `composer/2.0` — versions are delta-compressed.
packages.<vendor/name>array- Array of version objects, newest first.
packages[].versionstring- Version string.
packages[].requireobject- Runtime dependencies with version constraints.
packages[].licensearray- SPDX licence identifiers.
packages[].autoloadobject- PSR-4 or classmap autoload configuration.
What you can build with the Packagist API
- Check the latest release of a Composer package
- Audit licences across a PHP project's dependencies
- Analyse dependency constraints before upgrading
- Build a package browser or version badge
Common errors and how to fix them
404
Unknown vendor/package pair.
Fix: Both parts are required and lowercase: monolog/monolog, not just monolog.
Fields missing on some versions
The /p2/ format is delta-compressed — omitted fields inherit from the previous entry.
Fix: Merge forward from the first entry rather than reading each version in isolation.
Packagist API — frequently asked questions
Is the Packagist API free?
Yes, completely free with no API key. The /p2/ metadata endpoints are CDN-served and designed to handle Composer's own traffic.
Why do some versions seem to be missing fields?
The /p2/ format is minified with delta compression — a version only lists what changed from the previous entry. Merge forward rather than treating each entry as complete.
How do I find the latest version?
The versions array is ordered newest first, so the first entry with a non-dev version string is the current release.
Can I search for packages?
Yes, via packagist.org/search.json?q=term, though that endpoint is more rate limited than the CDN-served metadata paths.
Tools that pair with this API
JSON Formatter
Format, beautify and minify JSON online with 2-space, 4-space or tab indentation. Sort keys alphabetically and catch syntax errors instantly — free and private.
JSON Validator
Free online JSON validator: validate JSON and find syntax errors with the exact line and column. See root type, key counts and depth — instant and 100% private.
Packagist is an independent third-party service and is not affiliated with ByteTools or ByteVancer. Details on this page were verified on 2026-08-19; always check the official documentation before relying on this API in production, as terms and limits can change.