# Getting an image src from a website using thunkable API

**URL:** https://community.thunkable.com/t/getting-an-image-src-from-a-website-using-thunkable-api/1460910
**Category:** Questions about Thunkable X
**Created:** [August 20, 2021, 8:34pm UTC](https://community.thunkable.com/t/getting-an-image-src-from-a-website-using-thunkable-api/1460910 "2021-08-20T20:34:09Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![p.powercoders1i0t](https://avatars.discourse-cdn.com/v4/letter/p/f07891/32.png) [@p.powercoders1i0t](https://community.thunkable.com/u/p.powercoders1i0t)
#### Post date: [August 20, 2021, 8:34pm UTC](https://community.thunkable.com/t/getting-an-image-src-from-a-website-using-thunkable-api/1460910/1 "2021-08-20T20:34:10Z")

</div>

I’m using the Google custom search API to display a website’s games through an app. I’m able to retrieve the links on the website, but when I try to retrieve data within a pice of data I run into trouble.

I’m trying to retrieve an image URL that is inside pagemap \> cse\_thumbnail \> src

 ![Screen Shot 2021-08-20 at 1.25.30 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/5/c50d86e09471ce529d70a1f96ddb0a94172483c8.png)

Here is how I’ve set up my block code:

 ![Screen Shot 2021-08-20 at 1.32.06 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/6/b646dba8d2f45c1db523fb5d05c7103025bcd6fb.png)

but it returns null and I’m unsure why I retrieved a youtube video’s thumbnail with the same block code structure but I’ve had no luck in retrieving an image from a website.

Any help would be appreciated!

---

<div class="post-metadata">

### Author: ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)
#### Post date: [August 20, 2021, 9:05pm UTC](https://community.thunkable.com/t/getting-an-image-src-from-a-website-using-thunkable-api/1460910/2 "2021-08-20T21:05:06Z")

</div>

Can you back out a bit more and show the whole api call including the loop you seem To have this in. Not sure this code fits your need but I’d need more context to comment fully.

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [August 20, 2021, 9:06pm UTC](https://community.thunkable.com/t/getting-an-image-src-from-a-website-using-thunkable-api/1460910/3 "2021-08-20T21:06:10Z")

</div>

I see two problems:

1. You need to convert the JSON response to an object before you can get the properties of that object. Maybe you’re already doing this but it’s not clear from your screenshot.
2. You are parsing the JSON data in reverse. The first/outer property in the JSON tree is “pagemap” but you’re starting by getting the property “src” of the object. So while your parsing looks like this: src–\>cse\_thumbnail–\>pagemail, you actually want it to be pagemap–\>cse\_thumbnail–\>src. If that’s confusing, consider that the innermost `get property of object` block is going to run first in your code.

---

<div class="post-metadata">

### Author: ![p.powercoders1i0t](https://avatars.discourse-cdn.com/v4/letter/p/f07891/32.png) [@p.powercoders1i0t](https://community.thunkable.com/u/p.powercoders1i0t)
#### Post date: [August 20, 2021, 11:44pm UTC](https://community.thunkable.com/t/getting-an-image-src-from-a-website-using-thunkable-api/1460910/4 "2021-08-20T23:44:17Z")

</div>

@tatiang and @jared

Thanks for your help so far!

I think I did what you recommend to do Tatiang, but it’s still returning null. Here’s a closer look at the function

![Screen Shot 2021-08-20 at 4.45.16 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/a/6af79776ddc6a5ce2f4c586fef249b445e052a13.png)

---

<div class="post-metadata">

### Author: ![vishruth-ram](https://avatars.discourse-cdn.com/v4/letter/v/82dd89/32.png) [@vishruth-ram](https://community.thunkable.com/u/vishruth-ram)
#### Post date: [August 21, 2021, 6:12am UTC](https://community.thunkable.com/t/getting-an-image-src-from-a-website-using-thunkable-api/1460910/5 "2021-08-21T06:12:40Z")

</div>

you should try this block:  
 ![Screenshot 2021-08-21 114139](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/8/f81eb3710bf0ece4e13e871ba98ee989447df217.png)

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [August 21, 2021, 4:09pm UTC](https://community.thunkable.com/t/getting-an-image-src-from-a-website-using-thunkable-api/1460910/6 "2021-08-21T16:09:14Z")

</div>

You’re making things complicated before you have the JSON parsing working properly. Right now, you’re converting the JSON response to an object and then getting the “items” property from that and then looping through that list and attempting to get the property of object “j” which is now a list, not an object.

Simplify things greatly and just see if you can get **one** correct value from the “src” property without using a loop.

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [November 8, 2024, 1:17pm UTC](https://community.thunkable.com/t/getting-an-image-src-from-a-website-using-thunkable-api/1460910/7 "2024-11-08T13:17:19Z")

</div>


