index_api.rst 14 KB

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