Is there any place I can find "detailed" API documentation of Spaces?

October 17, 2017 185 views

I tried to find the API to delete at a folder(i know it is more of a virtual folder) level. I couldn't find it in documentation. But I managed to inspect the api requests of the Spaces dashboard and figure out folder level delete is supported and the api details. Is there any documentation available other than this

1 Answer
asb MOD October 17, 2017
Accepted Answer

The API that the Spaces dashboard calls is an internal implementation detail. It's how our Ember front end talks to our backend. Under the hood, it is still accessing the same S3-compatible API from the linked docs.

A "folder" is actually just a "key" with a zero sized "object." Items inside the folder have the folder key as a prefix to their own key. For example, here is a listing of objects in a Space with a folder named foo containing a file named bar:

$ aws s3api --endpoint-url --profile do list-objects --bucket my-bucket
    "Contents": [
            "LastModified": "2017-10-17T17:50:50.840Z", 
            "ETag": "\"d41d8cd98f00b204e9800998ecf8427e\"", 
            "StorageClass": "STANDARD", 
            "Key": "foo/", 
            "Owner": {
                "DisplayName": "681451698", 
                "ID": "681451698"
            "Size": 0
            "LastModified": "2017-10-17T17:56:08.583Z", 
            "ETag": "\"8cf8463b34caa8ac871a52d5dd7ad1ef\"", 
            "StorageClass": "STANDARD", 
            "Key": "foo/bar", 
            "Owner": {
                "DisplayName": "681451698", 
                "ID": "681451698"
            "Size": 2

The API does not support recursively deleting files per se. On the backend, we list all objects with that prefix and then delete them. You can achieve this same result by including a prefix query parameter when calling the API to list the contents of a Space. Here's a quick Python example:

import boto3

session = boto3.session.Session()
client = session.client('s3',

resp = client.list_objects(Bucket='my-bucket', Prefix='foo/')
objects_to_delete = []
for obj in resp['Contents']:
     objects_to_delete.append({'Key': obj['Key']})

response = client.delete_objects(Bucket='my-bucket',
                                     'Objects': objects_to_delete

print("Deleted: {0}".format(response['Deleted']))

Hope that helps!

Have another answer? Share your knowledge.