1
- :orphan:
2
-
3
1
API v3
4
2
======
5
3
6
4
The Read the Docs API uses :abbr: `REST ( Representational State Transfer ) `.
7
5
JSON is returned by all API responses including errors
8
6
and HTTP response status codes are to designate success and failure.
9
7
10
- .. warning ::
11
-
12
- APIv3 is currently under development and it's not ready to use yet.
13
-
14
-
15
- .. note ::
16
-
17
- If you want to beta test it, please `get in touch `_ with us so we can give you early access.
18
-
19
- .. _
get in touch :
mailto:[email protected] ?subject=APIv3%20beta%20test
20
-
21
8
.. contents :: Table of contents
22
9
:local:
23
10
:backlinks: none
37
24
The ``Authorization `` HTTP header can be specified with ``Token <your-access-token> ``
38
25
to authenticate as a user and have the same permissions that the user itself.
39
26
27
+ .. note ::
28
+
29
+ You will find your access Token under
30
+ `your profile settings <https://readthedocs.org/accounts/tokens/ >`_.
31
+
40
32
41
33
Session
42
34
~~~~~~~
@@ -55,6 +47,27 @@ When a user is trying to authenticate via session,
55
47
Resources
56
48
---------
57
49
50
+ This section shows all the resources that are currently available in APIv3.
51
+ There are some URL attributes that applies to all of these resources:
52
+
53
+ :?fields=:
54
+
55
+ Specify which fields are going to be returned in the response.
56
+
57
+ :?omit=:
58
+
59
+ Specify which fields are going to be omitted from the response.
60
+
61
+ :?expand=:
62
+
63
+ Some resources allow to expand/add extra fields on their responses (see `Project details <#project-details >`__ for example).
64
+
65
+
66
+ .. tip ::
67
+
68
+ You can browse the full API by accessing its root URL: https://readthedocs.org/api/v3/
69
+
70
+
58
71
Projects
59
72
~~~~~~~~
60
73
@@ -82,21 +95,8 @@ Projects list
82
95
"results": ["PROJECT"]
83
96
}
84
97
85
- :>json integer count: total number of projects.
86
- :>json string next: URI for next set of projects.
87
- :>json string previous: URI for previous set of projects.
88
- :>json array results: array of ``project `` objects.
89
-
90
- :query string name: name of the project.
91
- :query string name__contains: part of the name of the project.
92
- :query string slug: slug of the project.
93
- :query string slug__contains: part of the slug of the project.
94
98
:query string language: language code as ``en ``, ``es ``, ``ru ``, etc.
95
- :query string privacy_level: one of ``public ``, ``private ``, ``protected ``.
96
99
:query string programming_language: programming language code as ``py ``, ``js ``, etc.
97
- :query string repository_type: one of ``git ``, ``hg ``, ``bzr ``, ``svn ``.
98
-
99
- :requestheader Authorization: token to authenticate.
100
100
101
101
102
102
Project details
@@ -136,10 +136,6 @@ Project details
136
136
},
137
137
"default_version": "stable",
138
138
"default_branch": "master",
139
- "privacy_level": {
140
- "code": "public",
141
- "name": "Public",
142
- },
143
139
"subproject_of": null,
144
140
"translation_of": null,
145
141
"urls": {
@@ -174,23 +170,17 @@ Project details
174
170
}
175
171
}
176
172
177
- :>json string name: The name of the project.
178
- :>json string slug: The project slug (used in the URL).
179
-
180
- .. TODO: complete the returned data docs once agreed on this.
181
-
182
- :requestheader Authorization: token to authenticate.
183
-
184
- :statuscode 200: Success
185
- :statuscode 404: There is no ``Project `` with this slug
173
+ :query string expand: allows to add/expand some extra fields in the response.
174
+ Allowed values are ``active_versions ``, ``active_versions.last_build `` and
175
+ ``active_versions.last_build.config ``. Multiple fields can be passed separated by commas.
186
176
187
177
188
178
Project create
189
179
++++++++++++++
190
180
191
181
.. http :post :: /api/v3/projects/
192
182
193
- Import a project into Read the Docs .
183
+ Import a project under authenticated user .
194
184
195
185
**Example request **:
196
186
@@ -219,13 +209,7 @@ Project create
219
209
220
210
**Example response **:
221
211
222
- `See Project details <#project-details >`_
223
-
224
- :requestheader Authorization: token to authenticate.
225
-
226
- :statuscode 201: Created
227
- :statuscode 400: Some field is invalid
228
-
212
+ `See Project details <#project-details >`__
229
213
230
214
Project update
231
215
++++++++++++++
@@ -292,17 +276,8 @@ Versions listing
292
276
"results": ["VERSION"]
293
277
}
294
278
295
- :>json integer count: Total number of Projects.
296
- :>json string next: URI for next set of Projects.
297
- :>json string previous: URI for previous set of Projects.
298
- :>json array results: Array of ``Version `` objects.
299
-
300
- :query integer limit: limit number of object returned
301
- :query integer offset: offset from the whole list returned
302
- :query boolean active: whether return active versions only
303
- :query boolean built: whether return only built version
304
-
305
- :requestheader Authorization: token to authenticate.
279
+ :query boolean active: return only active versions
280
+ :query boolean built: return only built versions
306
281
307
282
308
283
Version detail
@@ -366,19 +341,23 @@ Version update
366
341
367
342
**Example request **:
368
343
344
+ .. sourcecode :: bash
345
+
346
+ $ curl \
347
+ -X PATCH \
348
+ -H "Authorization: Token <token>" https://readthedocs.org/api/v3/projects/pip/version/0.23/ \
349
+ -H "Content-Type: application/json" \
350
+ -d @body.json
351
+
352
+ The content of ``body.json `` is like,
353
+
369
354
.. sourcecode :: json
370
355
371
356
{
372
357
"active": true,
373
- "privacy_level": "public"
374
358
}
375
359
376
- :requestheader Authorization: token to authenticate.
377
-
378
360
:statuscode 204: Updated successfully
379
- :statuscode 400: Some field is invalid
380
- :statuscode 401: Not valid permissions
381
- :statuscode 404: There is no ``Version `` with this slug for this project
382
361
383
362
384
363
Builds
@@ -468,22 +447,14 @@ Build details
468
447
}
469
448
}
470
449
471
- :>json integer id : The ID of the build
472
- :>json string date : The ISO-8601 datetime of the build.
450
+ :>json string created : The ISO-8601 datetime when the build was created.
451
+ :>json string finished : The ISO-8601 datetime when the build has finished .
473
452
:>json integer duration: The length of the build in seconds.
474
453
:>json string state: The state of the build (one of ``triggered ``, ``building ``, ``installing ``, ``cloning ``, or ``finished ``)
475
- :>json boolean success: Whether the build was successful
476
454
:>json string error: An error message if the build was unsuccessful
477
- :>json string commit: A version control identifier for this build (eg. the commit hash)
478
- :>json string builder: The hostname server that built the docs
479
- :>json string cold_storage: Whether the build was removed from database and stored externally
480
-
481
- :query boolean include_config: whether or not include the configs used for this build. Default is ``false ``
482
455
483
- :requestheader Authorization: token to authenticate.
484
-
485
- :statuscode 200: Success
486
- :statuscode 404: There is no ``Build `` with this ID
456
+ :query string expand: allows to add/expand some extra fields in the response.
457
+ Allowed value is ``config ``.
487
458
488
459
489
460
Builds listing
@@ -511,9 +482,7 @@ Builds listing
511
482
}
512
483
513
484
:query string commit: commit hash to filter the builds returned by commit
514
- :query boolean running: whether or not to filter the builds returned by currently building
515
-
516
- :requestheader Authorization: token to authenticate.
485
+ :query boolean running: filter the builds that are currently building/running
517
486
518
487
519
488
Build triggering
@@ -534,13 +503,15 @@ Build triggering
534
503
535
504
**Example response **:
536
505
537
- ` See Build details < #build-details >`_
506
+ .. sourcecode :: json
538
507
539
- :requestheader Authorization: token to authenticate.
508
+ {
509
+ "build": "{BUILD}",
510
+ "project": "{PROJECT}",
511
+ "version": "{VERSION}"
512
+ }
540
513
541
- :statuscode 202: Accepted
542
- :statuscode 400: Some field is invalid
543
- :statuscode 401: Not valid permissions
514
+ :statuscode 202: the build was triggered
544
515
545
516
546
517
Subprojects
@@ -693,13 +664,6 @@ Translations listing
693
664
"results": ["PROJECT"]
694
665
}
695
666
696
- :>json integer count: total number of projects.
697
- :>json string next: URI for next set of projects.
698
- :>json string previous: URI for previous set of projects.
699
- :>json array results: array of ``project `` objects.
700
-
701
- :requestheader Authorization: token to authenticate.
702
-
703
667
704
668
Redirects
705
669
~~~~~~~~~
@@ -791,14 +755,21 @@ Redirect create
791
755
"type": "page"
792
756
}
793
757
758
+ .. note ::
759
+
760
+ ``type `` can be one of ``prefix ``, ``page ``, ``exact ``, ``sphinx_html `` and ``sphinx_htmldir ``.
761
+
762
+ Depending on the ``type `` of the redirect, some fields may not be needed:
763
+
764
+ * ``prefix `` type does not require ``to_url ``.
765
+ * ``page `` and ``exact `` types require ``from_url `` and ``to_url ``.
766
+ * ``sphinx_html `` and ``sphinx_htmldir `` types do not require ``from_url `` and ``to_url ``.
767
+
794
768
**Example response **:
795
769
796
770
`See Redirect details <#redirect-details >`_
797
771
798
- :requestheader Authorization: token to authenticate.
799
-
800
- :statuscode 201: Created
801
- :statuscode 400: Some field is invalid
772
+ :statuscode 201: redirect created successfully
802
773
803
774
804
775
Redirect update
@@ -832,12 +803,6 @@ Redirect update
832
803
833
804
`See Redirect details <#redirect-details >`_
834
805
835
- :requestheader Authorization: token to authenticate.
836
-
837
- :statuscode 200: Success
838
- :statuscode 400: Some field is invalid
839
-
840
-
841
806
Redirect delete
842
807
++++++++++++++++
843
808
@@ -853,9 +818,7 @@ Redirect delete
853
818
-X DELETE \
854
819
-H "Authorization: Token <token>" https://readthedocs.org/api/v3/projects/pip/redirects/1/
855
820
856
- :requestheader Authorization: token to authenticate.
857
-
858
- :statuscode 204: Deleted successfully
821
+ :statuscode 204: Redirect deleted successfully
859
822
860
823
861
824
Environment Variables
@@ -950,10 +913,7 @@ Environment Variable create
950
913
951
914
`See Environment Variable details <#environmentvariable-details >`_
952
915
953
- :requestheader Authorization: token to authenticate.
954
-
955
- :statuscode 201: Created
956
- :statuscode 400: Some field is invalid
916
+ :statuscode 201: Environment variable created successfully
957
917
958
918
959
919
Environment Variable delete
@@ -973,4 +933,4 @@ Environment Variable delete
973
933
974
934
:requestheader Authorization: token to authenticate.
975
935
976
- :statuscode 204: Deleted successfully
936
+ :statuscode 204: Environment variable deleted successfully
0 commit comments