# Need Help With Api

**URL:** <https://community.thunkable.com/t/need-help-with-api/1383029>\
**Category:** Questions about Thunkable X\
**Created:** [July 7, 2021, 5:35am UTC](https://community.thunkable.com/t/need-help-with-api/1383029 "2021-07-07T05:35:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![overturner](https://avatars.discourse-cdn.com/v4/letter/o/53a042/32.png) [@overturner](https://community.thunkable.com/u/overturner)\
**Post date:** [July 7, 2021, 5:35am UTC](https://community.thunkable.com/t/need-help-with-api/1383029/1 "2021-07-07T05:35:25Z")

</div>

[https://api.dictionaryapi.dev/api/v2/entries/en\_US/USA](https://api.dictionaryapi.dev/api/v2/entries/en_US/USA)  
Hi , this is my api and this is the code is used  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/d/1d2b776bea0db5dc8e549dd7acb3357776f7b7d4.png)  
But my app is not returning USA in the alert , it returns null

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [July 7, 2021, 5:39am UTC](https://community.thunkable.com/t/need-help-with-api/1383029/2 "2021-07-07T05:39:48Z")

</div>

First, you need to check for errors and you also need to check if the status is 200 or not. Check out @tatiang’s video on API handling. Also, what do you see when you run the app?

---

<div class="post-metadata">

**Author:** ![overturner](https://avatars.discourse-cdn.com/v4/letter/o/53a042/32.png) [@overturner](https://community.thunkable.com/u/overturner)\
**Post date:** [July 7, 2021, 5:41am UTC](https://community.thunkable.com/t/need-help-with-api/1383029/3 "2021-07-07T05:41:21Z")

</div>

i checked the response it returns whatever there is i am supposed to receive.  
But i cant understand how to get the word property

```auto
[
{
word: "USA",
phonetics: [
{
text: "/ˌju ˌɛs ˈeɪ/",
audio: "https://lex-audio.useremarkable.com/mp3/usa_us_1.mp3"
}
],
meanings: [
{
partOfSpeech: "abbreviation",
definitions: [
{
definition: "United States of America."
},
{
definition: "United States Army."
}
]
}
]
}
]

```

I get this when i just check the response  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/6/d64d29eab4c80c4d61656314957e5ebb2ab2a33a.png)  
probably because there is a square bracket in the result this error maybe caused , can you tell how to handle this?

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [July 7, 2021, 5:49am UTC](https://community.thunkable.com/t/need-help-with-api/1383029/4 "2021-07-07T05:49:18Z")

</div>

I have a small doubt: since you already have USA written in the URL, that means you already know the word, why are you using an API to get the same thing?

---

<div class="post-metadata">

**Author:** ![overturner](https://avatars.discourse-cdn.com/v4/letter/o/53a042/32.png) [@overturner](https://community.thunkable.com/u/overturner)\
**Post date:** [July 7, 2021, 5:50am UTC](https://community.thunkable.com/t/need-help-with-api/1383029/5 "2021-07-07T05:50:47Z")

</div>

no , that is just an example , i have a random word generator and that will be used to generate a word. Also , i actually needed the audio property but thought the word property would be easier to fetch

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [July 7, 2021, 5:54am UTC](https://community.thunkable.com/t/need-help-with-api/1383029/6 "2021-07-07T05:54:56Z")

</div>

Oh, ok. May I ask which random word generator you are suing, since I’m looking for one myself?

---

<div class="post-metadata">

**Author:** ![overturner](https://avatars.discourse-cdn.com/v4/letter/o/53a042/32.png) [@overturner](https://community.thunkable.com/u/overturner)\
**Post date:** [July 7, 2021, 5:55am UTC](https://community.thunkable.com/t/need-help-with-api/1383029/7 "2021-07-07T05:55:55Z")

</div>

[https://random-word-api.herokuapp.com/all](https://random-word-api.herokuapp.com/all)  
thunkable code:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/a/3a715b0f718c711152c1dfbc633487b5ef9131b1.png)  
[https://random-word-api.herokuapp.com/home](https://random-word-api.herokuapp.com/home)  
Also , this api is not owned by me nor am i promoting it 😀

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [July 7, 2021, 5:59am UTC](https://community.thunkable.com/t/need-help-with-api/1383029/8 "2021-07-07T05:59:33Z")

</div>

Thank you very much! I just pasted the response from the dictionary API into a json formatter, and it says that the JSON is invalid. Can you do this:  
when you set the web API’s url, paste it into an input, and add a wait 4 seconds block. In that time, copy the response and paste it here. I want to see what response you are getting, not just the sample data.

---

<div class="post-metadata">

**Author:** ![overturner](https://avatars.discourse-cdn.com/v4/letter/o/53a042/32.png) [@overturner](https://community.thunkable.com/u/overturner)\
**Post date:** [July 7, 2021, 6:01am UTC](https://community.thunkable.com/t/need-help-with-api/1383029/9 "2021-07-07T06:01:08Z")

</div>

this is what i get in thunkable  
[{“word”:“USA”,“phonetics”:[{“text”:"/ˌju ˌɛs ˈeɪ/",“audio”:“[https://lex-audio.useremarkable.com/mp3/usa\_us\_1.mp3"}],“meanings”:[{“partOfSpeech”:“abbreviation”,“definitions”:[{“definition”:"United](https://lex-audio.useremarkable.com/mp3/usa_us_1.mp3%22%7D%5D,%22meanings%22:%5B%7B%22partOfSpeech%22:%22abbreviation%22,%22definitions%22:%5B%7B%22definition%22:%22United) States of America.”},{“definition”:“United States Army.”}]}]}]

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [July 7, 2021, 6:01am UTC](https://community.thunkable.com/t/need-help-with-api/1383029/10 "2021-07-07T06:01:32Z")

</div>

Cool, let me paste it and tell you what I find.

---

<div class="post-metadata">

**Author:** ![overturner](https://avatars.discourse-cdn.com/v4/letter/o/53a042/32.png) [@overturner](https://community.thunkable.com/u/overturner)\
**Post date:** [July 7, 2021, 6:02am UTC](https://community.thunkable.com/t/need-help-with-api/1383029/11 "2021-07-07T06:02:21Z")

</div>

Thanks , you can use this link too [https://api.dictionaryapi.dev/api/v2/entries/en\_US/USA](https://api.dictionaryapi.dev/api/v2/entries/en_US/USA)

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [July 7, 2021, 6:04am UTC](https://community.thunkable.com/t/need-help-with-api/1383029/12 "2021-07-07T06:04:49Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [July 7, 2021, 6:10am UTC](https://community.thunkable.com/t/need-help-with-api/1383029/13 "2021-07-07T06:10:39Z")

</div>

OK, so there’s something very weird going on.  
When I try to paste your first response in a JSON formatter, it says Bad String, and doesn’t format it. When I paste the response from the link, it formats it correctly.

---

<div class="post-metadata">

**Author:** ![overturner](https://avatars.discourse-cdn.com/v4/letter/o/53a042/32.png) [@overturner](https://community.thunkable.com/u/overturner)\
**Post date:** [July 7, 2021, 6:11am UTC](https://community.thunkable.com/t/need-help-with-api/1383029/14 "2021-07-07T06:11:35Z")

</div>

That’s strange

---

<div class="post-metadata">

**Author:** ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)\
**Post date:** [July 7, 2021, 6:12am UTC](https://community.thunkable.com/t/need-help-with-api/1383029/15 "2021-07-07T06:12:39Z")

</div>

Aha! In the first response, you have curved quotation marks: “ ”. They’re supposed to be straight, like this: " ". Before parsing, use a replace block to replace all the curved quotation marks with the straight ones.

---

<div class="post-metadata">

**Author:** ![overturner](https://avatars.discourse-cdn.com/v4/letter/o/53a042/32.png) [@overturner](https://community.thunkable.com/u/overturner)\
**Post date:** [July 7, 2021, 6:14am UTC](https://community.thunkable.com/t/need-help-with-api/1383029/16 "2021-07-07T06:14:03Z")

</div>

Where to do this exactly?

---

<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:** [July 7, 2021, 6:32am UTC](https://community.thunkable.com/t/need-help-with-api/1383029/17 "2021-07-07T06:32:18Z")

</div>

The problem is that your API returns invalid JSON. JSON cannot contain comments (lines that start with //).

---

<div class="post-metadata">

**Author:** ![overturner](https://avatars.discourse-cdn.com/v4/letter/o/53a042/32.png) [@overturner](https://community.thunkable.com/u/overturner)\
**Post date:** [July 7, 2021, 6:34am UTC](https://community.thunkable.com/t/need-help-with-api/1383029/18 "2021-07-07T06:34:00Z")

</div>

Where are those lines in the random word generator or word detail finder?

---

<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:** [July 7, 2021, 6:38am UTC](https://community.thunkable.com/t/need-help-with-api/1383029/19 "2021-07-07T06:38:14Z")

</div>

Actually, I was wrong. Thunkable seems to handle those comments okay in the response.

This works:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/0/70c5e2a0b648098a5764c851cc920242db7b06e4.png)

You have to take the first item of the list before getting the property “word” because the JSON response has an array ([] brackets).

---

<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:** [July 7, 2021, 6:40am UTC](https://community.thunkable.com/t/need-help-with-api/1383029/20 "2021-07-07T06:40:39Z")

</div>

You can see this is the case if you paste the response to something like this:

[https://random-word-api.herokuapp.com/word?number=10](https://random-word-api.herokuapp.com/word?number=10)

Into this site and click Tree Viewer:

> **[Best JSON Viewer and JSON Beautifier Online](https://codebeautify.org/jsonviewer)**
>
> Online JSON Viewer, JSON Beautifier to beautify and tree view of JSON data - It works as JSON Pretty Print to pretty print JSON data.

[Next page](https://community.thunkable.com/t/need-help-with-api/1383029.md?page=2)
