Skip to content

List a folder's contents

By , Head of IntegrationsUpdated

Open this page in a new chat

Short answer

List a folder's contents with GET /v2/files/readdir. It will return the filename, mimetype, content type and file size. It will also return any folders that exist. A page of up to 100 results will be returned - use the 'continuation' field to request additional pages. Each call needs a bearer token and counts towards your hourly API limit.

After reading this you will know

  • How to list a folder's contents
  • Which parameters it takes
  • Sample code in 9 languages and a sample answer

This command needs a bearer token and counts towards your hourly limit.

GEThttps://api.sirv.com/v2/files/readdir

Use this API method to get a list of all the files/folders within a folder.

It will return the filename, mimetype, content type and file size. It will also return any folders that exist.

A page of up to 100 results will be returned - use the ‘continuation’ field to request additional pages.

Query parameters

NameTypeRequiredExampleDescription
dirnamestringYes/REST API ExamplesPath of the folder to list, starting with /.
continuationstringNoSend it to get next page of results

Example request

// Your bearer token, from POST /v2/token, in the SIRV_TOKEN environment variable
const res = await fetch('https://api.sirv.com/v2/files/readdir?dirname=%2FREST%20API%20Examples', {
method: 'GET',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}` },
});
console.log(res.status, await res.text());

Example response

{
"contents": [
{
"filename": "aurora.jpg",
"mtime": "2026-02-23T10:22:34.659Z",
"contentType": "image/jpeg",
"size": 260864,
"isDirectory": false,
"meta": {
"width": 2500,
"height": 1667,
"duration": 0
}
},
{
"filename": "aurora3.jpg",
"mtime": "2020-11-18T19:55:13.459Z",
"contentType": "image/webp",
"size": 201846,
"isDirectory": false,
"meta": {
"width": 2500,
"height": 1667,
"duration": 0
}
}
]
}
Back to top