# Distance matrix api not working

**URL:** https://community.thunkable.com/t/distance-matrix-api-not-working/2125372
**Category:** Questions about Thunkable X
**Tags:** webapi
**Created:** [November 10, 2022, 5:32pm UTC](https://community.thunkable.com/t/distance-matrix-api-not-working/2125372 "2022-11-10T17:32:08Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![krishanveer.gangwars](https://avatars.discourse-cdn.com/v4/letter/k/c57346/32.png) [@krishanveer.gangwars](https://community.thunkable.com/u/krishanveer.gangwars)
#### Post date: [November 10, 2022, 5:32pm UTC](https://community.thunkable.com/t/distance-matrix-api-not-working/2125372/1 "2022-11-10T17:32:08Z")

</div>

can Any1 help why this distance matrix of google map api is not working

---

<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 10, 2022, 5:52pm UTC](https://community.thunkable.com/t/distance-matrix-api-not-working/2125372/2 "2022-11-10T17:52:38Z")

</div>

Please post the full JSON response as text.

---

<div class="post-metadata">

### Author: ![krishanveer.gangwars](https://avatars.discourse-cdn.com/v4/letter/k/c57346/32.png) [@krishanveer.gangwars](https://community.thunkable.com/u/krishanveer.gangwars)
#### Post date: [November 10, 2022, 6:31pm UTC](https://community.thunkable.com/t/distance-matrix-api-not-working/2125372/4 "2022-11-10T18:31:07Z")

</div>

i am pasting the link of app can u plz check it.  
it is on the 4th screen distance calculator

---

<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 10, 2022, 6:44pm UTC](https://community.thunkable.com/t/distance-matrix-api-not-working/2125372/5 "2022-11-10T18:44:47Z")

</div>

I can look at it but I’ll need the full JSON response in order to help you! You can put the API url in a browser and copy and paste from there.

Without that, I have no idea if your blocks are correct because I can’t see the structure of the JSON.

---

<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 10, 2022, 6:49pm UTC](https://community.thunkable.com/t/distance-matrix-api-not-working/2125372/6 "2022-11-10T18:49:26Z")

</div>

Have you gotten this working in a browser yet? If not, then you shouldn’t be working in Thunkable yet. The first step is to make sure you can get a valid JSON response in a browser.

Because this doesn’t look like it’s going to work to me:

[image removed]

The user’s input will contain spaces and I think that will break the url.

But even if that works – and it may – **you’re using zero for the list index and that isn’t valid in Thunkable**. Try 1 instead. See the last part of this post:

> [@API JSON Tutorial (Video)](https://community.thunkable.com/t/api-json-tutorial-video/1140575/15):
>
> Interesting… I just got an email from Thunkable about a new feature available within text boxes, related to APIs and JSON parsing: [https://docs.thunkable.com/objects#nested-values-and-values-from-arrays](https://docs.thunkable.com/objects#nested-values-and-values-from-arrays) So, if you wanted to replace the blocks I show at the 21:52 mark in the video above: You could do that with these blocks: warning This could easily confuse some people if they’ve been following along in my video so please only use this new…

---

<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 10, 2022, 6:59pm UTC](https://community.thunkable.com/t/distance-matrix-api-not-working/2125372/7 "2022-11-10T18:59:58Z")

</div>

By the way, your code (with [1] as list indexes) works fine on a mobile device. It just fails in a browser. Many APIs don’t in a browser with Thunkable.

 ![IMG_CA09989033D8-1](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/a/da886c414345e830aafc6d868f5389ea91b8c167.jpeg)

⚠ I would recommend removing your API key from screenshots and project links unless you want people to use it!

---

<div class="post-metadata">

### Author: ![krishanveer.gangwars](https://avatars.discourse-cdn.com/v4/letter/k/c57346/32.png) [@krishanveer.gangwars](https://community.thunkable.com/u/krishanveer.gangwars)
#### Post date: [November 10, 2022, 7:01pm UTC](https://community.thunkable.com/t/distance-matrix-api-not-working/2125372/8 "2022-11-10T19:01:46Z")

</div>

i tried 1 index first it didnot worked later on i tried 0 index

```auto
{
   "destination_addresses" : ["France"],
   "origin_addresses" : ["Germany"],
   "rows" : [
      {
         "elements" : [
            {
               "distance" : {
                  "text" : "1,028 km",
                  "value" : 1027828
               },
               "duration" : {
                  "text" : "10 hours 52 mins",
                  "value" : 39134
               },
               "status" : "OK"
            }
         ]
      }
   ],
   "status" : "OK"
}

```

---

<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 10, 2022, 7:04pm UTC](https://community.thunkable.com/t/distance-matrix-api-not-working/2125372/9 "2022-11-10T19:04:23Z")

</div>

Your blocks work for me:

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/6/c6ef8459d40533c1aff79d610b774f4de010c314.png)

---

<div class="post-metadata">

### Author: ![krishanveer.gangwars](https://avatars.discourse-cdn.com/v4/letter/k/c57346/32.png) [@krishanveer.gangwars](https://community.thunkable.com/u/krishanveer.gangwars)
#### Post date: [November 10, 2022, 7:12pm UTC](https://community.thunkable.com/t/distance-matrix-api-not-working/2125372/10 "2022-11-10T19:12:39Z")

</div>

plz remove screenshot…thanx for ur help…it is working on mobile…i was just checking on web browser…

---

<div class="post-metadata">

### Author: ![krishanveer.gangwars](https://avatars.discourse-cdn.com/v4/letter/k/c57346/32.png) [@krishanveer.gangwars](https://community.thunkable.com/u/krishanveer.gangwars)
#### Post date: [November 10, 2022, 7:17pm UTC](https://community.thunkable.com/t/distance-matrix-api-not-working/2125372/11 "2022-11-10T19:17:52Z")

</div>

plz remove this screenshot …my key is visible in this…

---

<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 10, 2022, 7:40pm UTC](https://community.thunkable.com/t/distance-matrix-api-not-working/2125372/12 "2022-11-10T19:40:01Z")

</div>

You should be able to edit your post. Click on the 3 dots and then on the pencil.

---

<div class="post-metadata">

### Author: ![krishanveer.gangwars](https://avatars.discourse-cdn.com/v4/letter/k/c57346/32.png) [@krishanveer.gangwars](https://community.thunkable.com/u/krishanveer.gangwars)
#### Post date: [November 10, 2022, 7:51pm UTC](https://community.thunkable.com/t/distance-matrix-api-not-working/2125372/13 "2022-11-10T19:51:54Z")

</div>

I have deleted my screenshot but u also posted a screenshot …in which key is visible

---

<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 10, 2022, 8:25pm UTC](https://community.thunkable.com/t/distance-matrix-api-not-working/2125372/14 "2022-11-10T20:25:08Z")

</div>

Sorry about that, I’ve removed it.

---

<div class="post-metadata">

### Author: ![krishanveer.gangwars](https://avatars.discourse-cdn.com/v4/letter/k/c57346/32.png) [@krishanveer.gangwars](https://community.thunkable.com/u/krishanveer.gangwars)
#### Post date: [November 11, 2022, 3:54am UTC](https://community.thunkable.com/t/distance-matrix-api-not-working/2125372/15 "2022-11-11T03:54:02Z")

</div>

Thanx man.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)
#### Post date: [February 9, 2023, 3:54am UTC](https://community.thunkable.com/t/distance-matrix-api-not-working/2125372/16 "2023-02-09T03:54:28Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
