-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Add python examples for API v3 Documentation #6487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Issue #5935 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, code looks good. Left some suggestions
docs/api/v3.rst
Outdated
TOKEN = '<token>' | ||
HEADERS = {'Authorization': 'token {}'.format(TOKEN)} | ||
response = requests.get(URL, headers=HEADERS) | ||
print(response.text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print(response.text) | |
print(response.json()) |
docs/api/v3.rst
Outdated
import requests | ||
URL = 'https://readthedocs.org/api/v3/projects/' | ||
TOKEN = '<token>' | ||
HEADERS = {'Authorization': 'token {}'.format(TOKEN)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HEADERS = {'Authorization': 'token {}'.format(TOKEN)} | |
HEADERS = {'Authorization': f'token {TOKEN}'} |
docs/api/v3.rst
Outdated
import requests | ||
URL = 'https://readthedocs.org/api/v3/projects/pip/' | ||
TOKEN = '<token>' | ||
HEADERS = {'Authorization': 'token {}'.format(TOKEN)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HEADERS = {'Authorization': 'token {}'.format(TOKEN)} | |
HEADERS = {'Authorization': f'token {TOKEN}'} |
docs/api/v3.rst
Outdated
TOKEN = '<token>' | ||
HEADERS = {'Authorization': 'token {}'.format(TOKEN)} | ||
response = requests.get(URL, headers=HEADERS) | ||
print(response.text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print(response.text) | |
print(response.json()) |
docs/api/v3.rst
Outdated
import json | ||
URL = 'https://readthedocs.org/api/v3/projects/' | ||
TOKEN = '<token>' | ||
HEADERS = {'Authorization' : 'token {}'.format(TOKEN)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HEADERS = {'Authorization' : 'token {}'.format(TOKEN)} | |
HEADERS = {'Authorization' : f'token {TOKEN}'} |
docs/api/v3.rst
Outdated
TOKEN = '<token>' | ||
HEADERS = {'Authorization': 'token {}'.format(TOKEN)} | ||
response = requests.get(URL, headers=HEADERS) | ||
print(response.text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print(response.text) | |
print(response.json()) |
docs/api/v3.rst
Outdated
HEADERS = {'Authorization' : 'token {}'.format(TOKEN)} | ||
data = json.load(open('body.json', 'rb')) | ||
response = requests.post(URL, | ||
json = data, headers = HEADERS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same about indentation
docs/api/v3.rst
Outdated
import json | ||
URL = 'https://readthedocs.org/api/v3/projects/pip/redirects/' | ||
TOKEN = '<token>' | ||
HEADERS = {'Authorization' : 'token {}'.format(TOKEN)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HEADERS = {'Authorization' : 'token {}'.format(TOKEN)} | |
HEADERS = {'Authorization' : f'token {TOKEN}'} |
docs/api/v3.rst
Outdated
data = json.load(open('body.json', 'rb')) | ||
response = requests.post(URL, | ||
json = data, headers = HEADERS) | ||
print(response.text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print(response.text) | |
print(response.json()) |
docs/conf.py
Outdated
@@ -39,6 +39,7 @@ def get_version(): | |||
'recommonmark', | |||
'notfound.extension', | |||
'sphinx_search.extension', | |||
'sphinx_tabs.tabs', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have this extension listed above ^
'sphinx_tabs.tabs', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still some places where we need to change from 'token {}'.format(TOKEN)
to f'token {TOKEN}'
docs/api/v3.rst
Outdated
data = json.load(open('body.json', 'rb')) | ||
response = requests.post( | ||
URL, | ||
json = data, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json = data, | |
json=data, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs/api/v3.rst
Outdated
@@ -936,11 +1231,22 @@ Environment Variable delete | |||
|
|||
**Example request**: | |||
|
|||
.. sourcecode:: bash | |||
.. tabs:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. tabs:: | |
.. tabs:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry about that, must have missed the last one while checking. I fixed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks!
No description provided.