Basic API Requests
This guide assumes you have obtained an access token from an authorized user. You can obtain an access token either by completing the OAuth flow (see the User Authentication guide) or by using the Access Token Generator to generate a token using your own Bluescape login information.
The Base URL
All API endpoints share the same base URL:
https://api.apps.us.bluescape.com
Assembling a Request
URL
A request URL is assembled from the base URL and the path information for an operation as found in the reference. For example, Add a User to an Organization is an operation with path /organizations/<organization_uid>/users. Combining this path with the base URL gives us a request URL of:
https://api.apps.us.bluescape.com/organizations/<organization_uid>/users
Parameters
The path for the operation above, like many in the Bluescape API, contains a parameter. Adding a user to an organization requires we identify the organization to which the new user should be invited. To finish preparing this request URL, we must replace <organization_uid> with a valid organization UID, such as one obtained from the List a User's Organizations operation. Replacing the parameter placeholder with a sample organization UID yields a request URL of:
https://api.apps.us.bluescape.com/organizations/eidzMVOsv4peKG-4DLKA/users
In addition to path parameters, some requests will have query, body and form data parameters. Reviewing the documentation for Add a User to an Organization, we see that this operation has a JSON-format body parameter with a required email field. When an operation requires a body parameter, be sure to send your request with a Content-Type header of application/json. When a form data parameter is expected, be sure to send your request with a Content-Type header of multipart/form-data. A valid body for this request looks like:
{ "email": "[email protected]" }
Authorization Header
Lastly, all operations require an Authorization header based on the access tokens received from the OAuth flow. The value of this header should match the format of Bearer <access-token>.
Assembled Request
Putting this all together, a request to Add a User to an Organization looks like:
curl -X POST https://api.apps.us.bluescape.com/organizations/eidzMVOsv4peKG-4DLKA/users \ -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsImtpZCI6Imp3d...' \ -H 'Content-Type: application/json' \ -d '{ "email": "[email protected]" }'
import requests import pprint ... ... portal = 'https://api.apps.us.bluescape.com' workspace_uid = <SET_WORKSPACE_UID> API_endpoint = '/v2/workspaces/' + workspace_uid + '/elements/images' token = <SET_YOUR_TOKEN> the_request = requests.get( portal + API_endpoint, headers={"Authorization": "Bearer " + token, "Content-Type": "application/json" } ) json_response = the_request.json() pprint.pprint(json_response) ... ...
If you have any questions or comments, please contact us at Bluescape support.