Get image metadata for uploaded media files
You can programmatically get image EXIF, pHash, and other metadata for uploaded files in the ImageKit.io media library using this API.
💡
You can also get the image metadata while uploading the image by passing metadata in responseFields parameter.
get
https://api.imagekit.io
/v1/files/:fileId/metadata
Get image metadata for uploaded media files API

Response structure and status code (application/JSON)

In case of error, you will get an error code along with the error message. On success, you will receive a 200 status code with the image metadata in the JSON-encoded response body.
A metadata object example can be found here.

Examples

Here are some example requests to understand the API usage.

Get metadata of an uploaded image

cURL
Node.js
Python
PHP
Java
Ruby
1
# The unique fileId of the uploaded file. fileId is returned in response of list files API and upload API.
2
curl -X GET "https://api.imagekit.io/v1/files/fileId/metadata" \
3
-u your_private_api_key:
Copied!
1
var ImageKit = require("imagekit");
2
3
var imagekit = new ImageKit({
4
publicKey : "your_public_api_key",
5
privateKey : "your_private_api_key",
6
urlEndpoint : "https://ik.imagekit.io/your_imagekit_id/"
7
});
8
9
imagekit.getFileMetadata("fileId", function(error, result) {
10
if(error) console.log(error);
11
else console.log(result);
12
});
Copied!
1
from imagekitio import ImageKit
2
3
imagekit = ImageKit(
4
public_key='your_public_api_key',
5
private_key='your_private_api_key',
6
url_endpoint = 'https://ik.imagekit.io/your_imagekit_id/'
7
)
8
9
metadata = imagekit.get_metadata("file_id")
10
11
print("File detail-", metadata, end="\n\n")
Copied!
1
use ImageKit\ImageKit;
2
3
$public_key = "your_public_api_key";
4
$your_private_key = "your_private_api_key";
5
$url_end_point = "https://ik.imagekit.io/your_imagekit_id";
6
7
$imageKit = new ImageKit(
8
$public_key,
9
$your_private_key,
10
$url_end_point
11
);
12
13
$getFileDetails = $imageKit->getMetaData("file_id");
14
15
echo("File metadata : " . json_encode($getFileDetails));
Copied!
1
ResultMetaData result=ImageKit.getInstance().getFileMetadata("file_id");
Copied!
1
imagekitio = ImageKitIo::Client.new("your_private_key", "your_public_key", "your_url_endpoint")
2
file_metadata = imagekitio.get_file_metadata(file_id: "file_id")
Copied!

Calculate pHash distance between two images

See examples here.
Last modified 1mo ago