Obtain Resource Metadata from Folder ID
API Endpoint: folder_resource
Obtaining a list of resources files and their associated metadata can be a powerful step in creating complex scripts for bulk downloading files, investigating resource metadata in bulk, identifying sub-folders/sub-directories, etc.
Important
An API Key is required for ALL downloads as of EDX 3.07 (09/03/2020)
The API Key name component can be added to your header using any of the following ways, “X-CKAN-API-Key”, “EDX-API-Key”, or “Authorization”.
Results for this API endpoint are in JSON format.
Obtain the initial/seed folder ID
Using the EDX web user interface, navigate to the workspace that contains the folder that you wish to upload to, right click the folder, select the “Get Folder ID” option from the menu, and select the “Copy ID to Clipboard” option from the modal pop-up window.


Parameter Definitions
Parameter Name |
Description |
Required Field |
---|---|---|
|
The name or ID of workspace where the folder resides |
Required |
|
The ID of the folder on EDX Drive you wish to explore |
Required |
|
If you wish to only return resources or folders |
Optional |
Caution
If the only_show_type
parameter is not used, then both resources and folders will return in the JSON.
Tip
If you wish to return items at the root level of the EDX drive, then use the value root
for folder_id
In the example below, you will see that you can provide one OR many folder IDs in a single request. If the list of folder IDs provided contain a deleted folder, that deleted folder will not return information in the JSON. Essentially, if a folder is missing in the JSON, either the folder was deleted or the ID provided is incorrect.
Example 1: Resource and Folders Query
Attention
Add the
"User-Agent":
parameter within theheaders
of the API requestSet
"User-Agent":
to the value"EDX-USER"
import requests
headers = {
"EDX-API-Key": 'YOUR-API-KEY-HERE',
"User-Agent": "EDX-USER"
}
data = {
"workspace_id": 'test-workspace',
"folder_id": '7c3e598c-3486-468d-9d5b-9eee6da7637a'
#"folder_id": ['7c3e598c-3486-468d-9d5b-9eee6da7637a', '4d932b54-57be-404a-b38e-6e9caa6e3b23'] list of folders format
#"only_show_type": 'folders' # Uncomment this line if you wish to only return folders
#"only_show_type": 'resources' # Uncomment this line if you wish to only return resources
}
url = 'https://edx.netl.doe.gov/api/3/action/folder_resources'
r = requests.post(
url, # URL to API endpoint
headers=headers, # Headers dictionary
data=data, # Dictionary of data params
)
print (r.json())
{
'help': 'http://edx.netl.doe.gov/api/3/action/help_show?name=folder_resources',
'success': True,
'result': {
'resources': [
{
'id': 'c133dc74-c719-4072-8ee3-69c491223f62',
'package_id': '78a8dcb1-2736-49f6-a7ca-b4994498e21a',
'revision_id': '77bd7083-179a-4c58-b649-4ac21b68e122',
'url': 'http://edx.netl.doe.gov/storage/f/edx/2021/04/2021-04-15T14:53:02.651Z/c133dc74-c719-4072-8ee3-69c491223f62/alligator.jpeg',
'format': 'JPEG',
'description': '',
'hash': 'md5:86b552add383a47a8958a19617652805',
'position': 0,
'name': 'alligator.jpeg',
'resource_type': 'file.upload',
'mimetype': 'image/jpeg',
'mimetype_inner': None,
'size': 5944,
'created': '2021-04-15T10:53:02.707000',
'last_modified': '2021-04-15T10:53:02.707000',
'cache_url': 'storage/f/edx/2021/04/2021-04-15T14:53:02.651Z/c133dc74-c719-4072-8ee3-69c491223f62/alligator.jpeg',
'cache_last_updated': None,
'url_type': 'upload',
'state': 'active',
'license_type': 'notspecified',
'folder_id': '2fba33a7-6607-482d-89dd-ec964342e843',
'owner_org': '2bcc2e6c-8830-4c52-9f77-dca017947723',
'recycle_removed': False,
'rating': None,
'key': '2021-04-15T14:53:02.651Z/c133dc74-c719-4072-8ee3-69c491223f62/alligator.jpeg',
'owner': 'catherinehines',
'cache_url_updated': '2021-04-15T10:53:02.707',
'datastore_active': False,
'revision_timestamp': 'April 15, 2021, 14:53:02 (EST)',
'intended_use_auth': False
},
{
'id': '741c4bdb-b04a-457b-8947-42d9a95faf53',
'package_id': '584a1890-3970-442f-9a96-dea794fff0f1',
'revision_id': '469e4fc7-ad98-46a4-9c71-88412333e4c2',
'url': 'http://edx.netl.doe.gov/storage/f/edx/2021/04/2021-04-15T14:51:35.522Z/741c4bdb-b04a-457b-8947-42d9a95faf53/red_panda.jpeg',
'format': 'JPEG',
'description': '',
'hash': 'md5:4a6acf2c516fdaa608f090ccca5b6a7e',
'position': 0,
'name': 'red_panda.jpeg',
'resource_type': 'file.upload',
'mimetype': 'image/jpeg',
'mimetype_inner': None,
'size': 6714,
'created': '2021-04-15T10:51:35.676000',
'last_modified': '2021-04-15T10:51:35.676000',
'cache_url': 'storage/f/edx/2021/04/2021-04-15T14:51:35.522Z/741c4bdb-b04a-457b-8947-42d9a95faf53/red_panda.jpeg',
'cache_last_updated': None,
'url_type': 'upload',
'state': 'active',
'license_type': 'notspecified',
'folder_id': '2fba33a7-6607-482d-89dd-ec964342e843',
'owner_org': '2bcc2e6c-8830-4c52-9f77-dca017947723',
'recycle_removed': False,
'rating': None,
'key': '2021-04-15T14:51:35.522Z/741c4bdb-b04a-457b-8947-42d9a95faf53/red_panda.jpeg',
'owner': 'catherinehines',
'cache_url_updated': '2021-04-15T10:51:35.676',
'datastore_active': False,
'group': '2bcc2e6c-8830-4c52-9f77-dca017947723',
'revision_timestamp': 'April 15, 2021, 14:51:35 (EST)',
'intended_use_auth': False
}
],
'folders': [
{
'id': 'f80b7c26-9017-4538-8989-5cef771093d8',
'name': 'Subfolder'
}
]
}
}