How to download JSON & images via Docker
This guide will help you download JSON data and images from Lootfabriq using the docker.
Requirements
Using docker
You can use our docker image to simplify dictionary and images downloading.
Paths can be relative to the directory where you’re running the Docker command or absolute:
- Example of an absolute path:
/opt/projects/my_game/dictionaries
- Example of a relative path:
./my_game/dictionaries
(relative to the directory where the command is executed)
To download the latest completed report dictionaries in the instance:
docker run --rm \ -v <YOUR_PATH_TO_DICTIONARIES_DIRECTORY>:/opt/lootfabriq/export \ -v <YOUR_PATH_TO_IMAGES_DIRECTORY>:/opt/lootfabriq/images \ lootfabriq/dictionary-downloader:latest \ --instance <YOUR_INSTANCE_ID> \ --token <YOUR_API_TOKEN>
Example with real values:
docker run --rm \ -v /opt/projects/my_game/dictionaries:/opt/lootfabriq/export \ -v /opt/projects/my_game/images:/opt/lootfabriq/images \ lootfabriq/dictionary-downloader:latest \ --instance 45 \ --token 12345abcde67890fghij
To download the specific report dictionaries in the instance:
docker run --rm \ -v <YOUR_DICTIONARY_PATH>:/opt/lootfabriq/export \ -v <YOUR_IMAGE_PATH>:/opt/lootfabriq/images \ lootfabriq/dictionary-downloader:latest \ --instance <YOUR_INSTANCE_ID> \ --token <YOUR_API_TOKEN> \ --report <YOUR_REPORT_ID>
- Argument
--rm
removes the container after command execution. See docker docs for more info. - Argument
-v
mounts OS directory inside the container. See docker docs for more info.
How it works
The script uses the Lootfabriq API to download exported dictionaries and then synchronizes images from the image.json
dictionary.
Version file
As the Docker script runs, it stores the version of each downloaded image. The version file is saved in the images directory, for example, /opt/projects/my_game/images/versions.json
in our example.
This file is essential to ensure that only updated or new images are downloaded during subsequent runs, reducing unnecessary downloads and saving time.
Note about images
The script searches for the image dictionary image.json
in the export directory (e.g., /opt/projects/my_game/dictionaries
in our example).
It iterates through each image in the dictionary and downloads it if necessary.
Each image in Lootfabriq has a version that updates whenever the image is modified. The Docker script checks this version and downloads the image under the following conditions:
- If the image is not present in the locally stored versions file.
- If the image version in the locally stored versions file is lower than the version in the image dictionary.
If the image version hasn’t changed, it won’t be downloaded again.
Finding and using your API token, instance ID, and report ID
- 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 replaceYOUR_API_TOKEN
in the above commands. - Instance ID. The instance ID identifies the specific environment or project you are working in. You can find
your instance ID on the dashboard. Use this ID to replace
YOUR_INSTANCE_ID
in the above commands. - Report ID. You can find your report ID in the
Exported data
section of the dashboard. Each report is listed with its unique ID, which is needed to retrieve specific reports. Use this ID to replaceYOUR_REPORT_ID
in the above commands.