import json
from requests_oauthlib import OAuth1Session
client = OAuth1Session('PROVIDEDKEYHERE',
client_secret='PROVIDEDSECRETHERE')
base_url = 'https://yourbrand.cloudfrontend.net/api/v2/'
Example fetching a list of Sites.
response = client.get(
'{}sites/'.format(base_url),
params={
'deleted': 0,
})
content = response.json()
Creating a new site using a JSON object containing the payload.
payload = {
'formatted_domain': 'www.somebusinessname.com',
...
}
response = client.post(
'{}sites/'.format(base_url),
json=payload)
content = response.json()
import json
import oauth2 as oauth
consumer = oauth.Consumer('PROVIDEDKEYHERE', 'PROVIDEDSECRETHERE')
client = oauth.Client(consumer, None)
response, content = client.request('/api/v2/sites/', 'GET', headers={
'content-type': 'application/json'
})
content = json.loads(content)
A JSON object containing the parameters is encoded as a string and then passed as the request body.
import json
import oauth2 as oauth
consumer = oauth.Consumer('PROVIDEDKEYHERE', 'PROVIDEDSECRETHERE')
client = oauth.Client(consumer, None)
params = {
'domain': 'somebusinessname.com',
...
}
response, content = client.request('/api/v2/sites/', 'POST', body=json.dumps(params), headers={
'Content-Type': 'application/json'
})
content = json.loads(content)