[SOLVED 2/9/24 3:35 PM EDT] Unsplash not using arrays/lists so how to import correct data

I have read tons of posts and seen tutorials regarding how to capture the object/property/value from an api. (Special thank you to the ones made this videos, very very useful. )
I have one simple question in your tutorials there are sort of a pre requisite that the api using arrays - But i just learnt thet unsplash api does not. So how can i then. Get the properties from the objects when nested.
Have tried this- The response is all good as i have viewed it separately. Likewise with the image URL that i want to pick up. But i can just do it with this blocks as i get “NULL”
URL Used - (except the “apikey” ) is this:
https://api.unsplash.com/photos/random?&orientation=portrait&count=1&query=horse

What is even more important than the url is the full JSON response posted as text here. Make sure to format it with the </> button in the forums toolbar (right above the post when you are editing it).

You can get the response by assigning the green response block to a Text Input’s Text. Then just copy it from the preview and paste it here and reformat it.

Yes sure - here you have a response as an example…Please advice…


[{"id":"tolcU--dvuw","slug":"brown-horse-tolcU--dvuw","created_at":"2019-07-21T18:55:26Z","updated_at":"2024-02-09T02:09:38Z","promoted_at":"2019-07-21T21:13:12Z","width":3589,"height":4486,"color":"#d9d9d9","blur_hash":"LkJRXHtR_NRj?bayRjj[x]WBRjof","description":"Portrait of an Icelandic horse in the snow.","alt_description":"brown horse","breadcrumbs":[],"urls":{"raw":"https://images.unsplash.com/photo-1563734956808-602dab25525f?ixid=M3w1NjQ2ODR8MHwxfHJhbmRvbXx8fHx8fHx8fDE3MDc0NjM0Njl8\u0026ixlib=rb-4.0.3","full":"https://images.unsplash.com/photo-1563734956808-602dab25525f?crop=entropy\u0026cs=srgb\u0026fm=jpg\u0026ixid=M3w1NjQ2ODR8MHwxfHJhbmRvbXx8fHx8fHx8fDE3MDc0NjM0Njl8\u0026ixlib=rb-4.0.3\u0026q=85","regular":"https://images.unsplash.com/photo-1563734956808-602dab25525f?crop=entropy\u0026cs=tinysrgb\u0026fit=max\u0026fm=jpg\u0026ixid=M3w1NjQ2ODR8MHwxfHJhbmRvbXx8fHx8fHx8fDE3MDc0NjM0Njl8\u0026ixlib=rb-4.0.3\u0026q=80\u0026w=1080","small":"https://images.unsplash.com/photo-1563734956808-602dab25525f?crop=entropy\u0026cs=tinysrgb\u0026fit=max\u0026fm=jpg\u0026ixid=M3w1NjQ2ODR8MHwxfHJhbmRvbXx8fHx8fHx8fDE3MDc0NjM0Njl8\u0026ixlib=rb-4.0.3\u0026q=80\u0026w=400","thumb":"https://images.unsplash.com/photo-1563734956808-602dab25525f?crop=entropy\u0026cs=tinysrgb\u0026fit=max\u0026fm=jpg\u0026ixid=M3w1NjQ2ODR8MHwxfHJhbmRvbXx8fHx8fHx8fDE3MDc0NjM0Njl8\u0026ixlib=rb-4.0.3\u0026q=80\u0026w=200","small_s3":"https://s3.us-west-2.amazonaws.com/images.unsplash.com/small/photo-1563734956808-602dab25525f"},"links":{"self":"https://api.unsplash.com/photos/brown-horse-tolcU--dvuw","html":"https://unsplash.com/photos/brown-horse-tolcU--dvuw","download":"https://unsplash.com/photos/tolcU--dvuw/download?ixid=M3w1NjQ2ODR8MHwxfHJhbmRvbXx8fHx8fHx8fDE3MDc0NjM0Njl8","download_location":"https://api.unsplash.com/photos/tolcU--dvuw/download?ixid=M3w1NjQ2ODR8MHwxfHJhbmRvbXx8fHx8fHx8fDE3MDc0NjM0Njl8"},"likes":472,"liked_by_user":false,"current_user_collections":[],"sponsorship":null,"topic_submissions":{"animals":{"status":"approved","approved_on":"2020-04-06T14:20:17Z"}},"user":{"id":"SOHPa8DtV5Q","updated_at":"2023-10-25T01:19:38Z","username":"davemullenjnr","name":"Dave Mullen","first_name":"Dave","last_name":"Mullen","twitter_username":"davemullenjnr","portfolio_url":"https://davemullenjnr.co.uk","bio":"Designer, photographer, developer.","location":"Sheffield, UK.","links":{"self":"https://api.unsplash.com/users/davemullenjnr","html":"https://unsplash.com/@davemullenjnr","photos":"https://api.unsplash.com/users/davemullenjnr/photos","likes":"https://api.unsplash.com/users/davemullenjnr/likes","portfolio":"https://api.unsplash.com/users/davemullenjnr/portfolio","following":"https://api.unsplash.com/users/davemullenjnr/following","followers":"https://api.unsplash.com/users/davemullenjnr/followers"},"profile_image":{"small":"https://images.unsplash.com/profile-1563446293469-f6a8ec2b1229?ixlib=rb-4.0.3\u0026crop=faces\u0026fit=crop\u0026w=32\u0026h=32","medium":"https://images.unsplash.com/profile-1563446293469-f6a8ec2b1229?ixlib=rb-4.0.3\u0026crop=faces\u0026fit=crop\u0026w=64\u0026h=64","large":"https://images.unsplash.com/profile-1563446293469-f6a8ec2b1229?ixlib=rb-4.0.3\u0026crop=faces\u0026fit=crop\u0026w=128\u0026h=128"},"instagram_username":"davemullenjnr","total_collections":1,"total_likes":0,"total_photos":4,"total_promoted_photos":3,"accepted_tos":true,"for_hire":false,"social":{"instagram_username":"davemullenjnr","portfolio_url":"https://davemullenjnr.co.uk","twitter_username":"davemullenjnr","paypal_email":null}},"exif":{"make":"Canon","model":"Canon EOS 6D","name":"Canon, EOS 6D","exposure_time":"1/125","aperture":"4.0","focal_length":"67.0","iso":400},"location":{"name":null,"city":null,"country":null,"position":{"latitude":null,"longitude":null}},"views":1755067,"downloads":10592}]

PS this is the API used…

If you paste that into Best JSON Viewer and JSON Beautifier Online, you can click on any property to view the path to it. For example, here is a screenshot after clicking “regular”:

You can see the path at the top: array–>0–>urls–>regular.

This shows that the object is an array/list and you’ll need to get the first item of the list (JSON arrays start counting at 0) and then get “urls” from that and finally “regular” from that.

So your property name in Thunkable should be “[1].urls.regular”

It’s a shorthand to use [1] to mean the first item of a list. If you prefer, you can use the list blocks to do that and just get the first list item of property “urls.regular”

Of course this worked perfect and as expected
Thanks a lot - it will also hepl for my other api projects :pray:t2::pray:t2::pray:t2::grinning::grinning::grinning:

2 Likes