Developer

Get all the images from a workspace

Objective: get a list of all the images in a Workspace. You will need the Workspace ID. This list will contain, for each image, details such as: image name, creation date, traits, comments, etc.
This page contains the implementation details for v2 REST APIs. You can also see the example for v3 APIs.

Implementation using REST APIs v2

Endpoint /v2/workspaces/<SET_WORKSPACEID>/elements/images
Method GET
Comments You need to know the workspace ID.

Code sample

See below code samples in Python and Node.js.

curl --location --request GET '/v2/workspaces/<SET_WORKSPACEID>/elements/images' \
--header 'Authorization: Bearer <TOKEN>' 

# Python Code (python 3.5+)
import requests
import pprint

'''
Required modules:
   requests 2.22.0
'''

token = '<SET_TOKEN>'

if __name__ == "__main__":
   portal = ""
   workspaceId = '<SET_WORKSPACE_ID>'   
   API_version = 'v2'

   # Get all the images from a workspace

   API_endpoint = '/' + API_version + '/workspaces/' + workspaceId + '/elements/images'

   the_request = requests.get(
       portal + API_endpoint,
       headers={"Authorization": "Bearer " + token,
                "Content-Type": "application/json"
                }
   )

   json_response = the_request.json()

   pprint.pprint(json_response)

// 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_TOKEN>';
const portal = '';
const workspaceId = '<SET_WORKSPACE_ID>';
const api_version = 'v2';
const api_endpoint = '/workspaces/' + workspaceId + '/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/' + workspaceId + '/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 all images in the workspace


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.