Quantcast
Channel: The Things Network - Latest posts
Viewing all articles
Browse latest Browse all 116833

Extract Json array. (Example needed)

$
0
0

@turiphro, would keeping track of offset work as well? Like: if I know I already got 28 values in my own database, would http://thethingsnetwork.org/api/v0/nodes/05060709/?offset=28 get me all new values (if any)? I guess not, as I assume that TTN will not keep all data forever. So if today the Nth result refers to, say, March 24th 2016, then some time later (after old data has been deleted) that same Nth value might be for, say, May 29th 2016. (And if that's true, then limit cannot be used to get all data.)

@muzab, like turiphro explained: parsing JSON is just not specific to LoRaWAN or The Things Network, and there are much better help resources for general programming questions.

Still then:

  • Like with any other proper JSON API, when invoking it using Accept: application/json, you'll get true JSON without HTML. In a browser you could add format=json to mimic that, like http://thethingsnetwork.org/api/v0/nodes/05060709/?format=json
  • Beware that when using a node EUI such as 05060709 others might send data using the same value. (Some day the node hardware itself will get one a true unique device id.) So ensure you get the expected payload when parsing the value of data.
  • It seems weird that you want to store values in a database but are asking for 'the first and last "data_plain" & "time" values'. Assuming one day it will be real data, wouldn't you want to store all other values too? When using limit=1 you might get the very same value multiple times, or be missing values when you don't ask often enough. So you might want to process the JSON by searching for timestamps larger than your last known value. Like in JavaScript one might use JSONPath to query for $..*(@time > "2016-03-25T11:31:34.699Z")] (not tested).
  • Beware that data_plain might be removed from the JSON response. It's just not a good idea to send data from nodes using ASCII text, which I already explained in one of your other questions.
  • The REST API is not the only API; to store data in your own database consider using the MQTT interface instead. MQTT is also not specific to LoRaWAN or The Things Network though.

Viewing all articles
Browse latest Browse all 116833

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>