index_api.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. :title: Index API
  2. :description: API Documentation for Docker Index
  3. :keywords: API, Docker, index, REST, documentation
  4. =================
  5. Docker Index API
  6. =================
  7. 1. Brief introduction
  8. =====================
  9. - This is the REST API for the Docker index
  10. - Authorization is done with basic auth over SSL
  11. - Not all commands require authentication, only those noted as such.
  12. 2. Endpoints
  13. ============
  14. 2.1 Repository
  15. ^^^^^^^^^^^^^^
  16. Repositories
  17. *************
  18. User Repo
  19. ~~~~~~~~~
  20. .. http:put:: /v1/repositories/(namespace)/(repo_name)/
  21. Create a user repository with the given ``namespace`` and ``repo_name``.
  22. **Example Request**:
  23. .. sourcecode:: http
  24. PUT /v1/repositories/foo/bar/ HTTP/1.1
  25. Host: index.docker.io
  26. Accept: application/json
  27. Content-Type: application/json
  28. Authorization: Basic akmklmasadalkm==
  29. X-Docker-Token: true
  30. [{"id": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f"}]
  31. :parameter namespace: the namespace for the repo
  32. :parameter repo_name: the name for the repo
  33. **Example Response**:
  34. .. sourcecode:: http
  35. HTTP/1.1 200
  36. Vary: Accept
  37. Content-Type: application/json
  38. WWW-Authenticate: Token signature=123abc,repository="foo/bar",access=write
  39. X-Docker-Token: signature=123abc,repository="foo/bar",access=write
  40. X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io]
  41. ""
  42. :statuscode 200: Created
  43. :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
  44. :statuscode 401: Unauthorized
  45. :statuscode 403: Account is not Active
  46. .. http:delete:: /v1/repositories/(namespace)/(repo_name)/
  47. Delete a user repository with the given ``namespace`` and ``repo_name``.
  48. **Example Request**:
  49. .. sourcecode:: http
  50. DELETE /v1/repositories/foo/bar/ HTTP/1.1
  51. Host: index.docker.io
  52. Accept: application/json
  53. Content-Type: application/json
  54. Authorization: Basic akmklmasadalkm==
  55. X-Docker-Token: true
  56. ""
  57. :parameter namespace: the namespace for the repo
  58. :parameter repo_name: the name for the repo
  59. **Example Response**:
  60. .. sourcecode:: http
  61. HTTP/1.1 202
  62. Vary: Accept
  63. Content-Type: application/json
  64. WWW-Authenticate: Token signature=123abc,repository="foo/bar",access=delete
  65. X-Docker-Token: signature=123abc,repository="foo/bar",access=delete
  66. X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io]
  67. ""
  68. :statuscode 200: Deleted
  69. :statuscode 202: Accepted
  70. :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
  71. :statuscode 401: Unauthorized
  72. :statuscode 403: Account is not Active
  73. Library Repo
  74. ~~~~~~~~~~~~
  75. .. http:put:: /v1/repositories/(repo_name)/
  76. Create a library repository with the given ``repo_name``.
  77. This is a restricted feature only available to docker admins.
  78. When namespace is missing, it is assumed to be ``library``
  79. **Example Request**:
  80. .. sourcecode:: http
  81. PUT /v1/repositories/foobar/ HTTP/1.1
  82. Host: index.docker.io
  83. Accept: application/json
  84. Content-Type: application/json
  85. Authorization: Basic akmklmasadalkm==
  86. X-Docker-Token: true
  87. [{"id": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f"}]
  88. :parameter repo_name: the library name for the repo
  89. **Example Response**:
  90. .. sourcecode:: http
  91. HTTP/1.1 200
  92. Vary: Accept
  93. Content-Type: application/json
  94. WWW-Authenticate: Token signature=123abc,repository="library/foobar",access=write
  95. X-Docker-Token: signature=123abc,repository="foo/bar",access=write
  96. X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io]
  97. ""
  98. :statuscode 200: Created
  99. :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
  100. :statuscode 401: Unauthorized
  101. :statuscode 403: Account is not Active
  102. .. http:delete:: /v1/repositories/(repo_name)/
  103. Delete a library repository with the given ``repo_name``.
  104. This is a restricted feature only available to docker admins.
  105. When namespace is missing, it is assumed to be ``library``
  106. **Example Request**:
  107. .. sourcecode:: http
  108. DELETE /v1/repositories/foobar/ HTTP/1.1
  109. Host: index.docker.io
  110. Accept: application/json
  111. Content-Type: application/json
  112. Authorization: Basic akmklmasadalkm==
  113. X-Docker-Token: true
  114. ""
  115. :parameter repo_name: the library name for the repo
  116. **Example Response**:
  117. .. sourcecode:: http
  118. HTTP/1.1 202
  119. Vary: Accept
  120. Content-Type: application/json
  121. WWW-Authenticate: Token signature=123abc,repository="library/foobar",access=delete
  122. X-Docker-Token: signature=123abc,repository="foo/bar",access=delete
  123. X-Docker-Endpoints: registry-1.docker.io [, registry-2.docker.io]
  124. ""
  125. :statuscode 200: Deleted
  126. :statuscode 202: Accepted
  127. :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
  128. :statuscode 401: Unauthorized
  129. :statuscode 403: Account is not Active
  130. Repository Images
  131. *****************
  132. User Repo Images
  133. ~~~~~~~~~~~~~~~~
  134. .. http:put:: /v1/repositories/(namespace)/(repo_name)/images
  135. Update the images for a user repo.
  136. **Example Request**:
  137. .. sourcecode:: http
  138. PUT /v1/repositories/foo/bar/images HTTP/1.1
  139. Host: index.docker.io
  140. Accept: application/json
  141. Content-Type: application/json
  142. Authorization: Basic akmklmasadalkm==
  143. [{"id": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f",
  144. "checksum": "b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087"}]
  145. :parameter namespace: the namespace for the repo
  146. :parameter repo_name: the name for the repo
  147. **Example Response**:
  148. .. sourcecode:: http
  149. HTTP/1.1 204
  150. Vary: Accept
  151. Content-Type: application/json
  152. ""
  153. :statuscode 204: Created
  154. :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
  155. :statuscode 401: Unauthorized
  156. :statuscode 403: Account is not Active or permission denied
  157. .. http:get:: /v1/repositories/(namespace)/(repo_name)/images
  158. get the images for a user repo.
  159. **Example Request**:
  160. .. sourcecode:: http
  161. GET /v1/repositories/foo/bar/images HTTP/1.1
  162. Host: index.docker.io
  163. Accept: application/json
  164. :parameter namespace: the namespace for the repo
  165. :parameter repo_name: the name for the repo
  166. **Example Response**:
  167. .. sourcecode:: http
  168. HTTP/1.1 200
  169. Vary: Accept
  170. Content-Type: application/json
  171. [{"id": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f",
  172. "checksum": "b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087"},
  173. {"id": "ertwetewtwe38722009fe6857087b486531f9a779a0c1dfddgfgsdgdsgds",
  174. "checksum": "34t23f23fc17e3ed29dae8f12c4f9e89cc6f0bsdfgfsdgdsgdsgerwgew"}]
  175. :statuscode 200: OK
  176. :statuscode 404: Not found
  177. Library Repo Images
  178. ~~~~~~~~~~~~~~~~~~~
  179. .. http:put:: /v1/repositories/(repo_name)/images
  180. Update the images for a library repo.
  181. **Example Request**:
  182. .. sourcecode:: http
  183. PUT /v1/repositories/foobar/images HTTP/1.1
  184. Host: index.docker.io
  185. Accept: application/json
  186. Content-Type: application/json
  187. Authorization: Basic akmklmasadalkm==
  188. [{"id": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f",
  189. "checksum": "b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087"}]
  190. :parameter repo_name: the library name for the repo
  191. **Example Response**:
  192. .. sourcecode:: http
  193. HTTP/1.1 204
  194. Vary: Accept
  195. Content-Type: application/json
  196. ""
  197. :statuscode 204: Created
  198. :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
  199. :statuscode 401: Unauthorized
  200. :statuscode 403: Account is not Active or permission denied
  201. .. http:get:: /v1/repositories/(repo_name)/images
  202. get the images for a library repo.
  203. **Example Request**:
  204. .. sourcecode:: http
  205. GET /v1/repositories/foobar/images HTTP/1.1
  206. Host: index.docker.io
  207. Accept: application/json
  208. :parameter repo_name: the library name for the repo
  209. **Example Response**:
  210. .. sourcecode:: http
  211. HTTP/1.1 200
  212. Vary: Accept
  213. Content-Type: application/json
  214. [{"id": "9e89cc6f0bc3c38722009fe6857087b486531f9a779a0c17e3ed29dae8f12c4f",
  215. "checksum": "b486531f9a779a0c17e3ed29dae8f12c4f9e89cc6f0bc3c38722009fe6857087"},
  216. {"id": "ertwetewtwe38722009fe6857087b486531f9a779a0c1dfddgfgsdgdsgds",
  217. "checksum": "34t23f23fc17e3ed29dae8f12c4f9e89cc6f0bsdfgfsdgdsgdsgerwgew"}]
  218. :statuscode 200: OK
  219. :statuscode 404: Not found
  220. Repository Authorization
  221. ************************
  222. Library Repo
  223. ~~~~~~~~~~~~
  224. .. http:put:: /v1/repositories/(repo_name)/auth
  225. authorize a token for a library repo
  226. **Example Request**:
  227. .. sourcecode:: http
  228. PUT /v1/repositories/foobar/auth HTTP/1.1
  229. Host: index.docker.io
  230. Accept: application/json
  231. Authorization: Token signature=123abc,repository="library/foobar",access=write
  232. :parameter repo_name: the library name for the repo
  233. **Example Response**:
  234. .. sourcecode:: http
  235. HTTP/1.1 200
  236. Vary: Accept
  237. Content-Type: application/json
  238. "OK"
  239. :statuscode 200: OK
  240. :statuscode 403: Permission denied
  241. :statuscode 404: Not found
  242. User Repo
  243. ~~~~~~~~~
  244. .. http:put:: /v1/repositories/(namespace)/(repo_name)/auth
  245. authorize a token for a user repo
  246. **Example Request**:
  247. .. sourcecode:: http
  248. PUT /v1/repositories/foo/bar/auth HTTP/1.1
  249. Host: index.docker.io
  250. Accept: application/json
  251. Authorization: Token signature=123abc,repository="foo/bar",access=write
  252. :parameter namespace: the namespace for the repo
  253. :parameter repo_name: the name for the repo
  254. **Example Response**:
  255. .. sourcecode:: http
  256. HTTP/1.1 200
  257. Vary: Accept
  258. Content-Type: application/json
  259. "OK"
  260. :statuscode 200: OK
  261. :statuscode 403: Permission denied
  262. :statuscode 404: Not found
  263. 2.2 Users
  264. ^^^^^^^^^
  265. User Login
  266. **********
  267. .. http:get:: /v1/users
  268. If you want to check your login, you can try this endpoint
  269. **Example Request**:
  270. .. sourcecode:: http
  271. GET /v1/users HTTP/1.1
  272. Host: index.docker.io
  273. Accept: application/json
  274. Authorization: Basic akmklmasadalkm==
  275. **Example Response**:
  276. .. sourcecode:: http
  277. HTTP/1.1 200 OK
  278. Vary: Accept
  279. Content-Type: application/json
  280. OK
  281. :statuscode 200: no error
  282. :statuscode 401: Unauthorized
  283. :statuscode 403: Account is not Active
  284. User Register
  285. *************
  286. .. http:post:: /v1/users
  287. Registering a new account.
  288. **Example request**:
  289. .. sourcecode:: http
  290. POST /v1/users HTTP/1.1
  291. Host: index.docker.io
  292. Accept: application/json
  293. Content-Type: application/json
  294. {"email": "sam@dotcloud.com",
  295. "password": "toto42",
  296. "username": "foobar"'}
  297. :jsonparameter email: valid email address, that needs to be confirmed
  298. :jsonparameter username: min 4 character, max 30 characters, must match the regular expression [a-z0-9\_].
  299. :jsonparameter password: min 5 characters
  300. **Example Response**:
  301. .. sourcecode:: http
  302. HTTP/1.1 201 OK
  303. Vary: Accept
  304. Content-Type: application/json
  305. "User Created"
  306. :statuscode 201: User Created
  307. :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
  308. Update User
  309. ***********
  310. .. http:put:: /v1/users/(username)/
  311. Change a password or email address for given user. If you pass in an email,
  312. it will add it to your account, it will not remove the old one. Passwords will
  313. be updated.
  314. It is up to the client to verify that that password that is sent is the one that
  315. they want. Common approach is to have them type it twice.
  316. **Example Request**:
  317. .. sourcecode:: http
  318. PUT /v1/users/fakeuser/ HTTP/1.1
  319. Host: index.docker.io
  320. Accept: application/json
  321. Content-Type: application/json
  322. Authorization: Basic akmklmasadalkm==
  323. {"email": "sam@dotcloud.com",
  324. "password": "toto42"}
  325. :parameter username: username for the person you want to update
  326. **Example Response**:
  327. .. sourcecode:: http
  328. HTTP/1.1 204
  329. Vary: Accept
  330. Content-Type: application/json
  331. ""
  332. :statuscode 204: User Updated
  333. :statuscode 400: Errors (invalid json, missing or invalid fields, etc)
  334. :statuscode 401: Unauthorized
  335. :statuscode 403: Account is not Active
  336. :statuscode 404: User not found
  337. 2.3 Search
  338. ^^^^^^^^^^
  339. If you need to search the index, this is the endpoint you would use.
  340. Search
  341. ******
  342. .. http:get:: /v1/search
  343. Search the Index given a search term. It accepts :http:method:`get` only.
  344. **Example request**:
  345. .. sourcecode:: http
  346. GET /v1/search?q=search_term HTTP/1.1
  347. Host: example.com
  348. Accept: application/json
  349. **Example response**:
  350. .. sourcecode:: http
  351. HTTP/1.1 200 OK
  352. Vary: Accept
  353. Content-Type: application/json
  354. {"query":"search_term",
  355. "num_results": 3,
  356. "results" : [
  357. {"name": "ubuntu", "description": "An ubuntu image..."},
  358. {"name": "centos", "description": "A centos image..."},
  359. {"name": "fedora", "description": "A fedora image..."}
  360. ]
  361. }
  362. :query q: what you want to search for
  363. :statuscode 200: no error
  364. :statuscode 500: server error