# API results into a List Viewer

**URL:** https://community.thunkable.com/t/api-results-into-a-list-viewer/51051
**Category:** Questions about Thunkable X
**Created:** [October 9, 2018, 9:36am UTC](https://community.thunkable.com/t/api-results-into-a-list-viewer/51051 "2018-10-09T09:36:50Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![xuld](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/xuld/32/26396_2.png) [@xuld](https://community.thunkable.com/u/xuld)
#### Post date: [October 9, 2018, 9:36am UTC](https://community.thunkable.com/t/api-results-into-a-list-viewer/51051/1 "2018-10-09T09:36:50Z")

</div>

Hi All,

I have read a bunch of docs and other community articles today but I am finding a task (that I think should be simple) very frustrating! I am trying to get the results of an API into a listviewer to form a list of clickable links that will go to another page and use the relevant ID to load data from another API.

JSON response is as follows  
[{“key”:“1”,“value”:“Jindabyne”},{“key”:“2”,“value”:“Cooma”},{“key”:“3”,“value”:“Berridale”},{“key”:“4”,“value”:“Bombala”},{“key”:“5”,“value”:“Adaminaby”},{“key”:“6”,“value”:“Anglers Reach”},{“key”:“7”,“value”:“Dalgety”},{“key”:“8”,“value”:“Michelago”},{“key”:“9”,“value”:“Delegate”},{“key”:“10”,“value”:“Bredbo”},{“key”:“11”,“value”:“Numeralla”},{“key”:“12”,“value”:“Nimmitabel”},{“key”:“13”,“value”:“Jerangle”},{“key”:“14”,“value”:“Craigie”},{“key”:“15”,“value”:“Charlottes Pass”},{“key”:“16”,“value”:“Thredbo”},{“key”:“17”,“value”:“Perisher”},{“key”:“18”,“value”:“Guthega”},{“key”:“19”,“value”:“Mt Selwyn”}]

This is what I have in the blocks.

 ![49](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/6/26434b2d9b1bbbe95ae4533321a6f0f2e56f06ee.png)

So I think what is happening is:  
When Screen 1 starts  
Load data from the API URL  
Set my variable ListContents to empty list  
Then from the JSON object, insert the ‘name’ key into the list  
Set the contents of the List Viewer to the variable ListContents

However all I get is a blank row in the list viewer. Where am I going wrong?

Secondly when the user clicks one of these items (once populated) how do I use the key (integer) with the button and pass it to the next screen?

Thanks!

---

<div class="post-metadata">

### Author: ![Mark](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mark/32/18133_2.png) [@Mark](https://community.thunkable.com/u/Mark)
#### Post date: [October 11, 2018, 9:47pm UTC](https://community.thunkable.com/t/api-results-into-a-list-viewer/51051/2 "2018-10-11T21:47:18Z")

</div>

It looks like your JSON response is a representation of a list (you can tell because it starts with a ‘[’ character). Consequently, your

![53%20PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/d/6d0fc513cd0755669b5d2d30abb86510cb0f4952.png)

block is returning a list. You’ll need to iterate (i.e. loop) over that list using:

![36%20PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/d/0de892701d057c599be269d523913a0a24304f07.png)

and then use your

![20%20PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/f/2fb3f75956d1e7557b21001029b4a04cc94ccdfd.png)

block on each of the items in the list, which you can access by using the

![20%20PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/9/e9d486708e6fe0d364808b2fddbd42e750017418.png)

block that you will be able to find in the “Variables” category of the Blocks editor.

In that loop, you’ll want to just insert the ‘value’ property of each item ‘j’ into your ‘ListContents’.

I hope this helps.

-Mark

---

<div class="post-metadata">

### Author: ![darren](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/darren/32/69854_2.png) [@darren](https://community.thunkable.com/u/darren)
#### Post date: [February 10, 2019, 4:34am UTC](https://community.thunkable.com/t/api-results-into-a-list-viewer/51051/3 "2019-02-10T04:34:50Z")

</div>

Hey @Mark,  
I’m taking a stab at an API project using your approach above without success.

From my understanding, this is how I would loop through a list of JSON objects returned through an API, but this is not returning any results:

 ![Multiple%20Not%20Working](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/7/77bc0a9150d39de1c9e13401cc0663a1cb4f48dc.png)

Is this the correct approach or am I off base?

Thanks,  
Darren

* * *

**Appendix 1**  
Here is my [data](https://api.openbrewerydb.org/breweries?by_name=abita):

> [{  
> “id”: 2928,  
> “name”: “Abita Brewing Co”,  
> “brewery\_type”: “regional”,  
> “street”: “166 Barbee Rd”,  
> “city”: “Covington”,  
> “state”: “Louisiana”,  
> “postal\_code”: “70433-8651”,  
> “country”: “United States”,  
> “longitude”: null,  
> “latitude”: null,  
> “phone”: “9858933143”,  
> “website\_url”: “[http://www.abita.com](http://www.abita.com)”,  
> “updated\_at”: “2018-08-11T21:37:28.656Z”,  
> “tag\_list”:   
> }, {  
> “id”: 5130,  
> “name”: “Habitat Brewing Co”,  
> “brewery\_type”: “micro”,  
> “street”: “174 Broadway St”,  
> “city”: “Asheville”,  
> “state”: “North Carolina”,  
> “postal\_code”: “28801-2305”,  
> “country”: “United States”,  
> “longitude”: “-82.5533973”,  
> “latitude”: “35.5986648”,  
> “phone”: “7047018141”,  
> “website\_url”: “[http://www.habitatbrewing.com](http://www.habitatbrewing.com)”,  
> “updated\_at”: “2018-08-24T15:41:50.670Z”,  
> “tag\_list”:   
> }]

* * *

**Appendix 2**  
Through my struggles, I was able to brute force the result I was looking for:

 ![Multiple%20Brute%20Force%20Working](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/a/aa873f428300b55c01958723c371f7256dfe9d47.png)

---

<div class="post-metadata">

### Author: ![Mark](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mark/32/18133_2.png) [@Mark](https://community.thunkable.com/u/Mark)
#### Post date: [February 10, 2019, 8:31pm UTC](https://community.thunkable.com/t/api-results-into-a-list-viewer/51051/4 "2019-02-10T20:31:26Z")

</div>

Darren,

If you look carefully at my post above, you’ll note that I am using the `'get object from JSON'` block directly on the `'response'` block. You need to do that because the `'response'` is not itself a list. It is JSON text which represents a list. I know it’s a little confusing because in this case the `'get object from JSON'` block isn’t returning an object - it’s returning a list.

Once you have the list you can iterate over it an each item `j` will be one of the objects that you are interested in and that you can get the name of. I.e., you will simply do a `'get property name of object j'`.

Does that make sense?

-Mark

---

<div class="post-metadata">

### Author: ![darren](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/darren/32/69854_2.png) [@darren](https://community.thunkable.com/u/darren)
#### Post date: [February 10, 2019, 8:52pm UTC](https://community.thunkable.com/t/api-results-into-a-list-viewer/51051/5 "2019-02-10T20:52:15Z")

</div>

@Mark,

Thanks for your response. I got it working now!

The issue is the `'get object from JSON'` block will **not** connect to the `'for each item j in list'` block as depicted here:  
 ![Not%20Connecting](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/6/267bc3ed71807dcbcef2bd78773aeaabfac1f461.png)

However if I save the `'get object from JSON - response'` block in a list variable 1st, I am then able to connect the variable to the `'for each item j in list'` block. Glad to have this working, and I’ve added my final solution below.

Thanks,  
Darren

* * *

**_The following shows how to loop through a JSON List that is returned through an API response._**  
 ![Multiple%20Objects%20Working](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/8/3815df95c0ff4b3d1fdc3d6e41b278a214c5f9be.png)

---

<div class="post-metadata">

### Author: ![Mark](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mark/32/18133_2.png) [@Mark](https://community.thunkable.com/u/Mark)
#### Post date: [February 11, 2019, 1:39am UTC](https://community.thunkable.com/t/api-results-into-a-list-viewer/51051/6 "2019-02-11T01:39:13Z")

</div>

Darren,

I’m glad its working now! And I’ve reported the bug that you found whereby you couldn’t connect the `'get object from JSON'` block to the `'for each item j in list'` block.

-Mark

---

<div class="post-metadata">

### Author: ![bobbyj12](https://avatars.discourse-cdn.com/v4/letter/b/d26b3c/32.png) [@bobbyj12](https://community.thunkable.com/u/bobbyj12)
#### Post date: [February 12, 2020, 10:40pm UTC](https://community.thunkable.com/t/api-results-into-a-list-viewer/51051/7 "2020-02-12T22:40:39Z")

</div>

WHere do you find the “Get” block with the “Response” in it? I only see Value and Error when I pull from the Realtime component.

---

<div class="post-metadata">

### Author: ![Mark](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mark/32/18133_2.png) [@Mark](https://community.thunkable.com/u/Mark)
#### Post date: [February 12, 2020, 11:35pm UTC](https://community.thunkable.com/t/api-results-into-a-list-viewer/51051/8 "2020-02-12T23:35:57Z")

</div>

The `'get object from JSON'` block is in the Object drawer. You would plug the `Value` block in to that to create an object from the JSON response.

-Mark

---

<div class="post-metadata">

### Author: ![bobbyj12](https://avatars.discourse-cdn.com/v4/letter/b/d26b3c/32.png) [@bobbyj12](https://community.thunkable.com/u/bobbyj12)
#### Post date: [February 12, 2020, 11:44pm UTC](https://community.thunkable.com/t/api-results-into-a-list-viewer/51051/9 "2020-02-12T23:44:37Z")

</div>

Thanks @Mark. I was referring to the “In OpenBrewery” call block.

---

<div class="post-metadata">

### Author: ![Mark](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/mark/32/18133_2.png) [@Mark](https://community.thunkable.com/u/Mark)
#### Post date: [February 13, 2020, 6:45pm UTC](https://community.thunkable.com/t/api-results-into-a-list-viewer/51051/10 "2020-02-13T18:45:12Z")

</div>

Sorry, I meant to say that you would plug the `response` block (from your `'In OpenBreweryDB get'` call) into the `'get object from JSON'` block.

---

<div class="post-metadata">

### Author: ![bobbyj12](https://avatars.discourse-cdn.com/v4/letter/b/d26b3c/32.png) [@bobbyj12](https://community.thunkable.com/u/bobbyj12)
#### Post date: [February 13, 2020, 8:42pm UTC](https://community.thunkable.com/t/api-results-into-a-list-viewer/51051/11 "2020-02-13T20:42:40Z")

</div>

Hi @Mark. I followed the blocks above but parsing the db does not seem to work. Here are my blocks for pull the data for my ToDo list. It seems to save it to the db just fine. but will not display it in the listview. Also, since the data does not seem to be writing to my variable, it gets over-written when I exist the screen (this is when the list is saved to the DB. Any suggestions would be very appreciated.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/8/5854b34486f9daa494e0d81b80bfb78b058f7751.png)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/1/71183e6a085e5d52e3ca91920e75d639739c42ce.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/4/2410174c5cf86ac6c535cc0dc3f5d97b3a0a4ff7.png)

---

<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: [February 13, 2020, 9:05pm UTC](https://community.thunkable.com/t/api-results-into-a-list-viewer/51051/12 "2020-02-13T21:05:03Z")

</div>

I have been trying this today with no luck as well.

Following

---

<div class="post-metadata">

### Author: ![eoinparkinson](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/eoinparkinson/32/143769_2.png) [@eoinparkinson](https://community.thunkable.com/u/eoinparkinson)
#### Post date: [February 13, 2020, 9:13pm UTC](https://community.thunkable.com/t/api-results-into-a-list-viewer/51051/13 "2020-02-13T21:13:47Z")

</div>

Something like this? I believe the issue you are facing is something like one I had.

> [@\[Solved\] List adds items with empty text](http://community.thunkable.com/t/solved-list-adds-items-with-empty-text/312791/2):
>
> Hi, [%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5]

---

<div class="post-metadata">

### Author: ![alexey.ben](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@alexey.ben](https://community.thunkable.com/u/alexey.ben)
#### Post date: [November 30, 2020, 8:06pm UTC](https://community.thunkable.com/t/api-results-into-a-list-viewer/51051/14 "2020-11-30T20:06:13Z")

</div>

Hey , tried to do what you suggested here but with no luck unfortunately .  
Here is my data (Would be very thankful for any one who can help ) :  
“results”: [

```
    {

        "business_status": "OPERATIONAL",

        "geometry": {

            "location": {

                "lat": 32.4747588,

                "lng": 34.9713922

            },

            "viewport": {

                "northeast": {

                    "lat": 32.4760607302915,

                    "lng": 34.9726427302915

                },

                "southwest": {

                    "lat": 32.4733627697085,

                    "lng": 34.9699447697085

                }

            }

        },

        "icon": "https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/generic_business-71.png",

        "name": "Central Veterinary pets Pardes Hanna",

        "opening_hours": {

            "open_now": false

        },

        "photos": [

            {

                "height": 4160,

                "html_attributions": [

                    "<a href=\"https://maps.google.com/maps/contrib/114373861275704723265\">יערה בקר</a>"

                ],

                "photo_reference": "ATtYBwLb1k7mSuRy6mMRGcWuDkEvxXrvDGopTHGb7gC_bQcg6bYxlElEDh3Enl3uVDAmkOGCbn_MZuaXM5SC10qSMM_pOgcbyAwyudhqs2VrmDlUS-Ux6PxhQQZsXSZ5Z-0HDeRgV0SfIrRIbDwgr1amVbiWGzSG7e0VzV9K1qiNr-6D1oK-",

                "width": 3120

            }

        ],

        "place_id": "ChIJ8eHKNNUIHRUR6Ce4t9iy8YY",

        "plus_code": {

            "compound_code": "FXFC+WH Pardes Hanna-Karkur, Israel",

            "global_code": "8G4PFXFC+WH"

        },

        "rating": 4.8,

        "reference": "ChIJ8eHKNNUIHRUR6Ce4t9iy8YY",

        "scope": "GOOGLE",

        "types": [

            "veterinary_care",

            "point_of_interest",

            "establishment"

        ],

        "user_ratings_total": 147,

        "vicinity": "HaOranim Street 18, Pardes Hanna-Karkur"

    },

    {

        "business_status": "OPERATIONAL",

        "geometry": {

            "location": {

                "lat": 32.471729,

                "lng": 34.973782

            },

            "viewport": {

                "northeast": {

                    "lat": 32.4730747802915,

                    "lng": 34.97513418029149

                },

                "southwest": {

                    "lat": 32.4703768197085,

                    "lng": 34.9724362197085

                }

            }

        },

        "icon": "https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/generic_business-71.png",

        "name": "ד\"ר תמר וטרינרית",

        "opening_hours": {

            "open_now": true

        },

        "photos": [

            {

                "height": 2500,

                "html_attributions": [

                    "<a href=\"https://maps.google.com/maps/contrib/113764155770280100997\">ד&quot;ר תמר וטרינרית</a>"

                ],

                "photo_reference": "ATtYBwLRR-1lw5O3rpFEKRTQuDW_o8TfnM3E7I2q23BtZe5sA-MBN0YmiCYLCgRKPJEzhofawhBFCY8hunKw3kobocr0rFLZHKzwn2HVNBIq_LqyssXwX2Vih3zn8kwvZ0-5FB3lntfJlSEmfhc_TZLO4TN5bQsZ7SNFuOKfTVNP8TwViCtF",

                "width": 3750

            }

        ],

        "place_id": "ChIJucOIFTwOHRURXGwQdE1jWRU",

        "plus_code": {

            "compound_code": "FXCF+MG Pardes Hanna-Karkur, Israel",

            "global_code": "8G4PFXCF+MG"

        },

        "rating": 4.8,

        "reference": "ChIJucOIFTwOHRURXGwQdE1jWRU",

        "scope": "GOOGLE",

        "types": [

            "veterinary_care",

            "health",

            "point_of_interest",

            "establishment"

        ],

        "user_ratings_total": 16,

        "vicinity": "העצמאות 8 פרדס חנה כרכור"

    },
```

---

<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: [November 30, 2020, 9:08pm UTC](https://community.thunkable.com/t/api-results-into-a-list-viewer/51051/15 "2020-11-30T21:08:42Z")

</div>

@alexey.ben Which data item(s) are you wanting to get from that JSON response?

---

<div class="post-metadata">

### Author: ![alexey.ben](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@alexey.ben](https://community.thunkable.com/u/alexey.ben)
#### Post date: [December 1, 2020, 6:54am UTC](https://community.thunkable.com/t/api-results-into-a-list-viewer/51051/16 "2020-12-01T06:54:50Z")

</div>

@tatiang I`m sorry , forgot to explain my self.  
I actually want to get a list of “lat” property .  
I know how to get a specific lat property inside the (for example #2 index) but I want it to run and get a list with “lat” propertys .

---

<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: [December 1, 2020, 7:13am UTC](https://community.thunkable.com/t/api-results-into-a-list-viewer/51051/17 "2020-12-01T07:13:58Z")

</div>

I can help you create a loop to do that. What do your blocks look like that work to get a single lat property?

---

<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: [December 1, 2020, 4:45pm UTC](https://community.thunkable.com/t/api-results-into-a-list-viewer/51051/18 "2020-12-01T16:45:59Z")

</div>

Based on the blocks you sent me, it looks like your JSON response is just an array/list of businesses at the top level. So you should be able to use a “for each i in list [get property ‘results’ of object [get object from JSON [app response]]]” block and replace the “1” with i. The “for each” block would go around the entire function contents except the return block. You’d need to store the value you get in a list within the loop, using the “insert in list [app listviewer data] as last […the entire set of function blocks except the return block]”. Then, use the “app listviewer” as the value for your list viewer text items.

Try that and if you need a screenshot of the blocks, I can make that for you.

---

<div class="post-metadata">

### Author: ![alexey.ben](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@alexey.ben](https://community.thunkable.com/u/alexey.ben)
#### Post date: [December 6, 2020, 5:04pm UTC](https://community.thunkable.com/t/api-results-into-a-list-viewer/51051/19 "2020-12-06T17:04:17Z")

</div>

> [@tatiang](#):
>
> s

kindly , if you can please add a screenshot with the blocks (want to be sure i did the right thing)

---

<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: [December 8, 2020, 3:18am UTC](https://community.thunkable.com/t/api-results-into-a-list-viewer/51051/20 "2020-12-08T03:18:44Z")

</div>

@alexey.ben Try this:

 ![Screen Shot 2020-12-07 at 7.18.13 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/8/c8b63e5bbb55e52761bdcbb4ed5eae51dca69ff2.png)

[Next page](https://community.thunkable.com/t/api-results-into-a-list-viewer/51051.md?page=2)
