index_api.rst 13 KB

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