Not able to get complete API response, only few displays others say null

Dear All,

I am trying to get the lat and lon via Place Details API Playground | Geoapify website.

I am able to get the place_id from the json response but unable to get the lat,lon and address.

Sharing my blocks

also sharing the json resonse

output of json response

{“type”:“FeatureCollection”,“features”:[{“type”:“Feature”,“properties”:{“feature_type”:“details”,“categories”:[“highway”,“highway.public”],“datasource”:{“sourcename”:“openstreetmap”,“attribution”:“© OpenStreetMap contributors”,“license”:“Open Database Licence”,“url”:“https://www.openstreetmap.org/copyright",“raw”:{“osm_id”:214718489,“highway”:“unclassified”,“z_order”:330,“osm_type”:“w”}},“street”:"MIDC - Rabale”,“city”:“Navi Mumbai”,“county”:“Thane”,“state”:“Maharashtra”,“postcode”:“410701”,“country”:“India”,“country_code”:“in”,“formatted”:“MIDC - Rabale, Navi Mumbai - 410701, Maharashtra, India”,“address_line1”:“MIDC - Rabale”,“address_line2”:“Navi Mumbai - 410701, Maharashtra, India”,“lat”:19.1364033,“lon”:73.0112182,“timezone”:{“name”:“Asia/Kolkata”,“offset_STD”:“+05:30”,“offset_STD_seconds”:19800,“offset_DST”:“+05:30”,“offset_DST_seconds”:19800,“abbreviation_STD”:“IST”,“abbreviation_DST”:“IST”},“place_id”:“512bdd4444b3405240597ccb1dc124233340f00102f9011958cc0c00000000”},“geometry”:{“type”:“LineString”,“coordinates”:[[73.0079302,19.1402014],[73.0079799,19.1401204],[73.0087993,19.1387969],[73.0088729,19.1386632],[73.0090056,19.1384605],[73.0092273,19.1380926],[73.0093264,19.1378296],[73.0093649,19.1373759],[73.0093764,19.1365504],[73.0093763,19.1363151],[73.0102983,19.1363409],[73.0112182,19.1364033],[73.0117721,19.1364234],[73.0122037,19.1364046],[73.013233,19.1364306],[73.0134858,19.136442],[73.0136595,19.1364654],[73.0138412,19.1365396],[73.0141436,19.1367055],[73.0142288,19.1367568],[73.0143227,19.1368145],[73.0144266,19.1368753],[73.0147123,19.137054],[73.0148846,19.1371547],[73.0151213,19.1373105],[73.0152018,19.1373522]]}}]}

Your input is greatly appreciated.

Regards,
Sasi Preetha

I had to run your JSON text through a website to remove smart quotes but once I did, I was able to paste it into a JSON beautifier to see the JSON property tree:

You can see at the top that the path to the “lat” property is:

features → [1] → properties → lat

That’s exactly what you are doing with blocks in your screenshot. So I would think that would work. Maybe try rebuilding that set of blocks? I don’t see any extra characters like spaces but I’d double-check that there’s nothing besides the property names (“lat”, etc.).

Edit: Okay, that was silly of me… you already included the JSON tree. I just see a JSON text response and immediately go through that process. Lol.

1 Like

Thank you so much for your assistance:)

It works now…hmmm… strange… I guess it was waiting for your response after seeing your response it worked:)

1 Like

I am having this exact same problem.

I’m able to set my Text to the Geoapify API response for property “housenumber” and property “postcode” but I get “null” for property “street” and “city”

JSON response:
{
“results”: [
{
“datasource”: {
“sourcename”: “openstreetmap”,
“attribution”: “© OpenStreetMap contributors”,
“license”: “Open Database License”,
“url”: “OpenStreetMap
},
“country”: “United States”,
“country_code”: “us”,
“state”: “Kansas”,
“county”: “Neosho County”,
“city”: “Chanute”,
“postcode”: “66720”,
“street”: “South Santa Fe Avenue”,
“housenumber”: “1533”,
“lon”: -95.45260714285713,
“lat”: 37.66549102040816,

Code:

(ignore the “TX” below – that’s static. It’s supposed to pull values for the 1st, 2nd, 3rd, and 5th text boxes).

Start up:

After pressing Detect Location button:

I don’t freakin get it man…

Your blocks are all incorrect for retrieving values from the response. It’s possible that you’re seeing some values and not others because the preview is cached. This could be true if you’re previewing the project in the Thunkable Live app. I find that I have to force-quit it every time I want to preview a change in my project.

When you get the property of a JSON object, it’s a text string. But you’re then converting that to an object which won’t really work and also makes it unreadable in a label.

Just get rid of the get object from JSON blocks at the front of each set of blocks, as below. If you want to learn more about this, see my tutorial here: API JSON Tutorial (Video)

1 Like

Solved!

Thanks tatiang. I’ve watched your video and read several of your posts. Much quicker to do it with results[1].housenumber too!

Here’s the working block:

1 Like