Skip to content

How to download image via API

This guide explains how to download images using the curl command-line tool, assuming you have an image.json dictionary from your export.

Requirements

  • curl: Ensure curl is installed on your device. It’s a tool used to transfer data from or to a server.

How to obtain the JSON file

To get the JSON file from your export report via the API, follow the instructions in How to download JSON via API. This guide explains how to retrieve the export report that includes your image data.

Example JSON file

Here is an example of what your image.json file look:

[
{
"id": 8,
"img": {
"p": "rR5Hrqv2E7243HHLpZN/i/66eff4f76ef78bde4ec7de08.png",
"v": 1
}
},
{
"id": 9,
"img": {
"p": "rR5Hrqv2E7243HHLpZN/i/66eff5596ef78bde4ec7de0a.png",
"v": 22
}
}
]

Where:

  • p is a parameter IMAGE_PATH. How to use it read examples below.
  • v is a version parameter, representing the numeric version of an image. The version number increases each time the image is changed (updated within the item). The value starts at 1.

This parameter should be used for detecting image changes before the game-building process. For example:

  • The first time, you download all images and store their paths along with their versions.
  • The next time, you compare the versions in the newly downloaded directory with those stored locally. If the versions are the same, the image hasn’t changed.

This approach helps to download only the changed images, reducing the time required for the next game build.

Downloading images

The curl example provided is only to illustrate the process. You can use any tool or programming language to achieve the same result.

To download the image using the URL from your JSON file, execute the following curl command:

Terminal window
curl -s -L -XGET https://api.lootfabriq.io/v1/api/images/IMAGE_PATH \
-H "x-lootf-token: YOUR_API_TOKEN" > image-name.png

Example with actual path:

Terminal window
curl -s -L -XGET https://api.lootfabriq.io/v1/api/images/rR5Hrqv2E7243HHLpZN/i/66eff4f76ef78bde4ec7de08 \
-H "x-lootf-token: YOUR_API_TOKEN" > image-name.png

Finding and using your API token and image path

  • API token. The API token is necessary for authentication when accessing data via the API. To find your API token, navigate to the Export settings page on the dashboard. Here, you can copy your token for API access. Use this token to replace YOUR_API_TOKEN in the above commands.
  • Image path. The image path specifies the location of the image file you want to download. Use the image path from your JSON file to replace IMAGE_PATH in the command.