String size limit

Is there a limit to how big a String variable can be in the Photon?

I’ve been getting weather forecast data from worldweatheronline.com which returns a nice compact http.get string. However, what I thought was a free service isn’t anymore so I have to find a new API provider. Turns out weatherunlocked.com has similar data for free but their API returns a huge string full of data I mostly don’t need. One sample call returned 62,186 characters! Out of all of that I just want the 12 hour forecast, eg. “Sunny”, “Cloudy” or whatever.

If I try to http.get that, will my Photon crash? Or alternatively, is there a free weather API somewhere that has query parameters you can use to narrow down the data you receive?

The limit for C strings is only the available memory you’ve got, but with 60K+ you’ll definetly run out of space on the Photon.
Can you use webhooks to boil the response down to what you really need?

On the other hand, you’d not need to keep all the data if you just read and immediately discard what’s not needed, your local “copy” of the string won’t grow to that size.

I might - if I could figure out how they work. There are several threads addressing this issue here and after reading them carefully I'm afraid I still have no idea how to do it.

That sounds good, but how would I do that? When you call http.get (request, response, headers) do you not automatically get the entire 61K string in "response.body"? I have to parse that looking for instance of things like

<wx_desc>Clear skies</wx_desc>

This might help :smile:
https://docs.particle.io/tutorials/topics/webhooks/

Thanks - that’s one I hadn’t seen before. Let me go over that and see if I can get it to work. At least they show a similar weather example.

True, but if you use TCPClient instead of HTTPClient you've got control over the seperate packets.

Oh I get it - I hadn't thought of doing that. Thanks!