Project

General

Profile

Data Access REST API

Time specification

Allowed time specification formats:

Format Template Example
ISO date/time string implied US Central/Chicago time zone yyyy-mm-ddThh:mm:ss.ssss 2011-04-01T12:13:14.156 April 1 2011, 12:13:14.156
ISO date/time string with explicit timezone yyyy-mm-ddThh:mm:ss.ssss+hh:mm yyyy-mm-ddThh:mm:ss.ssss-hh:mm 2011-04-01T12:13:14.156-06:00 April 1 2011, 12:13:14.156 CST
ISO date/time string UTC yyyy-mm-ddThh:mm:ss.ssss+00:00 2011-04-01T12:13:14.156+00:00 April 1 2011, 12:13:14.156 UTC
Absolute timestamp (floating point, time in seconds since Jan 1, 1970 in UTC) sssssss.mmm 1317672067.273 Oct 3 2011, 20:01:07.273 UTC
Relative to now (seconds back from now) -nnn.fffs -3600.00s 1 hour ago
Relative to now (hours back from now) -nnn.fffh -24h 1 day ago
Relative to now (days back from now) -nnn.fffd -365d 1 year ago
now word "now" current time

Most methods support 1 or more of the following formats:

  • xml * csv * json * html

General URL format

All data access is performed by issuing HTTP GET request with URL like this:

http://ifb-data.fnal.gov:8089/ifbeam/data/data?<arguments>

Single variable mesurement

Arguments are:
  • v=<variable name>
  • e=<event name> - optional
  • t=<event time, or measurement time if "e" is missing> - default = current time
  • f=<format> - default = xml
  • m=<seconds> - margin. Default is 5 seconds. Data will be searched within the interval [t-m, t+m] and then the data closest to t will be returned.

Examples

Single variable over time interval

Arguments are:
  • v=<variable name>
  • e=<event name> - optional
  • t0=<time interval begin> - default = current time
  • t1=<time interval end> - default = current time
  • bin=<seconds> - data will be averaged over subintervals of "bin" seonds
  • m=<seconds> - margin. Default is 2 second. Returned data will also include data timestamped before and after the requested interval, effectively widening it by the margin seconds. Specifying a margin of m is equivalent to specifying [t0-m, t1+m] as time interval.

Examples

All variables from a bundle, event closest to given time

Arguments are:

  • b=<bundle name>
  • t=<event time> - default = current time
  • f=<format> - default = xml
  • m=<seconds> - margin. Default is 5 second. Data will be searched within the interval [t-m, t+m] and then the data closest to t will be returned.

Output is sorted by device name, alphabetically.

Example

All variables from a bundle, time interval

Arguments are:

  • b=<bundle name>
  • t0= interval begin
  • t1= interval end - default = current time
  • f=<format> - default = csv (currently only csv is supported)
  • m=<seconds> - margin. Default is 2 second. Returned data will also include data timestamped before and after the requested interval, effectively widening it by the margin seconds. Specifying a margin of m is equivalent to specifying [t0-m, t1+m] as time interval.

Output is sorted first by timestamp and then by device name, alphabetically.

Example

Sample Python client code

Here is a sample Python code which reads data from IFBeam DB:

import urllib2, sys
from datetime import datetime, tzinfo, timedelta

class UTC(tzinfo):

    ZERO = timedelta(0)

    def utcoffset(self, dt):
        return self.ZERO

    def tzname(self):
        return "UTC" 

    def dst(self, dt):
        return self.ZERO

utc = UTC()
t0 = datetime(2015, 5, 18, 10, 00, 00, tzinfo=utc).isoformat()
t1 = datetime(2015, 5, 18, 10, 10, 00, tzinfo=utc).isoformat()

url = "http://ifb-data.fnal.gov:8089/ifbeam/data/data?b=NuMI_Physics_A9&t0=%s&t1=%s" % (t0, t1)
print "URL:", url

f = urllib2.urlopen(url)
print "Status code: %s\n" % (f.getcode(),)

d = f.read(10000)
while d:
    sys.stdout.write(d)
    d = f.read(10000)