Get all the images from a workspace
Objective: get a list of all the images in a Workspace. You will need the Workspace UID. This list will contain, for each image, details such as: image name, creation date, traits, comments, etc.
Endpoint | /v2/workspaces/<workspace_uid>/elements/images |
Method | GET |
Comments | You need to know the workspace UID. |
Code sample
See below code samples in Python and Node.js.
# Python Code (python 3.5+) import requests import pprint ''' Required modules: requests 2.22.0 ''' token = 'ADD_YOUR_TOKEN_HERE' if __name__ == "__main__": portal = "https://api.apps.us.bluescape.com" workspace_uid = 'ADD_WORKSPACE_UID' API_version = 'v2' # Get all the images from a workspace API_endpoint = '/' + API_version + '/workspaces/' + workspace_uid + '/elements/images' the_request = requests.get( portal + API_endpoint, headers={"Authorization": "Bearer " + token, "Content-Type": "application/json" } ) json_response = the_request.json() # Uncomment line below if you want to see the whole structure of the json answer # pprint.pprint(json_response) for object_item in json_response['images']: print("\tImage: ", object_item['url'])
// Node.js Javascript /* How to run: node this_script_name.js Requires "axios" module (0.19.0), run: npm install axios website: https://github.com/axios/axios */ var axios = require('axios'); const token = 'SET_YOUR_TOKEN_HERE'; const portal = 'https://api.apps.us.bluescape.com'; const workspace_uid = 'SET_WORKSPACE-UID_HERE'; const api_version = 'v2'; const api_endpoint = '/workspaces/' + workspace_uid + '/elements/images'; var request_values = { url: portal + '/' + api_version + api_endpoint, method : 'GET' , headers : { 'Authorization': "Bearer " + token, 'Content-Type' : 'application/json' } }; axios(request_values) .then(function (response) { if (response.status == 200) { console.log("Success"); console.log(response.data); } }) .catch (function (error) { console.log('Error: ' + error.message); });
You can modify this script to return a list of each specific object from the workspace by changing the last element in the API entrypoint: API_endpoint = '/v2/workspaces/' + workspace_uid + '/elements/images'. Here, replace the final '/images' element with:
- "/documents"
- "/notes"
- "/images"
- "/text"
- "/canvas"
- "/browsers"
- "/strokes"
- "/videos"
- "/grids"
OUTPUT
What you should get: json with the list of the first 25 workspaces
Element | Json | Comments |
Image ID | ['images'][N]['id'] | where N is the N-th workspace in the list. |
Image Title | ['workspaces'][N]['title'] | where N is the N-th workspace in the list. |
Image URL | ['workspaces'][N]['url'] | where N is the N-th image in the list. |
Output Json sample
{'images': [{'comments': [{'actorId': '38988', 'actorType': 'user', 'date': '2019-07-23T17:37:03+00:00', 'id': '5d3745bfda1ecc2c2d00036c', 'name': 'Ansel Adams', 'text': 'Nice picture, beautiful dunes.'}], 'height': 871, 'id': '5d374593da139IOOd000369', 'order': 193, 'pin': False, 'scale': 0.4, 'strokeIds': [], 'title': 'Screen Shot 2019-06-18 at 2.51.06 PM.png', 'traits': [{'http://test.bluescape.com/picture/description': 'Sand ' 'Dunes, ' 'big, ' 'light ' 'on ' 'one ' 'side, ' 'shadow ' 'ont ' 'he ' 'other ' 'one', 'http://test.bluescape.com/picture/tags': ['sand ' 'dunes', 'light', 'desert', 'blue sky', 'yellow ' 'sand', 'sand'], 'http://test.bluescape.com/picture/title': 'Nice sand ' 'dunes ' 'picture'}], 'url': 'https://s3.amazonaws.com/public-assets.bluescape.com/sessions/objects/QJh-lZUZGaFinBFuz2/5d37459cc2c9Ad000369.png?X-Amz<-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=BKIXIWO33I6HA%2F20191723%2Fus-1%2Fs3%2Faws4_request&X-Amz-Date=20190723T230936Amz-Expires=300', 'width': 1394, 'workspace_uid': 'QJh-lZU9RRFinOuzeR2', 'x': 6344, 'y': 4520} ] }
If you have any questions or comments, please contact us at Bluescape support.