Introduction
Using the Imago Application Programming Interface (API) and some basic web service tools it is possible to generate a list of images currently available for a project.
Here some example code from a .bat file which accomplishes this task:
@echo off
set "im_user=ImagoDemo1"
set "im_password=ImagoDemo1"
set "im_file_out=list.csv"
echo "PROJECT","DATASET","ENTITY","SERIETYPE","IMAGERYTYPE","STARTDEPTH","ENDDEPTH","URL" > %im_file_out%
echo %im_password%
FOR /F "tokens=* USEBACKQ" %%F IN (`curl -X PUT -d username^="%im_user%" -d password^="%im_password%" https://io.imago.live/integrate/1/session ^| jq -r ".apiToken"`) DO (
set varApiToken=%%F
)
echo "The API Token is: %varApiToken%"
FOR /F "tokens=1,2,3,4,5,6 delims=$$$ USEBACKQ" %%G IN (`curl -H "imago-api-token: %varApiToken%" -X GET https://io.imago.live/integrate/1/context ^| jq -r "foreach .projects[] as $item ([];foreach $item.datasets[] as $dset([];foreach $dset.dataSeriesTypes[] as $dser([];$item.name + \"$$$\" + $dset.id + \"$$$\" + $dset.name + \"$$$\" + $dser.id + \"$$$\" + $dser.name + \"$$$\" + $dser.imageryTypes[].name)))"`) DO (
FOR /F "tokens=1,2 delims=$$$ USEBACKQ" %%M IN (`curl -H "imago-api-token: %varApiToken%" -X GET https://io.imago.live/integrate/1/dataentity?datasetid^=%%H ^| jq -r "foreach .dataEntities[] as $ent ([];$ent.id + \"$$$\" + $ent.name)"`) DO (
FOR /F "tokens=1,2,3 delims=$$$ USEBACKQ" %%O IN (`curl -H "imago-api-token: %varApiToken%" -X GET https://io.imago.live/integrate/1/dataitem?dataentityid^=%%M^^^&dataseriestypeid^=%%J ^| jq -r "foreach .dataItems[] as $data([];$data.id + \"$$$\" + ($data.startDepth | tostring) + \"$$$\" + ($data.endDepth | tostring))"`) DO (
echo "%%G","%%I","%%N","%%K","%%L","%%P","%%Q","https://portal.imago.live/api/display?pj=%%G&da=%%I&de=%%N&ds=%%K&im=%%L&dp=%%P" >> %im_file_out%
)
)
)
You will need some calls to the webservice (curl.exe) and manage the JSON (jq.exe).
As an example:
- Download DownloadList v2.zip
- Extract the contents to a local folder
- Open Windows Explorer and navigate to the folder.
- Double-click DownloadList.bat.
Alternatively, instead of 3 and 4 above:
- Open a Command Window and change directory to the local folder.
- Type in 'downloadlist.bat' (you may need to run as Administrator)
- Press the Enter/Return key.
![]() |
The download will take a few minutes. There a large number of images. |
The resulting List.csv file looks like this:
WHERE NEXT |
Imago IO for Developers |
Scanning a Directory for Images - Script |
Useful Powershell Scripts for Task Automation in Imago |
Comments
0 comments
Article is closed for comments.