How does one pull historical data from the WebThings API?

Hello everyone,

I’m interested in displaying data for a project of mine on a webpage akin to how the logs on the gateway interface works (but with my own styling of course). It’s relatively simple to pull current data after the website opens or using local storage, but if I were to pull the data from say, the last 24 hours via an API call, would this be possible? Or will i have to set up my own backend :frowning: ?

I’ve been combing through the documentation and repos, but I must be missing what I’m looking for. If any of you have some pointers or a snippet, I’d very much appreciate it and as always, I’ll be sure to post my solution with pictures should I find it.

The only historical data the gateway keeps is the properties you’ve set up to be logged via the UI. To fetch that data, you’d have to use your user JWT, rather than an OAuth token.

Is this the data you’re referring to, or were you hoping for something more general?

You could also use something like the influxdb, kafka, or azure-iot add-ons.

Thanks for getting back so fast. The logged info is exactly what I’m looking for. For example in the past I’ve pulled temperature data via websocket and HTTP from the API. On the Gateway UI, one can select properties to show up in “logs” with a variable on the timeframe that the data is sent from the selected Thing. I’d like to see my property data to that degree rather than since I opened my site locally.

I already authorize my requests with the bearer token but its sounding like you’re saying that what I’m using is from my oAuth and not the jwt? It would be a pleasant surprise if the only difference was the authorization haha. I DO however write my old websocket with the format of


If i were to pull the log for that item would i format it differently?

No, you’ll still use the user JWT with an Authorization: Bearer <jwt> header. You can get all logged data via the GET /logs endpoint. You may want to read through the source to get the other endpoints, since it was only meant to be an internal API: