[Solved] Geocoding API to locate the address

Hi,

I am trying to get the address details via following API https://api.geoapify.com/v1/geocode/search?text=[place name]&apiKey=YOUR_API_KEY

Below is the Json response:

{“type”:“FeatureCollection”,“features”:[{“type”:“Feature”,“properties”:{“datasource”:{“sourcename”:“openstreetmap”,“attribution”:“© OpenStreetMap contributors”,“license”:“Open Database Licence”,“url”:“https://www.openstreetmap.org/copyright"},“name”:"Annai Arul Hospital”,“street”:“Tambaram-Sriperumbudur Highway”,“neighbourhood”:“Peerkankaranai”,“suburb”:“Perungalathur”,“city”:“Tambaram”,“county”:“Tambaram”,“state_district”:“Chengalpattu District”,“state”:“Tamil Nadu”,“postcode”:“600063”,“country”:“India”,“country_code”:“in”,“lon”:80.08801007859745,“lat”:12.9207815,“formatted”:“Annai Arul Hospital, Tambaram-Sriperumbudur Highway, Tambaram - 600063, Tamil Nadu, India”,“address_line1”:“Annai Arul Hospital”,“address_line2”:“Tambaram-Sriperumbudur Highway, Tambaram - 600063, Tamil Nadu, India”,“result_type”:“amenity”,“rank”:{“importance”:0.30100000000000005,“popularity”:1.6891035262901575,“confidence”:1,“match_type”:“full_match”},“place_id”:“51d85206f5a1055440590e863aac70d72940f00102f90125a4fe1b00000000c00201920313416e6e6169204172756c20486f73706974616c”},“bbox”:[80.0877133,12.9203822,80.0884227,12.9210841],“geometry”:{“type”:“Point”,“coordinates”:[80.08801007859745,12.9207815]}}],“query”:{“text”:“annai arul hospital”}}

I do not get any error but I get the reply as undefined.

Sharling the link Thunkable

Your input/assistance would be highly appreciated.

Hey @sasi26preetha4r - there are lots of great JSON tutorials in the community.

Here are two of them:

Hope that helps!

1 Like

Thank you so much. I did go through the API JSON tutorial video and understood how to get data.

Followed the same method but for some reason I do not get the desired output, thus seek assistance.

@sasi26preetha4r got it.

Can you share a screenshot of the blocks you’re using and a screenshot of the output you’re getting?

Here are the screenshots.

The JSON response you posted above isn’t valid so I can’t re-format it. you can use this website to validate your JSON before posting it. Can you post a screenshot of the JSON response?

Have shared the screenshot Tatiang.

Also sharing the API website(https://www.geoapify.com/geocoding-api) screenshot

.

I would expect Label1’s Text to be “Tambaram”. Make sure you test it on a mobile device. Some APIs don’t work in a browser.

2 Likes

Yahooo:) Thank you so much Tatiang.

I found why I got undefined before and how I am getting the city name printed now, b’coz I searched along with the city name thus I got undefined and now when I searched with the place name alone I get the city name displayed.

Your tutuioal video is very informative and helpful , from there is where I learnt how to read datd from Json response.

Thanks again.

1 Like