Third Light Developer Exchange

Code and templating community forum for developers and software integrators

You are not logged in.

Announcement

If you wish to join the Developer Exchange, please contact your account manager - this is to avoid unnecessary spam in the forums. Many thanks for your understanding.

#1 2021-04-28 06:14:57

Devrocketium
Member
Registered: 2021-04-26
Posts: 3

API to fetch asset/media by AssetID/ReferenceID

In the workflow followed by our client, media elements are searched by an ID in the search bar. It is being referred to as Asset ID or Reference ID. I couldn't find any api in the swagger api docs to fetch the media using this ID. Can you please help  with the apis required to fetch & download an asset(media element) by asset ID/Reference ID

Offline

#2 2021-04-28 09:56:00

MarcoThirdLight
Third Light Staff
Registered: 2020-09-14
Posts: 3

Re: API to fetch asset/media by AssetID/ReferenceID

The endpoint to get a direct URL of a file is:

/rest/v1/files/{fileId}/directUrl

with the ID added in instead of the {field} bit of course

You will need to authenticate first and provide the sessionId as a header for this request

As an example, if I do this in Python:

import requests
fileId = "66285385883"
fetch_endpoint = f"/rest/v1/files/{fileId}/directUrl"
fetch_response = requests.get(url=URL+fetch_endpoint, headers=headers)
print(fetch_response.text)

I get back

{"response":"https://d1br04p5jdm344.cloudfront.net/file/26/mu2J6ywmeRX4cqmu-M2mh.fmifP_JR/rev=2/Food-packaging-08.jpg"}

which is a direct URL for this file. If you look at the documentation in our API docs here:

https://infosys.thirdlight.com//apidocs … tDirectUrl

you can see that you are also allowed to make some modifications to the version of the picture you are fetching, without affecting the original file in Chorus.

Note that you can also use the Chorus UI to create derivatives of any given file to have different versions of it (such as crops or different file types) and then use their IDs instead to get those direct URL.

Offline

#3 2021-04-28 10:26:26

MarcoThirdLight
Third Light Staff
Registered: 2020-09-14
Posts: 3

Re: API to fetch asset/media by AssetID/ReferenceID

addendum: if it's about creating downloads it's better to use this endpoint instead:

/rest/v1/files/{fileId}/temporaryDirectUrl

as links created this way don't check for permissions in the same way and will automatically expire

Offline

#4 2021-04-28 12:57:20

Devrocketium
Member
Registered: 2021-04-26
Posts: 3

Re: API to fetch asset/media by AssetID/ReferenceID

Thank you for the swift response. That api worked.

Offline

Board footer