FieldClimate



Fieldclimate JSON API V1

Contents

Introduction 2

About JSON 4

Authentication 5

API Methods 5

API Keys 5

PESSL JSON Library v.01 7

The "Hello, World" of Fieldclimate JSON API V1 8

Reading the List of Stations 9

Getting Configuration of Station 11

Getting Sensors Info 12

Getting Weather Data 13

API Reference 16

For developers 16

Introduction

This API allows anyone to write applications that interact with Fieldclimate JSON API. You can get started by checking out the API Methods .

The API consists of a set of callable methods and API endpoints. The arguments, responses, and error codes for each method are described.

[pic]

To perform an action using API, send a request (specifying a method and some parameters) to an API endpoint. A response will then be sent back to you.

All requests take a list of named parameters.

The REST format is a simple JSON-based protocol - it is a conventional HTTP GET or POST action.

The REST endpoint URL is

For example, to request the CIDIStationList_GetFirst service, you would invoke the following:

1. (Friendly URL)

2.

The required parameter action is used to specify the method to be called.

[pic]

All responses are returned in JSON format. By default, character encoding is UTF-8.

Successful Response

|{"ReturnDataSet":[ |

|{"f_station_code":"282", |

|"f_date":"2009-04-20 12:07:21", |

|"f_dev_id":"1", |

|"f_name":"00000146", |

|"f_descr":"imetos avr","f_info":"\r\nImetos 1 software: 02.55 hardware: 01.00 compiled: Apr 23 2009 12:23:00", |

|"f_uid":"2147483647", |

|"f_status":"0", |

|"f_create_time":"2007-01-22 08:59:42", |

|"f_master_name":null, |

|"f_date_min":"2005-03-08 12:50:00", |

|"f_date_max":"2010-10-11 02:20:00", |

|"f_date_last_down":"2010-10-11 01:22:40", |

|"f_date_sens":"2010-05-20 12:30:50.625755", |

|"f_date_data":"2010-01-24 19:02:12.19124", |

|"f_date_conf":"2010-10-11 03:22:40.462109", |

|"f_sernum":"326", |

|"f_timezone":"60", |

|"f_latitude":"47.2055", |

|"f_longitude":"15.63507", |

|"f_altitude":"443", |

|"f_date_comm":1286756560, |

|"f_user_station_name":"Pessl Instruments Company Weather '\u00b4\u00b4", |

|"f_user_name":"Pessl Instruments Company Weather '\u00b4\u00b4"}], |

|"ReturnParams":{"row_count":"1","station_code":1}} |

Failure Response

|{"faultcode":5, |

|"faultactor":"CIDIStationList", |

|"faultstring":"No rights", |

|"faultdetail":"CIDIData interface error"} |

About JSON

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate.

JSON is built on two structures:

* A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.

* An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.

These are universal data structures. Virtually all modern programming languages support them in one form or another. It makes sense that a data format that is interchangable with programming languages also be based on these structures.

For more information you can have a look at





Authentication

To use Fieldclimate API and authenticate users, it needs username, password or API KEY.

Logging with username and password.

| |

The required parameter user_name is username Fieldclimate.

The required parameter user_passw is password Fieldclimate.

Logging with with username and API KEY

|

|f12099d1c2d40ab994e8410c |

The required parameter user_name is username Fieldclimate.

The required parameter api_key is specially generated application api key for authorization client's apps .

API Methods

All methods , arguments are described

• CIDIUser

• CIDIStationList

• CIDIStationConfig

• CIDIStationSensors

• CIDIStationData

• CIDIFields

• CIDICrops

• CIDIDiarySprayList

• CIDIDiarySprayEvents

More soon coming….

API Keys

For getting API KEY mail the following details to support@metos.at

• fieldclimate account name

• domain name of the website, on which you want to show the sticker

After short verification you will receive necessary instructions and code for the sticker

PESSL JSON Library v.01

Pessl Instruments Gmbh has released set of classes javascript libraries. It wrappers all AJAX calls in a nice classes so that you don't need to deal with JSON and AJAX at all.

[pic]

You can download last version PESSL JSON Library v.01

You can download examples PESSL JSON Examples

Requirements: jQuery 1.3.2

The "Hello, World" of Fieldclimate JSON API V1

The easiest way to start learning about the Fieldclimate JSON API is to see a simple example.

| |

| |

| |

| |

| |

| The "Hello, World" of Fieldclimate JSON API |

|V1 |

| |

| |

| |

| |

|$j('document').ready(function() { |

|checkLogin(); |

|}); |

| |

|function checkLogin() { |

|var login = new PESSL.json.Basic(); |

|login.onFault = function(rep) { |

|if (rep.faultcode == 5) { |

|$j('#dialog-form').show(); |

|} else { |

|alert('Fault: ' + rep.faultcode + ' ' + rep.faultstring); |

|} |

|return true; |

|}; |

| |

|login.onComplete = function(obj) { |

|if (obj.faultcode == -1) { |

|$j('#dialog-form').hide(); |

|$j('#user-box').html('You have logged!'); |

|} |

|}; |

|login.Login(); |

|} |

| |

|function doLogin() { |

|var login = new PESSL.json.Basic(); |

| |

|login.username = $j("#name").val(); |

|login.password = $j("#password").val(); |

| |

|login.onFault = function(rep) { |

|if (rep.faultcode == 5) { |

|$j('#dialog-form').show(); |

|$j('#login_error_msg').html(rep.faultstring); |

|} else { |

|alert('Fault: ' + rep.faultcode + ' ' + rep.faultstring); |

|} |

|return true; |

|}; |

|login.onComplete = function(obj) { |

|if (obj.faultcode == -1) { |

|$j('#dialog-form').hide(); |

|} |

|}; |

|login.Login(); |

|} |

| |

|function Logout() { |

|var logout = new PESSL.json.Basic(); |

|logout.onFault = function(rep) { |

|alert('Fault: ' + rep.faultcode + ' ' + rep.faultstring); |

|return true; |

|}; |

|logout.onComplete = function() { |

|window.location.reload(); |

|}; |

|logout.Logout(); |

|} |

| |

| |

| |

| |

| The "Hello, World" of Fieldclimate JSON API V1 |

| |

| |

|All form fields are required. |

| |

| |

|Username |

| |

|Password |

| |

| |

| |

| |

| |

|Logout |

| |

| |

Please describe the input/output parameters and output recordset of this method

Live demo is available here The "Hello, World" of Fieldclimate JSON API V1

Reading the List of Stations

| |

| |

| |

| |

| |

|Example 1 - Reading the List of Stations |

| |

| |

| |

| |

| |

| |

|$j('document').ready(function() { |

|var stations = new PESSL.json.StationList(); |

|stations.username = 'austria'; |

|stations.password = 'guest'; |

|stations.api_key = ''; |

| |

|var s = 0; |

|stations.onError = function() { |

|alert('Error code:'+stations.error.code+' '+stations.error.text); |

|}; |

|// on Fault |

|stations.onFault = function(rep) { |

|if (rep.faultcode == 5) { |

|// handle fault |

|alert('You have no rights!'); |

|} else { |

|} |

| |

|return true; |

|}; |

| |

|// On complete |

|stations.onComplete = function() { |

| |

|var stations_div = $j('#stations_list'); |

|if (stations.faultcode > 0) { |

|return false; |

|} |

| |

|if (stations.dataset == null) { |

|return false; |

|} |

|var stations_list = ""; |

| |

|for ( var f in stations.dataset.rs) { |

|var station = stations.dataset.rs[f]; |

|var lat = parseFloat(station.f_latitude); |

|var long = parseFloat(station.f_longitude); |

|var title = station.f_user_name; |

| |

|stations_div.html(stations_div.html() + ' - '+ title + ''); |

| |

|s++; |

|} |

|; |

| |

|if (stations.dataset.rs != null) { |

|stations.GetNext(); |

|} |

|; |

|}; |

| |

|stations.GetFirst(); |

|}); |

| |

|Example 1 - Reading the List of Stations |

| |

| |

| |

Please describe the input/output parameters and output recordset of this method

Live demo is available here Example 1 - Reading the List of Stations

Getting Configuration of Station

| |

| |

| |

| |

| |

|Example 2 - Getting Configuration of Station |

| |

| |

| |

| |

| |

| |

|$j('document').ready(function() { |

| |

|var conf = new PESSL.json.StationConfig(); |

|conf.username = 'austria'; |

|conf.password = 'guest'; |

|conf.api_key = ''; |

|conf.station_name = '00000146'; |

| |

|conf.onError = function() { |

|alert('Error code:'+conf.error.code+' '+conf.error.text); |

|}; |

| |

|// on Fault |

|conf.onFault = function(rep) { |

|if (rep.faultcode == 5) { |

|// handle fault |

|alert('You have no rights!'); |

|} else { |

|} |

|return true; |

|}; |

| |

|// On complete |

|conf.onComplete = function() { |

| |

|var conf_div = $j('#station_conf'); |

| |

|for ( var f in conf.dataset.rs) { |

|var row = conf.dataset.rs[f]; |

|var title = row.f_name; |

| |

|for (var field in row) { |

|conf_div.html(conf_div.html() + field+'='+ row[field] + ''); |

|} |

|} |

|; |

|}; |

|conf.Get(); |

|}); |

| |

|Example 2 - Getting Configuration of Station |

| |

| |

| |

Please describe the input/output parameters and output recordset of this method

Live demo is available here Example 2 - Getting Configuration of Station

Getting Sensors Info

| |

| |

| |

| |

| |

|Example 3 - Getting Sensors Info |

| |

| |

| |

| |

| |

| |

|$j('document').ready(function() { |

| |

|var station_name = '00000146'; |

|var user_name = 'austria'; |

|var user_password = 'guest'; |

|var api_key = '' |

| |

|var sensors = new PESSL.json.StationSensors(); |

|sensors.station_name = station_name; |

|sensors.username = user_name; |

|sensors.password = user_password; |

|sensors.api_key = api_key; |

| |

|sensors.onError = function() { |

|alert('Error code:'+sensors..error.code+' '+sensors.error.text); |

|}; |

|// on Fault |

|sensors.onFault = function(rep) { |

|if (rep.faultcode == 5) { |

|// handle fault |

|alert('You have no rights!'); |

|} else { |

|} |

| |

|return true; |

|}; |

| |

|sensors.onComplete = function() { |

| |

|var sens_div = $j('#sensors_div'); |

|var sens = sensors.dataset.rs; |

|var sens_html = ''; |

| |

|for ( var f in sens) { |

|var sensor = sens[f]; |

|var name = sensor.f_sensor_user_name; |

|var unit = sensor.f_unit; |

| |

|sens_html+='-'+name+'('+unit+')'+''; |

|} |

| |

|sens_div.html(sens_html); |

|} |

|sensors.Get(); |

|}); |

| |

|Example 3 - Getting Sensors Info |

| |

| |

| |

Please describe the input/output parameters and output recordset of this method

Include all fields of sensor info into Example 3 - Getting Sensors Info

Live demo is available here Example 3 - Getting Sensors Info

Getting Weather Data

| |

| |

| |

| |

| |

|Example 4 - Getting Weather Data |

| |

| |

| |

| |

| |

| |

|$j('document').ready(function() { |

| |

|var station_name = '00000146'; |

|var user_name = 'austria'; |

|var user_password = 'guest'; |

|var api_key = '' |

| |

|var sensors = new PESSL.json.StationSensors(); |

|sensors.station_name = station_name; |

|sensors.username = user_name; |

|sensors.password = user_password; |

|sensors.api_key = api_key; |

|sensors.onComplete = function() { |

| |

|// Get sation data |

|var station_data = new PESSL.json.StationData(); |

|station_data.username = user_name; |

|station_data.password = user_password; |

|station_data.api_key = api_key; |

|station_data.station_name = station_name; |

|station_data.group_code = 0; |

| |

|station_data.onComplete = function() { |

|var data = station_data.dataset.rs; |

|var sens = sensors.dataset.rs; |

|var lastdata = HtmlDataHours (sens, data); |

| |

|$j('#data_div').html(lastdata); |

| |

|}; |

|station_data.GetLast(); |

|// End station data |

|} |

|sensors.Get(); |

|}); |

| |

| |

|function GetSensorValue(s, fields, info, data, aggr) { |

|var val = null; |

|var sens_field = "sens_" + aggr[fields[s]] + "_" + info.f_sensor_ch + "_" |

|+ info.f_sensor_code; |

|if (data[sens_field]) { |

|val = data[sens_field]; |

|} |

|; |

|return val; |

|}; |

| |

|function HtmlDataHours(sens, data) { |

|var html = ""; |

| |

|if (!data || data.length < 1) { |

|return html; |

|} |

|var aggr = { |

|f_val_min : "min", |

|f_val_max : "max", |

|f_val_aver : "aver", |

|f_val_sum : "sum", |

|f_val_time : "time", |

|f_val_last : "last" |

|}; |

| |

|html += ""; |

|html += "Date" + data[0].f_date + ""; |

|for ( var f in sens) { |

|var sensor = sens[f]; |

|var name = sensor.f_sensor_user_name; |

|var unit = sensor.f_unit; |

|var fields = []; |

| |

|if (sensor.f_val_max == 1) { |

|fields.push("f_val_min"); |

|} |

| |

|if (sensor.f_val_max == 1) { |

|fields.push("f_val_max"); |

|} |

| |

|if (sensor.f_val_aver == 1) { |

|fields.push("f_val_aver"); |

|} |

| |

|if (sensor.f_val_sum == 1) { |

|fields.push("f_val_sum"); |

|} |

| |

|if (sensor.f_val_time == 1) { |

|fields.push("f_val_time"); |

|} |

| |

|if (sensor.f_val_last == 1) { |

|fields.push("f_val_last"); |

|} |

| |

|if (sensor.f_val_user == 1) { |

|fields.push("f_val_user"); |

|} |

| |

|var vals = []; |

|var notnulls = []; |

|var valnull = false; |

| |

|for ( var i = 0; i < fields.length; i++) { |

|var val = GetSensorValue(i, fields, sensor, data[0], aggr); |

|vals[i] = ((val != null) ? val : ''); |

|if (val != null) { |

|notnulls[i] = val; |

|} |

| |

|if (i == fields.length - 1 && notnulls.length < 1) { |

|valnull = true; |

|} |

|} |

| |

|if (valnull) { |

|continue; |

|} |

| |

|html += ""; |

|html += "" + name + "[" + unit |

|+ "]" + ""; |

| |

|if (fields.length > 1) { |

|html += "" + aggr[fields[0]] + ""; |

|} |

| |

|html += "" |

|+ vals[0] + ""; |

|html += ""; |

| |

|for ( var i = 1; i < fields.length; i++) { |

|html += "" + aggr[fields[i]] + "" + vals[i] |

|+ ""; |

|} |

|; |

| |

|} |

|html += ""; |

|return html; |

|}; |

| |

| |

|Example 4 - Getting Weather Data |

| |

| |

| |

Provide examples for all methods – getfirst, genext, getprev and gelast

Create examples for reading disease models and weather forecast (like in soap manual)

Live demo is available here Example 4 - Getting Weather Data

API Reference

This reference contains inline documentation in JavaScript source files, and produces an documentation of the JavaScript code.



For developers

After learning the basics of data interface you can start developing your own applications. Here you will find a complete example with Google Map API integration



Please send error reports, suggestions, requests for support and examples of your applications to software@metos.at

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download

To fulfill the demand for quickly locating and searching documents.

It is intelligent file search solution for home and business.

Literature Lottery

Related searches