mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-25 18:13:10 +03:00
final redesign of API docs?
This commit is contained in:
parent
56283c052b
commit
d0106e1db4
@ -23,15 +23,19 @@ const json = await response.json();
|
||||
console.log(json);`;
|
||||
|
||||
const EXAMPLE_CODE_PY = (key, slateId) => `import requests
|
||||
import json
|
||||
import json as JSON
|
||||
|
||||
url = 'https://slate.host/api/v1/get'
|
||||
headers = {
|
||||
'content-type': 'application/json',
|
||||
'Authorization': 'Basic ${key}'
|
||||
}
|
||||
|
||||
json = {'id': '${slateId}'}
|
||||
|
||||
r = requests.post(url, headers=headers, json=json)
|
||||
print(r.text)`;
|
||||
|
||||
print(JSON.dumps(r.json(), indent=2))`;
|
||||
|
||||
const EXAMPLE_RESPONSE = (key, slateId) => `
|
||||
{
|
||||
|
@ -30,9 +30,9 @@ headers = {
|
||||
|
||||
json = {"private": "false"}
|
||||
|
||||
get = requests.post(url, headers=headers, json=json)
|
||||
r = requests.post(url, headers=headers, json=json)
|
||||
|
||||
print(JSON.dumps(get.json(), indent=2))`;
|
||||
print(JSON.dumps(r.json(), indent=2))`;
|
||||
|
||||
export default class APIDocsGet extends React.Component {
|
||||
render() {
|
||||
|
@ -20,32 +20,33 @@ const response = await fetch('https://slate.host/api/v1/update-slate', {
|
||||
Authorization: 'Basic ${key}',
|
||||
},
|
||||
body: JSON.stringify({ data: slate })
|
||||
});
|
||||
|
||||
const json = await response.json();
|
||||
console.log(json);`;
|
||||
});`;
|
||||
};
|
||||
|
||||
const EXAMPLE_CODE_PY = (key, slateId) =>
|
||||
`headers = {
|
||||
`import requests
|
||||
|
||||
headers = {
|
||||
"content-type": "application/json",
|
||||
"Authorization": "Basic ${key}",
|
||||
}
|
||||
|
||||
json = {"id": "${slateId}"}
|
||||
|
||||
get_slate = requests.post(
|
||||
"https://slate.host/api/v1/get-slate", headers=headers, json=json
|
||||
)
|
||||
|
||||
get_slate_response = get_slate.json()
|
||||
|
||||
slate = get_slate_response["slate"]
|
||||
# change a field in the slate response
|
||||
slate["data"]["objects"][0]["title"] = "i changed the title"
|
||||
|
||||
url = "https://slate.host/api/v1/update-slate"
|
||||
slate = get_slate_response["slate"]
|
||||
slate["data"]["objects"][0]["title"] = "i changed the title"
|
||||
updated_data = {"data": slate}
|
||||
|
||||
update_slate = requests.post(url, headers=headers, json=updated_data)`;
|
||||
url = "https://slate.host/api/v1/update-slate"
|
||||
|
||||
r = requests.post(url, headers=headers, json=updated_data)`;
|
||||
|
||||
export default class APIDocsUpdateSlate extends React.Component {
|
||||
render() {
|
||||
|
@ -20,11 +20,7 @@ const response = await fetch(url, {
|
||||
Authorization: 'Basic ${key}',
|
||||
},
|
||||
body: data
|
||||
});
|
||||
|
||||
const json = await response.json();
|
||||
|
||||
console.log(json);`;
|
||||
});`;
|
||||
|
||||
const EXAMPLE_CODE_PY = (key, slateId) => `url = "https://uploads.slate.host/api/public/${slateId}"
|
||||
files = {"file": open("example-file.txt", "rb")}
|
||||
|
Loading…
Reference in New Issue
Block a user