Links

Get file versions

get
https://api.imagekit.io
/v1/files/:fileId/versions
Get all versions of an asset

Response structure and status code (application/JSON)

In case of an error, you will get an error code along with the error message. On success, you will receive a 200 status code with the list of file object in the JSON-encoded response body on success.

Examples

Here is the example request to understand the API usage.
cURL
Node.js
Python
PHP
Java
Ruby
Go
.Net
# The unique fileId of the uploaded file. fileId is returned in response of list files API and upload API.
curl -X GET "https://api.imagekit.io/v1/files/file_id/versions" \
-u your_private_api_key:
var ImageKit = require("imagekit");
var imagekit = new ImageKit({
publicKey : "your_public_api_key",
privateKey : "your_private_api_key",
urlEndpoint : "https://ik.imagekit.io/your_imagekit_id/"
});
imagekit.getFileVersions("file_id", function(error, result) {
if(error) console.log(error);
else console.log(result);
});
from imagekitio import ImageKit
imagekit = ImageKit(
public_key='your_public_api_key',
private_key='your_private_api_key',
url_endpoint = 'https://ik.imagekit.io/your_imagekit_id/'
)
file_versions = imagekit.get_file_versions(file_id='file_id')
print("Get File versions-", "\n", file_versions)
# Raw Response
print(file_versions.response_metadata.raw)
# print that file's version id
print(file_versions.list[0].version_info.id)
$public_key = "your_public_api_key";
$your_private_key = "your_private_api_key";
$url_end_point = "https://ik.imagekit.io/your_imagekit_id";
$imageKit = new ImageKit(
$public_key,
$your_private_key,
$url_end_point
);
$fileId = 'file_id';
$getFileVersions = $imageKit->getFileVersions($fileId);
echo("File Versions : " . json_encode($getFileVersions));
String fileId = "file_id";
ResultFileVersions resultFileVersions = ImageKit.getInstance().getFileVersions(fileId);
imagekitio = ImageKitIo::Client.new("your_private_key", "your_public_key", "your_url_endpoint")
imagekitio.file_versions(
file_id: 'file_id'
)
resp, err := ik.Media.FileVersions(ctx, media.FileVersionsParam{
FileId: "file_id",
})
var imagekit = new ImageKit({
publicKey : "your_public_api_key",
privateKey : "your_private_api_key",
urlEndpoint : "https://ik.imagekit.io/your_imagekit_id/"
});
ResultFileVersions resultFileVersions = imagekit.GetFileVersions("file_Id");