Author Topic: API history requests return one fewer records than requested  (Read 5700 times)

rotus8

  • Sr. Member
  • ****
  • Posts: 315
  • Karma: +0/-0
API history requests return one fewer records than requested
« on: April 02, 2011, 06:35:10 PM »
Fetching history data using the TED 5000 API, the document says:
Quote
COUNT(Optional) - number of records to return. If count is not specified all
records from the specified index and older will be returned.

In reality it returns one less than specified unless a non-zero INDEX is specified. for example, the requests:
http://TED5000/history/secondhistory.xml?MTU=1&COUNT=10
and
http://TED5000/history/secondhistory.xml?MTU=1&COUNT=10&INDEX=0
only return 9 second records. However this command
http://TED5000/history/secondhistory.xml?MTU=1&COUNT=10&INDEX=1
returns 10 records.

This holds for secondhistory, minutehistory, and hourhistory. I didn't try dailyhistory because my TED has been reset and I don't have enough days to try it.

checkers1811

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-0
Re: API history requests return one fewer records than requested
« Reply #1 on: June 06, 2011, 06:02:33 AM »
please post your version numbers (TED Help panel). When I enter the same string as you I get an entire hour's worth of data. It doesn't stop at 10 records - more like 6000 records.

My gateway is 1.0.406. Footprints 1.0.223, MTU version 1.0.61

/history/secondhistory.xml?MTU=0&count=10&INDEX=1


Any idea why I can't control the data flow?

rotus8

  • Sr. Member
  • ****
  • Posts: 315
  • Karma: +0/-0
Re: API history requests return one fewer records than requested
« Reply #2 on: June 06, 2011, 05:57:08 PM »
My versions are the same as yours except my MTU version is 1.0.64.

checkers1811

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-0
Re: API history requests return one fewer records than requested
« Reply #3 on: June 06, 2011, 06:10:20 PM »
I seems a little odd that we have the same versions and are getting different results.

I copy/pasted the line from your first post into my TED and got a hours worth of seconds data.
"192.168.1.100/history/secondhistory.xml?MTU=0&count=10&INDEX=1"

I'll see if I can find an update for the MTU firmware. Since I have been using this TED for only 3 days, I have to wonder why I don't have a version as new as yours. Did you update your MTU firmware lately?

checkers1811

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-0
Re: API history requests return one fewer records than requested
« Reply #4 on: June 06, 2011, 06:41:38 PM »
Ok, I tried it again with this string from the PDF and it works just fine.

http://192.168.1.100/history/secondhistory.xml?MTU=0&COUNT=1&INDEX=1

Apparently, the words MTU, COUNT and INDEX must be all caps.

It returns this ...

<History>
<SECOND>
<MTU>0</MTU>
<DATE>06/06/2011 10:37:56</DATE>
<POWER>862</POWER>
<COST>9</COST>
<VOLTAGE>1174</VOLTAGE>
</SECOND>
</History>


SherlockOhms

  • Full Member
  • ***
  • Posts: 168
  • Karma: +0/-0
  • Sherlock
Re: API history requests return one fewer records than requested
« Reply #5 on: June 13, 2011, 07:04:19 PM »
FYI the MTU version number is irrelevant to you guys, the data format is the same. The newer firmware has only a few things related to manufacturing and nothing new in terms of functionality or data format.