All API access is over HTTPS or HTTP,
and accessed from the registry.npmjs.org
domain.
All data is sent and received as JSON.
$ curl -i https://registry.npmjs.org
HTTP/1.1 200 OK
{
"db_name": "registry",
"doc_count": 123772,
"doc_del_count": 377,
"update_seq": 685591,
"purge_seq": 0,
"compact_running": false,
"disk_size": 634187899,
"data_size": 445454185,
"instance_start_time": "1420670152481614",
"disk_format_version": 6,
"committed_update_seq": 685591
}
Status: 4xx
{
"error": "error_name",
"reason": "error reason string"
}
There are two ways to authenticate through the API.
$ curl -u "username:password" https://registry.npmjs.org
$ curl -H "Authorization: Bearer ${UUId}" https://registry.npmjs.org
$ curl -i -X "GET" -u "foo:pwd" \
"https://registry.npmjs.com/-/user/org.couchdb.user:npm-user-service-testuser?write=true"
HTTP/1.1 401 Unauthorized
{"error":"unauthorized","reason":"Name or password is incorrect."}
- Read
- Write
GET /:package
HTTP/1.1 200 OK
Etag: "8UDCP753LFXOG42NMX88JAN40"
{
"_id": "pedding",
"_rev": "11-e6d1e6e96eaf72433fef6aaabe843af8",
"name": "pedding",
"description": "Just pedding for callback.",
"dist-tags": {
"latest": "1.0.0"
},
"versions": {
"1.0.0": {
"name": "pedding",
"version": "1.0.0",
"description": "Just pedding for callback.",
"main": "index.js",
"scripts": {
"test": "make test-all"
},
"repository": {
"type": "git",
"url": "git://github.com/fengmk2/pedding.git"
},
"keywords": [
"pedding",
"callback"
],
"devDependencies": {
"contributors": "*",
"mocha": "*",
"mocha-phantomjs": "*",
"component": "*",
"chai": "*"
},
"author": {
"name": "fengmk2",
"email": "[email protected]"
},
"license": "MIT",
"contributors": [
{
"name": "fengmk2",
"email": "[email protected]",
"url": "https://github.com/fengmk2"
},
{
"name": "dead-horse",
"email": "[email protected]",
"url": "https://github.com/dead-horse"
}
],
"gitHead": "b42a708414a704336e9dee570a963e2dbe43e529",
"bugs": {
"url": "https://github.com/fengmk2/pedding/issues"
},
"homepage": "https://github.com/fengmk2/pedding",
"_id": "[email protected]",
"_shasum": "7f5098d60307b4ef7240c3d693cb20a9473c6074",
"_from": ".",
"_npmVersion": "1.4.13",
"_npmUser": {
"name": "fengmk2",
"email": "[email protected]"
},
"maintainers": [
{
"name": "fengmk2",
"email": "[email protected]"
},
{
"name": "dead-horse",
"email": "[email protected]"
}
],
"dist": {
"shasum": "7f5098d60307b4ef7240c3d693cb20a9473c6074",
"tarball": "http://registry.npmjs.org/pedding/-/pedding-1.0.0.tgz"
},
"directories": {}
}
},
"readme": "# pedding\n readme...",
"maintainers": [
{
"name": "fengmk2",
"email": "[email protected]"
},
{
"name": "dead-horse",
"email": "[email protected]"
},
{
"name": "dead_horse",
"email": "[email protected]"
}
],
"time": {
"modified": "2014-07-05T14:22:53.849Z",
"created": "2012-09-18T14:46:08.346Z",
"0.0.1": "2012-09-18T14:46:21.321Z",
"0.0.2": "2013-06-22T08:26:45.125Z",
"0.0.3": "2013-07-02T15:20:34.707Z",
"1.0.0": "2014-07-05T11:08:51.614Z"
},
"author": {
"name": "fengmk2",
"email": "[email protected]"
},
"repository": {
"type": "git",
"url": "git://github.com/fengmk2/pedding.git"
},
"keywords": [
"pedding",
"callback"
],
"bugs": {
"url": "https://github.com/fengmk2/pedding/issues"
},
"license": "MIT",
"readmeFilename": "README.md",
"homepage": "https://github.com/fengmk2/pedding",
"contributors": [
{
"name": "fengmk2",
"email": "[email protected]",
"url": "https://github.com/fengmk2"
},
{
"name": "dead-horse",
"email": "[email protected]",
"url": "https://github.com/dead-horse"
}
],
"_attachments": {}
}
HTTP/1.1 404 Object Not Found
{
"error": "not_found",
"reason": "document not found"
}
deprecated
GET /:package/:tag_or_version
HTTP/1.1 200 OK
Etag: "1WJ4JF535RO3BDZR2BARXSGLY"
Content-Type: application/json
Cache-Control: max-age=60
Content-Length: 1183
{
"name": "pedding",
"version": "1.0.0",
"description": "Just pedding for callback.",
"main": "index.js",
"scripts": {
"test": "make test-all"
},
"repository": {
"type": "git",
"url": "git://github.com/fengmk2/pedding.git"
},
"keywords": [
"pedding",
"callback"
],
"devDependencies": {
"contributors": "*",
"mocha": "*",
"mocha-phantomjs": "*",
"component": "*",
"chai": "*"
},
"author": {
"name": "fengmk2",
"email": "[email protected]"
},
"license": "MIT",
"contributors": [
{
"name": "fengmk2",
"email": "[email protected]",
"url": "https://github.com/fengmk2"
},
{
"name": "dead-horse",
"email": "[email protected]",
"url": "https://github.com/dead-horse"
}
],
"gitHead": "b42a708414a704336e9dee570a963e2dbe43e529",
"bugs": {
"url": "https://github.com/fengmk2/pedding/issues"
},
"homepage": "https://github.com/fengmk2/pedding",
"_id": "[email protected]",
"_shasum": "7f5098d60307b4ef7240c3d693cb20a9473c6074",
"_from": ".",
"_npmVersion": "1.4.13",
"_npmUser": {
"name": "fengmk2",
"email": "[email protected]"
},
"maintainers": [
{
"name": "fengmk2",
"email": "[email protected]"
},
{
"name": "dead-horse",
"email": "[email protected]"
}
],
"dist": {
"shasum": "7f5098d60307b4ef7240c3d693cb20a9473c6074",
"tarball": "http://registry.npmjs.org/pedding/-/pedding-1.0.0.tgz"
},
"directories": {}
}
- Authentication required.
PUT /:package
{
"_id": "pedding",
"name": "pedding",
"description": "Just pedding for callback.",
"dist-tags": {
"latest": "1.0.0"
},
"versions": {
"1.0.0": {
"name": "pedding",
"version": "1.0.0",
"description": "Just pedding for callback.",
"main": "index.js",
"scripts": {
"test": "make test-all"
},
"repository": {
"type": "git",
"url": "git://github.com/fengmk2/pedding.git"
},
"keywords": [ "pedding","callback" ],
"devDependencies": {
"contributors": "*",
"mocha": "*",
"mocha-phantomjs": "*",
"component": "*",
"chai": "*"
},
"dependencies": {},
"author": {
"name": "fengmk2",
"email": "[email protected]"
},
"license": "MIT",
"contributors": [
{
"name": "fengmk2",
"email": "[email protected]",
"url": "https://github.com/fengmk2"
},
{
"name": "dead-horse",
"email": "[email protected]",
"url": "https://github.com/dead-horse"
}
],
"readme": "# pedding ...",
"readmeFilename": "README.md",
"gitHead": "b42a708414a704336e9dee570a963e2dbe43e529",
"bugs": {
"url": "https://github.com/fengmk2/pedding/issues"
},
"homepage": "https://github.com/fengmk2/pedding",
"_id": "[email protected]",
"_shasum": "7f5098d60307b4ef7240c3d693cb20a9473c6074",
"_from": ".",
"_npmVersion": "1.5.0-alpha-4",
"_npmUser": {
"name": "admin",
"email": "[email protected]"
},
"maintainers": [
{
"name": "admin",
"email": "[email protected]"
}
],
"dist": {
"shasum": "7f5098d60307b4ef7240c3d693cb20a9473c6074",
"tarball": "https://registry.npmjs.org/pedding/-/pedding-1.0.0.tgz"
}
}
},
"readme": "# pedding ...",
"maintainers": [
{
"name": "admin",
"email": "[email protected]"
}
],
"_attachments": {
"pedding-1.0.0.tgz":{
"content_type": "application/octet-stream",
"data": "H4sIAAAAAAAAA+0aa3PbNjKf8Su...",
"length": 2107
}
}
}
Status: 201 Created
{
"ok": true,
"rev": "11-e6d1e6e96eaf72433fef6aaabe843af8"
}
- Authentication required.
PUT /:package/:tag
The total input body is the version
string which's setting to the tag.
"1.0.0"
Status: 201 Created
{
"ok": true
}
- Authentication required.
PUT /:package/-rev/:rev
{
"_id": "pedding",
"_rev": "11-e6d1e6e96eaf72433fef6aaabe843af8",
"maintainers":[
{ "name": "fengmk2", "email": "[email protected]" },
{ "name": "dead-horse", "email": "[email protected]" }
]
}
Status: 201 Created
{
"ok": true,
"id": "pedding",
"rev": "12-bb300a90c9aeb779748b83ec1b744039"
}
- Authentication required.
- In any delete, note that the version number still cannot be reused.
PUT /:package/-rev/:rev
Remove that specific version from the versions hash in the PUT
body.
Example for removing 0.0.1
version:
{
"_id": "pedding",
"_rev": "12-bb300a90c9aeb779748b83ec1b744039",
"name": "pedding",
"description": "desc",
"dist-tags": { "latest": "1.0.0" },
"maintainers":
[ ... ],
"time":
{ ... },
"users": {},
"author": { ... },
"repository": { ... },
"versions":
{ "1.0.0":
{ ... },
"0.0.3":
{ ... },
"0.0.2":
{ ... } },
"readme": "...",
"homepage": "https://github.com/fengmk2/pedding",
"bugs": { ... },
"license": "MIT" }
Status: 201 Created
{
"ok": true
}
- Authentication required.
- In any delete, note that the version number still cannot be reused.
DELETE /:package/-rev/:rev
Status: 201 Created
{
"ok": true
}
- Authentication required.
DELETE /:tgzfilepath/-rev/:rev
Exmaple for removing https://registry.npmjs.org/pedding/-/pedding-0.0.1.tgz
file:
DELETE /pedding/-/pedding-0.0.1.tgz/-rev/12-bb300a90c9aeb779748b83ec1b744039
Status: 200 OK
{
"ok": true
}
GET /-/all/since?stale=update_after&startkey=:startkey
startkey
is a ms timestamp
$ curl -i "https://registry.npmjs.org/-/all/since?stale=update_after&startkey=1407255748643"
HTTP/1.1 200 OK
{
"_updated": 1407255883282,
"bacon-and-eggs": {
"name": "bacon-and-eggs",
"description": "A functional reactive Twitter API client in node",
"dist-tags": {
"latest": "0.0.4"
},
"maintainers": [
{
"name": "mikegroseclose",
"email": "[email protected]"
}
],
"homepage": "http://github.com/mikegroseclose/bacon-and-eggs",
"keywords": [
"twitter",
"api",
"frp",
"functional",
"reactive",
"bacon",
"eggs",
"oauth",
"stream",
"streams"
],
"repository": {
"type": "git",
"url": "git://github.com/mikegroseclose/gulp-regex-replace.git"
},
"author": {
"name": "Mike Groseclose",
"email": "[email protected]",
"url": "http://mikegroseclose.com"
},
"bugs": {
"url": "https://github.com/mikegroseclose/gulp-regex-replace/issues"
},
"readmeFilename": "README.md",
"time": {
"modified": "2014-08-05T16:21:17.041Z"
},
"versions": {
"0.0.4": "latest"
}
},
"git-perm-rm": {
"name": "git-perm-rm",
"description": "Permanently remove a file or directory from a git repo including all related commit records.",
"dist-tags": {
"latest": "1.0.1"
},
"maintainers": [
{
"name": "kael",
"email": "[email protected]"
}
],
"homepage": "https://github.com/kaelzhang/git-perm-rm",
"keywords": [
"git",
"rm",
"git-perm-rm",
"remove",
"permanently"
],
"repository": {
"type": "git",
"url": "git://github.com/kaelzhang/git-perm-rm.git"
},
"author": {
"name": "Kael"
},
"bugs": {
"url": "https://github.com/kaelzhang/git-perm-rm/issues"
},
"license": "MIT",
"readmeFilename": "README.md",
"time": {
"modified": "2014-08-05T16:22:41.253Z"
},
"versions": {
"1.0.1": "latest"
}
}
}
GET /-/by-user/$username[|$another1[|$another2...]]
username
user name likefengmk2
- also support multi users by
name1|name2|name3
$ curl -i "https://registry.npmjs.org/-/by-user/czy88840616"
$ curl -i "https://registry.npmjs.org/-/by-user/czy88840616|fengmk2|dead-horse"
HTTP/1.1 200 OK
{
"czy88840616": [
"easyconf",
"egg",
"flag",
"gdp",
"generator-webx-vm",
"magic-cube",
"rim",
"tbuild",
"test-publish",
"velocity-parser",
"vmarket",
"wi"
]
}
- Authentication required.
GET /-/user/org.couchdb.user::username?write=true
HTTP/1.1 200 OK
ETag: "5-a31b61ba3c50b50f7fcaf185e079e17a"
{
"_id": "org.couchdb.user:npm-user-service-testuser",
"_rev": "5-a31b61ba3c50b50f7fcaf185e079e17a",
"password_scheme": "pbkdf2",
"iterations": 10,
"name": "npm-user-service-testuser",
"email": "[email protected]",
"type": "user",
"roles": [],
"date": "2015-01-04T08:28:51.378Z",
"password_scheme": "pbkdf2",
"iterations": 10,
"derived_key": "644157c126b93356e6eba2c59fdf1b7ec644ebf2",
"salt": "5d13874c0aa10751e35743bacd6eedd5"
}
HTTP/1.1 401 Unauthorized
{
"error": "unauthorized",
"reason": "Name or password is incorrect."
}
GET /-/user/org.couchdb.user::username
HTTP/1.1 200 OK
ETag: "32-984ee97e01aea166dcab6d1517c730e3"
{
"_id": "org.couchdb.user:fengmk2",
"_rev": "32-984ee97e01aea166dcab6d1517c730e3",
"name": "fengmk2",
"email": "[email protected]",
"type": "user",
"roles": [],
"date": "2014-08-04T10:43:07.063Z",
"fullname": "fengmk2",
"avatar": "https://secure.gravatar.com/avatar/95b9d41231617a05ced5604d242c9670?s=50&d=retro",
"freenode": "",
"github": "fengmk2",
"homepage": "http://fengmk2.github.com",
"twitter": "fengmk2",
"avatarMedium": "https://secure.gravatar.com/avatar/95b9d41231617a05ced5604d242c9670?s=100&d=retro",
"avatarLarge": "https://secure.gravatar.com/avatar/95b9d41231617a05ced5604d242c9670?s=496&d=retro",
"fields": [
{
"name": "fullname",
"value": "fengmk2",
"title": "Full Name",
"show": "fengmk2"
},
{
"name": "email",
"value": "[email protected]",
"title": "Email",
"show": "<a href=\"mailto:[email protected]\">[email protected]</a>"
},
{
"name": "github",
"value": "fengmk2",
"title": "Github",
"show": "<a rel=\"me\" href=\"https://github.com/fengmk2\">fengmk2</a>"
},
{
"name": "twitter",
"value": "fengmk2",
"title": "Twitter",
"show": "<a rel=\"me\" href=\"https://twitter.com/fengmk2\">@fengmk2</a>"
},
{
"name": "appdotnet",
"value": "",
"title": "App.net",
"show": ""
},
{
"name": "homepage",
"value": "http://fengmk2.github.com",
"title": "Homepage",
"show": "<a rel=\"me\" href=\"http://fengmk2.github.com/\">http://fengmk2.github.com</a>"
},
{
"name": "freenode",
"value": "",
"title": "IRC Handle",
"show": ""
}
],
"appdotnet": "fengmk2"
}
HTTP/1.1 404 Object Not Found
{
"error": "not_found",
"reason": "missing"
}
PUT /-/user/org.couchdb.user::username
{
"name": "admin",
"password": "123",
"email": "[email protected]",
"_id": "org.couchdb.user:admin",
"type": "user",
"roles": [],
"date": "2014-08-05T16:05:17.792Z"
}
Status: 201 Created
{
"ok": true,
"id": "org.couchdb.user:fengmk2",
"rev": "32-984ee97e01aea166dcab6d1517c730e3",
"token": "85d32fad-bd43-4dd7-9451-4f7d907313a2"
}
User already exists
HTTP/1.1 409 Conflict
{
"error": "conflict",
"reason": "Document update conflict."
}
- Authentication required.
PUT /-/user/org.couchdb.user::username/-rev/:rev
{
"name": "admin",
"password": "123",
"email": "[email protected]",
"_id": "org.couchdb.user:admin",
"type": "user",
"roles": [],
"date": "2014-08-05T16:05:17.792Z",
"_rev": "2-1a18c3d73ba42e863523a399ff3304d8"
}
Status: 201 Created
{
"ok": true,
"id": "org.couchdb.user:fengmk2",
"rev": "3-bb300a90c9aeb779748b83ec1b744039"
}
- Authentication required.
POST /-/npm/v1/tokens
{
"password": "123",
"readonly": false,
"cidr_whitelist": [
"127.0.0.1"
]
}
HTTP/1.1 200 OK
{
"token": "85d32fad-bd43-4dd7-9451-4f7d907313a2",
"key": "d06309a210570ef71cd9c7bd4849e7e96eeaa841976e63326436f6fd320dc4bbd452710e4e0fedc2efc2ea4a793b7159e95e9596e85e00dee26adc3f8afbb97f",
"cidr_whitelist": [ "127.0.0.1" ],
"created": "2015-01-04T08:28:51.378Z",
"updated": "2015-01-04T08:28:51.378Z",
"readonly": false
}
- Authentication required.
GET /-/npm/v1/tokens
perPage=10&page=0
{
"objects": [{
"token": "85d32f...7313a2",
"key": "d06309a210570ef71cd9c7bd4849e7e96eeaa841976e63326436f6fd320dc4bbd452710e4e0fedc2efc2ea4a793b7159e95e9596e85e00dee26adc3f8afbb97f",
"cidr_whitelist": [ "127.0.0.1" ],
"created": "2015-01-04T08:28:51.378Z",
"updated": "2015-01-04T08:28:51.378Z",
"readonly": false
}]
}
- Authentication required.
GET /-/npm/v1/tokens/token/:UUID
GET /downloads/range/:start::end/:pkgName
HTTP/1.1 200 OK
// /downloads/range/2024-01-01:2024-12-31/cnpmcore
{
"downloads": [
// ...
{ "day": "2024-01-03", "downloads": 2 },
{ "day": "2024-05-30", "downloads": 16 }
],
"versions": {
// ...
"3.61.1": [{ "day": "2024-05-30", "downloads": 5 }],
"3.61.2": [{ "day": "2024-05-30", "downloads": 5 }],
"3.61.3": [{ "day": "2024-05-30", "downloads": 6 }]
}
}