diff --git a/docs/api/v3.rst b/docs/api/v3.rst index 63c0b385dfc..dc1360c3a47 100644 --- a/docs/api/v3.rst +++ b/docs/api/v3.rst @@ -80,9 +80,20 @@ Projects list **Example request**: - .. sourcecode:: bash + .. tabs:: - $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/ + .. code-tab:: bash + + $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/ + + .. code-tab:: python + + import requests + URL = 'https://readthedocs.org/api/v3/projects/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + response = requests.get(URL, headers=HEADERS) + print(response.json()) **Example response**: @@ -108,9 +119,20 @@ Project details **Example request**: - .. sourcecode:: bash + .. tabs:: + + .. code-tab:: bash + + $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/ - $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/ + .. code-tab:: python + + import requests + URL = 'https://readthedocs.org/api/v3/projects/pip/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + response = requests.get(URL, headers=HEADERS) + print(response.json()) **Example response**: @@ -184,13 +206,30 @@ Project create **Example request**: - .. sourcecode:: bash + .. tabs:: + + .. code-tab:: bash + + $ curl \ + -X POST \ + -H "Authorization: Token " https://readthedocs.org/api/v3/projects/ \ + -H "Content-Type: application/json" \ + -d @body.json + + .. code-tab:: python - $ curl \ - -X POST \ - -H "Authorization: Token " https://readthedocs.org/api/v3/projects/ \ - -H "Content-Type: application/json" \ - -d @body.json + import requests + import json + URL = 'https://readthedocs.org/api/v3/projects/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + data = json.load(open('body.json', 'rb')) + response = requests.post( + URL, + json=data, + headers=HEADERS, + ) + print(response.json()) The content of ``body.json`` is like, @@ -220,13 +259,30 @@ Project update **Example request**: - .. sourcecode:: bash + .. tabs:: - $ curl \ - -X PATCH \ - -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/ \ - -H "Content-Type: application/json" \ - -d @body.json + .. code-tab:: bash + + $ curl \ + -X PATCH \ + -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/ \ + -H "Content-Type: application/json" \ + -d @body.json + + .. code-tab:: python + + import requests + import json + URL = 'https://readthedocs.org/api/v3/projects/pip/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + data = json.load(open('body.json', 'rb')) + response = requests.patch( + URL, + json=data, + headers=HEADERS, + ) + print(response.json()) The content of ``body.json`` is like, @@ -272,9 +328,20 @@ Versions listing **Example request**: - .. sourcecode:: bash + .. tabs:: + + .. code-tab:: bash + + $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/versions/ - $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/versions/ + .. code-tab:: python + + import requests + URL = 'https://readthedocs.org/api/v3/projects/pip/versions/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + response = requests.get(URL, headers=HEADERS) + print(response.json()) **Example response**: @@ -300,9 +367,20 @@ Version detail **Example request**: - .. sourcecode:: bash + .. tabs:: + + .. code-tab:: bash + + $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/versions/stable/ + + .. code-tab:: python - $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/versions/stable/ + import requests + URL = 'https://readthedocs.org/api/v3/projects/pip/versions/stable/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + response = requests.get(URL, headers=HEADERS) + print(response.json()) **Example response**: @@ -352,13 +430,30 @@ Version update **Example request**: - .. sourcecode:: bash + .. tabs:: - $ curl \ - -X PATCH \ - -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/version/0.23/ \ - -H "Content-Type: application/json" \ - -d @body.json + .. code-tab:: bash + + $ curl \ + -X PATCH \ + -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/version/0.23/ \ + -H "Content-Type: application/json" \ + -d @body.json + + .. code-tab:: python + + import requests + import json + URL = 'https://readthedocs.org/api/v3/projects/pip/ersion/0.23/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + data = json.load(open('body.json', 'rb')) + response = requests.patch( + URL, + json=data, + headers=HEADERS, + ) + print(response.json()) The content of ``body.json`` is like, @@ -393,9 +488,20 @@ Build details **Example request**: - .. sourcecode:: bash + .. tabs:: + + .. code-tab:: bash + + $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/builds/8592686/?expand=config - $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/builds/8592686/?expand=config + .. code-tab:: python + + import requests + URL = 'https://readthedocs.org/api/v3/projects/pip/builds/8592686/?expand=config' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + response = requests.get(URL, headers=HEADERS) + print(response.json()) **Example response**: @@ -477,9 +583,20 @@ Builds listing **Example request**: - .. sourcecode:: bash + .. tabs:: + + .. code-tab:: bash + + $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/builds/ + + .. code-tab:: python - $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/builds/ + import requests + URL = 'https://readthedocs.org/api/v3/projects/pip/builds/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + response = requests.get(URL, headers=HEADERS) + print(response.json()) **Example response**: @@ -506,11 +623,22 @@ Build triggering **Example request**: - .. sourcecode:: bash + .. tabs:: - $ curl \ - -X POST \ - -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/versions/latest/builds/ + .. code-tab:: bash + + $ curl \ + -X POST \ + -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/versions/latest/builds/ + + .. code-tab:: python + + import requests + URL = 'https://readthedocs.org/api/v3/projects/pip/versions/latest/builds/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + response = requests.post(URL, headers=HEADERS) + print(response.json()) **Example response**: @@ -545,9 +673,20 @@ Subproject details **Example request**: - .. sourcecode:: bash + .. tabs:: + + .. code-tab:: bash + + $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/subprojects/subproject-alias/ - $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/subprojects/subproject-alias/ + .. code-tab:: python + + import requests + URL = 'https://readthedocs.org/api/v3/projects/pip/subprojects/subproject-alias/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + response = requests.get(URL, headers=HEADERS) + print(response.json()) **Example response**: @@ -572,9 +711,20 @@ Subprojects listing **Example request**: - .. sourcecode:: bash + .. tabs:: + + .. code-tab:: bash + + $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/subprojects/ + + .. code-tab:: python - $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/subprojects/ + import requests + URL = 'https://readthedocs.org/api/v3/projects/pip/subprojects/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + response = requests.get(URL, headers=HEADERS) + print(response.json()) **Example response**: @@ -598,13 +748,30 @@ Subproject create **Example request**: - .. sourcecode:: bash + .. tabs:: - $ curl \ - -X POST \ - -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/subprojects/ \ - -H "Content-Type: application/json" \ - -d @body.json + .. code-tab:: bash + + $ curl \ + -X POST \ + -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/subprojects/ \ + -H "Content-Type: application/json" \ + -d @body.json + + .. code-tab:: python + + import requests + import json + URL = 'https://readthedocs.org/api/v3/projects/pip/subprojects/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + data = json.load(open('body.json', 'rb')) + response = requests.post( + URL, + json=data, + headers=HEADERS, + ) + print(response.json()) The content of ``body.json`` is like, @@ -635,11 +802,22 @@ Subproject delete **Example request**: - .. sourcecode:: bash + .. tabs:: + + .. code-tab:: bash + + $ curl \ + -X DELETE \ + -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/subprojects/subproject-alias/ - $ curl \ - -X DELETE \ - -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/subprojects/subproject-alias/ + .. code-tab:: python + + import requests + URL = 'https://readthedocs.org/api/v3/projects/pip/subprojects/subproject-alias/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + response = requests.delete(URL, headers=HEADERS) + print(response.json()) :statuscode 204: Subproject deleted successfully @@ -660,9 +838,20 @@ Translations listing **Example request**: - .. sourcecode:: bash + .. tabs:: + + .. code-tab:: bash + + $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/translations/ + + .. code-tab:: python - $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/translations/ + import requests + URL = 'https://readthedocs.org/api/v3/projects/pip/translations/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + response = requests.get(URL, headers=HEADERS) + print(response.json()) **Example response**: @@ -693,9 +882,20 @@ Redirect details **Example request** - .. sourcecode:: bash + .. tabs:: - $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/redirects/1/ + .. code-tab:: bash + + $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/redirects/1/ + + .. code-tab:: python + + import requests + URL = 'https://readthedocs.org/api/v3/projects/pip/redirects/1/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + response = requests.get(URL, headers=HEADERS) + print(response.json()) **Example response** @@ -724,9 +924,20 @@ Redirects listing **Example request** - .. sourcecode:: bash + .. tabs:: + + .. code-tab:: bash + + $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/redirects/ - $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/redirects/ + .. code-tab:: python + + import requests + URL = 'https://readthedocs.org/api/v3/projects/pip/redirects/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + response = requests.get(URL, headers=HEADERS) + print(response.json()) **Example response** @@ -748,13 +959,30 @@ Redirect create **Example request**: - .. sourcecode:: bash + .. tabs:: + + .. code-tab:: bash + + $ curl \ + -X POST \ + -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/redirects/ \ + -H "Content-Type: application/json" \ + -d @body.json + + .. code-tab:: python - $ curl \ - -X POST \ - -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/redirects/ \ - -H "Content-Type: application/json" \ - -d @body.json + import requests + import json + URL = 'https://readthedocs.org/api/v3/projects/pip/redirects/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + data = json.load(open('body.json', 'rb')) + response = requests.post( + URL, + json=data, + headers=HEADERS, + ) + print(response.json()) The content of ``body.json`` is like, @@ -792,13 +1020,30 @@ Redirect update **Example request**: - .. sourcecode:: bash + .. tabs:: - $ curl \ - -X PUT \ - -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/redirects/1/ \ - -H "Content-Type: application/json" \ - -d @body.json + .. code-tab:: bash + + $ curl \ + -X PUT \ + -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/redirects/1/ \ + -H "Content-Type: application/json" \ + -d @body.json + + .. code-tab:: python + + import requests + import json + URL = 'https://readthedocs.org/api/v3/projects/pip/redirects/1/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + data = json.load(open('body.json', 'rb')) + response = requests.put( + URL, + json=data, + headers=HEADERS, + ) + print(response.json()) The content of ``body.json`` is like, @@ -823,11 +1068,22 @@ Redirect delete **Example request**: - .. sourcecode:: bash + .. tabs:: + + .. code-tab:: bash + + $ curl \ + -X DELETE \ + -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/redirects/1/ - $ curl \ - -X DELETE \ - -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/redirects/1/ + .. code-tab:: python + + import requests + URL = 'https://readthedocs.org/api/v3/projects/pip/redirects/1/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + response = requests.delete(URL, headers=HEADERS) + print(response.json()) :statuscode 204: Redirect deleted successfully @@ -850,9 +1106,20 @@ Environment Variable details **Example request** - .. sourcecode:: bash + .. tabs:: + + .. code-tab:: bash + + $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/environmentvariables/1/ + + .. code-tab:: python - $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/environmentvariables/1/ + import requests + URL = 'https://readthedocs.org/api/v3/projects/pip/environmentvariables/1/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + response = requests.get(URL, headers=HEADERS) + print(response.json()) **Example response** @@ -879,9 +1146,20 @@ Environment Variables listing **Example request** - .. sourcecode:: bash + .. tabs:: - $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/environmentvariables/ + .. code-tab:: bash + + $ curl -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/environmentvariables/ + + .. code-tab:: python + + import requests + URL = 'https://readthedocs.org/api/v3/projects/pip/environmentvariables/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + response = requests.get(URL, headers=HEADERS) + print(response.json()) **Example response** @@ -903,13 +1181,30 @@ Environment Variable create **Example request**: - .. sourcecode:: bash + .. tabs:: + + .. code-tab:: bash + + $ curl \ + -X POST \ + -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/environmentvariables/ \ + -H "Content-Type: application/json" \ + -d @body.json - $ curl \ - -X POST \ - -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/environmentvariables/ \ - -H "Content-Type: application/json" \ - -d @body.json + .. code-tab:: python + + import requests + import json + URL = 'https://readthedocs.org/api/v3/projects/pip/environmentvariables/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + data = json.load(open('body.json', 'rb')) + response = requests.post( + URL, + json=data, + headers=HEADERS, + ) + print(response.json()) The content of ``body.json`` is like, @@ -936,11 +1231,22 @@ Environment Variable delete **Example request**: - .. sourcecode:: bash + .. tabs:: + + .. code-tab:: bash + + $ curl \ + -X DELETE \ + -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/environmentvariables/1/ + + .. code-tab:: python - $ curl \ - -X DELETE \ - -H "Authorization: Token " https://readthedocs.org/api/v3/projects/pip/environmentvariables/1/ + import requests + URL = 'https://readthedocs.org/api/v3/projects/pip/environmentvariables/1/' + TOKEN = '' + HEADERS = {'Authorization': f'token {TOKEN}'} + response = requests.delete(URL, headers=HEADERS) + print(response.json()) :requestheader Authorization: token to authenticate.