Skip to content

Get file info

By , Head of IntegrationsUpdated

Open this page in a new chat

Short answer

Get file info with GET /v2/files/stat. It returns a file's or folder's size, content type, created and modified dates, and for images and videos the width, height and duration. Use it to check that a file exists. Each call needs a bearer token and counts towards your hourly API limit.

After reading this you will know

  • How to get file info
  • 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/stat

Use this API method to get information about a file, including created time, modified time, content type and size. It returns Unix information.

Query parameters

NameTypeRequiredExampleDescription
filenamestringYes/REST API Examples/blue-lake.jpgPath of the file in your account, starting with /.

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/stat?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg', {
method: 'GET',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}` },
});
console.log(res.status, await res.text());

Example response

{
"mtime": "2020-07-17T13:31:39.450Z",
"ctime": "2020-07-17T13:31:39.347Z",
"contentType": "image/jpeg",
"size": 587065,
"isDirectory": false,
"meta": {
"width": 1578,
"height": 1002,
"duration": 0
}
}
Back to top