github.com/slene/docker@v1.8.0-rc1/docs/reference/api/docker-io_api.md (about) 1 <!--[metadata]> 2 +++ 3 title = "Docker Hub API" 4 description = "API Documentation for the Docker Hub API" 5 keywords = ["API, Docker, index, REST, documentation, Docker Hub, registry"] 6 [menu.main] 7 parent = "smn_remoteapi" 8 +++ 9 <![end-metadata]--> 10 11 # Docker Hub API 12 13 - This is the REST API for [Docker Hub](https://hub.docker.com). 14 - Authorization is done with basic auth over SSL 15 - Not all commands require authentication, only those noted as such. 16 17 # Repositories 18 19 ## User repository 20 21 ### Create a user repository 22 23 `PUT /v1/repositories/(namespace)/(repo_name)/` 24 25 Create a user repository with the given `namespace` and `repo_name`. 26 27 **Example Request**: 28 29 PUT /v1/repositories/foo/bar/ HTTP/1.1 30 Host: index.docker.io 31 Accept: application/json 32 Content-Type: application/json 33 Authorization: Basic akmklmasadalkm== 34 X-Docker-Token: true 35 36 [{"id": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f"}] 37 38 Parameters: 39 40 - **namespace** – the namespace for the repo 41 - **repo_name** – the name for the repo 42 43 **Example Response**: 44 45 HTTP/1.1 200 46 Vary: Accept 47 Content-Type: application/json 48 WWW-Authenticate: Token signature=123abc,repository="foo/bar",access=write 49 X-Docker-Token: signature=123abc,repository="foo/bar",access=write 50 X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io] 51 52 "" 53 54 Status Codes: 55 56 - **200** – Created 57 - **400** – Errors (invalid json, missing or invalid fields, etc) 58 - **401** – Unauthorized 59 - **403** – Account is not Active 60 61 ### Delete a user repository 62 63 `DELETE /v1/repositories/(namespace)/(repo_name)/` 64 65 Delete a user repository with the given `namespace` and `repo_name`. 66 67 **Example Request**: 68 69 DELETE /v1/repositories/foo/bar/ HTTP/1.1 70 Host: index.docker.io 71 Accept: application/json 72 Content-Type: application/json 73 Authorization: Basic akmklmasadalkm== 74 X-Docker-Token: true 75 76 "" 77 78 Parameters: 79 80 - **namespace** – the namespace for the repo 81 - **repo_name** – the name for the repo 82 83 **Example Response**: 84 85 HTTP/1.1 202 86 Vary: Accept 87 Content-Type: application/json 88 WWW-Authenticate: Token signature=123abc,repository="foo/bar",access=delete 89 X-Docker-Token: signature=123abc,repository="foo/bar",access=delete 90 X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io] 91 92 "" 93 94 Status Codes: 95 96 - **200** – Deleted 97 - **202** – Accepted 98 - **400** – Errors (invalid json, missing or invalid fields, etc) 99 - **401** – Unauthorized 100 - **403** – Account is not Active 101 102 ## Library repository 103 104 ### Create a library repository 105 106 `PUT /v1/repositories/(repo_name)/` 107 108 Create a library repository with the given `repo_name`. 109 This is a restricted feature only available to docker admins. 110 111 > When namespace is missing, it is assumed to be `library` 112 113 114 **Example Request**: 115 116 PUT /v1/repositories/foobar/ HTTP/1.1 117 Host: index.docker.io 118 Accept: application/json 119 Content-Type: application/json 120 Authorization: Basic akmklmasadalkm== 121 X-Docker-Token: true 122 123 [{"id": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f"}] 124 125 Parameters: 126 127 - **repo_name** – the library name for the repo 128 129 **Example Response**: 130 131 HTTP/1.1 200 132 Vary: Accept 133 Content-Type: application/json 134 WWW-Authenticate: Token signature=123abc,repository="library/foobar",access=write 135 X-Docker-Token: signature=123abc,repository="foo/bar",access=write 136 X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io] 137 138 "" 139 140 Status Codes: 141 142 - **200** – Created 143 - **400** – Errors (invalid json, missing or invalid fields, etc) 144 - **401** – Unauthorized 145 - **403** – Account is not Active 146 147 ### Delete a library repository 148 149 `DELETE /v1/repositories/(repo_name)/` 150 151 Delete a library repository with the given `repo_name`. 152 This is a restricted feature only available to docker admins. 153 154 > When namespace is missing, it is assumed to be `library` 155 156 157 **Example Request**: 158 159 DELETE /v1/repositories/foobar/ HTTP/1.1 160 Host: index.docker.io 161 Accept: application/json 162 Content-Type: application/json 163 Authorization: Basic akmklmasadalkm== 164 X-Docker-Token: true 165 166 "" 167 168 Parameters: 169 170 - **repo_name** – the library name for the repo 171 172 **Example Response**: 173 174 HTTP/1.1 202 175 Vary: Accept 176 Content-Type: application/json 177 WWW-Authenticate: Token signature=123abc,repository="library/foobar",access=delete 178 X-Docker-Token: signature=123abc,repository="foo/bar",access=delete 179 X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io] 180 181 "" 182 183 Status Codes: 184 185 - **200** – Deleted 186 - **202** – Accepted 187 - **400** – Errors (invalid json, missing or invalid fields, etc) 188 - **401** – Unauthorized 189 - **403** – Account is not Active 190 191 # Repository images 192 193 ## User repository images 194 195 ### Update user repository images 196 197 `PUT /v1/repositories/(namespace)/(repo_name)/images` 198 199 Update the images for a user repo. 200 201 **Example Request**: 202 203 PUT /v1/repositories/foo/bar/images HTTP/1.1 204 Host: index.docker.io 205 Accept: application/json 206 Content-Type: application/json 207 Authorization: Basic akmklmasadalkm== 208 209 [{"id": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f", 210 "checksum": "b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087"}] 211 212 Parameters: 213 214 - **namespace** – the namespace for the repo 215 - **repo_name** – the name for the repo 216 217 **Example Response**: 218 219 HTTP/1.1 204 220 Vary: Accept 221 Content-Type: application/json 222 223 "" 224 225 Status Codes: 226 227 - **204** – Created 228 - **400** – Errors (invalid json, missing or invalid fields, etc) 229 - **401** – Unauthorized 230 - **403** – Account is not Active or permission denied 231 232 ### List user repository images 233 234 `GET /v1/repositories/(namespace)/(repo_name)/images` 235 236 Get the images for a user repo. 237 238 **Example Request**: 239 240 GET /v1/repositories/foo/bar/images HTTP/1.1 241 Host: index.docker.io 242 Accept: application/json 243 244 Parameters: 245 246 - **namespace** – the namespace for the repo 247 - **repo_name** – the name for the repo 248 249 **Example Response**: 250 251 HTTP/1.1 200 252 Vary: Accept 253 Content-Type: application/json 254 255 [{"id": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f", 256 "checksum": "b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087"}, 257 {"id": "ertwetewtwe38722009fe6857087b486531f9a779a0c1dfddgfgsdgdsgds", 258 "checksum": "34t23f23fc17e3ed29dae8f12c4f9e89cc6f0bsdfgfsdgdsgdsgerwgew"}] 259 260 Status Codes: 261 262 - **200** – OK 263 - **404** – Not found 264 265 ## Library repository images 266 267 ### Update library repository images 268 269 `PUT /v1/repositories/(repo_name)/images` 270 271 Update the images for a library repo. 272 273 **Example Request**: 274 275 PUT /v1/repositories/foobar/images HTTP/1.1 276 Host: index.docker.io 277 Accept: application/json 278 Content-Type: application/json 279 Authorization: Basic akmklmasadalkm== 280 281 [{"id": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f", 282 "checksum": "b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087"}] 283 284 Parameters: 285 286 - **repo_name** – the library name for the repo 287 288 **Example Response**: 289 290 HTTP/1.1 204 291 Vary: Accept 292 Content-Type: application/json 293 294 "" 295 296 Status Codes: 297 298 - **204** – Created 299 - **400** – Errors (invalid json, missing or invalid fields, etc) 300 - **401** – Unauthorized 301 - **403** – Account is not Active or permission denied 302 303 ### List library repository images 304 305 `GET /v1/repositories/(repo_name)/images` 306 307 Get the images for a library repo. 308 309 **Example Request**: 310 311 GET /v1/repositories/foobar/images HTTP/1.1 312 Host: index.docker.io 313 Accept: application/json 314 315 Parameters: 316 317 - **repo_name** – the library name for the repo 318 319 **Example Response**: 320 321 HTTP/1.1 200 322 Vary: Accept 323 Content-Type: application/json 324 325 [{"id": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f", 326 "checksum": "b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087"}, 327 {"id": "ertwetewtwe38722009fe6857087b486531f9a779a0c1dfddgfgsdgdsgds", 328 "checksum": "34t23f23fc17e3ed29dae8f12c4f9e89cc6f0bsdfgfsdgdsgdsgerwgew"}] 329 330 Status Codes: 331 332 - **200** – OK 333 - **404** – Not found 334 335 # Repository authorization 336 337 ## Library repository 338 339 ### Authorize a token for a library 340 341 `PUT /v1/repositories/(repo_name)/auth` 342 343 Authorize a token for a library repo 344 345 **Example Request**: 346 347 PUT /v1/repositories/foobar/auth HTTP/1.1 348 Host: index.docker.io 349 Accept: application/json 350 Authorization: Token signature=123abc,repository="library/foobar",access=write 351 352 Parameters: 353 354 - **repo_name** – the library name for the repo 355 356 **Example Response**: 357 358 HTTP/1.1 200 359 Vary: Accept 360 Content-Type: application/json 361 362 "OK" 363 364 Status Codes: 365 366 - **200** – OK 367 - **403** – Permission denied 368 - **404** – Not found 369 370 ## User repository 371 372 ### Authorize a token for a user repository 373 374 `PUT /v1/repositories/(namespace)/(repo_name)/auth` 375 376 Authorize a token for a user repo 377 378 **Example Request**: 379 380 PUT /v1/repositories/foo/bar/auth HTTP/1.1 381 Host: index.docker.io 382 Accept: application/json 383 Authorization: Token signature=123abc,repository="foo/bar",access=write 384 385 Parameters: 386 387 - **namespace** – the namespace for the repo 388 - **repo_name** – the name for the repo 389 390 **Example Response**: 391 392 HTTP/1.1 200 393 Vary: Accept 394 Content-Type: application/json 395 396 "OK" 397 398 Status Codes: 399 400 - **200** – OK 401 - **403** – Permission denied 402 - **404** – Not found 403 404 ## Users 405 406 ### User login 407 408 `GET /v1/users/` 409 410 If you want to check your login, you can try this endpoint 411 412 **Example Request**: 413 414 GET /v1/users/ HTTP/1.1 415 Host: index.docker.io 416 Accept: application/json 417 Authorization: Basic akmklmasadalkm== 418 419 **Example Response**: 420 421 HTTP/1.1 200 OK 422 Vary: Accept 423 Content-Type: application/json 424 425 OK 426 427 Status Codes: 428 429 - **200** – no error 430 - **401** – Unauthorized 431 - **403** – Account is not Active 432 433 ### User register 434 435 `POST /v1/users/` 436 437 Registering a new account. 438 439 **Example request**: 440 441 POST /v1/users/ HTTP/1.1 442 Host: index.docker.io 443 Accept: application/json 444 Content-Type: application/json 445 446 {"email": "sam@docker.com", 447 "password": "toto42", 448 "username": "foobar"} 449 450 Json Parameters: 451 452 - **email** – valid email address, that needs to be confirmed 453 - **username** – min 4 character, max 30 characters, must match 454 the regular expression [a-z0-9_]. 455 - **password** – min 5 characters 456 457 **Example Response**: 458 459 HTTP/1.1 201 OK 460 Vary: Accept 461 Content-Type: application/json 462 463 "User Created" 464 465 Status Codes: 466 467 - **201** – User Created 468 - **400** – Errors (invalid json, missing or invalid fields, etc) 469 470 ### Update user 471 472 `PUT /v1/users/(username)/` 473 474 Change a password or email address for given user. If you pass in an 475 email, it will add it to your account, it will not remove the old 476 one. Passwords will be updated. 477 478 It is up to the client to verify that that password that is sent is 479 the one that they want. Common approach is to have them type it 480 twice. 481 482 **Example Request**: 483 484 PUT /v1/users/fakeuser/ HTTP/1.1 485 Host: index.docker.io 486 Accept: application/json 487 Content-Type: application/json 488 Authorization: Basic akmklmasadalkm== 489 490 {"email": "sam@docker.com", 491 "password": "toto42"} 492 493 Parameters: 494 495 - **username** – username for the person you want to update 496 497 **Example Response**: 498 499 HTTP/1.1 204 500 Vary: Accept 501 Content-Type: application/json 502 503 "" 504 505 Status Codes: 506 507 - **204** – User Updated 508 - **400** – Errors (invalid json, missing or invalid fields, etc) 509 - **401** – Unauthorized 510 - **403** – Account is not Active 511 - **404** – User not found