Welcome to Pessl Instruments GmbH RESTful API. It allows you to manage your account
,devices and its data.
Our API is following all the standards of the RESTful services therefore implementation should be
straight forward in any language you are using.
Before you start please check if you are using latest version of the API.
To do so go to https://api.fieldclimate.com/versions.json and find out which version is latest. We recommend using
latest version and also migrating to when ready.
On your left side you will find your main navigation bar. The navigation bar will show
you topic pages and RESTful request that you are able to make. Middle pane reflects
the content and specifications depending on your selected topic. Right pane
will provide you code examples, input and output schemas if any.
Before you send request for API access, please check which authentication methods we are supporting and decide which
one meets your needs. More details and examples in Authentication section of the documentation.
HMAC is primarily used for fetching data or single account integration. It is the easiest way of integration Pessl Instruments GmbH RESTful API
into your environment. HMAC public and private keys are permanently binned to user account.
Request API access per email to api@metos.at
For getting support we kindly ask you to send email to api@metos.at
What support email should contain:
{
"version" : "1.0"
"status" : "Stable"
"release_date" : "06.11.2017",
"other_versions" : "https://api.fieldclimate.com/versions.json"
"support_email" : "api@metos.at"
"changelog" : {
"oAuth 2.0" : "When registering new user E-mail does not need to be unique",
"View" : "Soil and precipitation monitoring charting improved",
"Disease Model" : "Evapotranspiration display improved",
"Disease Model" : "Addet new models",
"Numbers" : "Improved decimal places placements",
"Docs" : "C# example updated",
"Docs" : "Updated",
"API" : "Sensor, calculations ... translations",
"API" : "Error codes and messages more clear (not final)",
"API" : "Other small fixes"
}
}
Each weather station is supplied with unique ID that is always 8 characters long (we call it Station ID or serial number, example: 00000146).
There are many types of stations that we support. Most of them can use all of the station specific functionalities offered by the API, but
some are limited (Example CropView stations are only able to use CropView functionalities).
Station types:
Most common workflows explained to help you understand the possibilities and best practices to integrate our API into your environment.
User can have multiple devices assigned to his account. Therefore first call we make is to get list of the user stations that he has.
Second thing that we need to know is min and max date of the data available to us. For that reason we make a call for station information
which gives us necessary dates. When we have dates all we need to do is request the data for required time period.
Above approach can be used to fetch data into your own database by tracking dates in your database and our and just fetch missing parts.
You wish to display latest temperature, wind speed ... all you need todo is to call last 1 to get latest entry of a station and
display it.
RESTful requests should be made following latest RESTful standards.
RESTful responses are being made by following latest RESTful standards.
If you are experiencing HTTP code 500 please contact support with all details of the request.
At the moment we only support JSON format of response.
JSON Schema is a vocabulary that allows you to annotate and validate JSON documents.
Advantages
JSON Schema specifications can be found HERE
Depending of version you are using all our schemas can be found at https://api.fieldclimate.com/v1/schemas/
NOTE: Mostly requests that require POST, PUT methods are using JSON schema. When you are browsing trough routes you will notice that in the right pane there is a tab Schema and Body, this two tabs contain JSON schema and example.
{
"title": "Station Name Update Schema",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"mac": {
"type": "string",
"description": "MAC address or Station ID as X (X indicates default station)"
}
},
"required": [
"name",
"mac"
],
"additionalProperties": false,
"description": "additionalProperties means that no new property can be created ... Data updated as whole object will overwrite whole set in database. Required property needs to be specified. Pattern is pattern in regex"
}
{
"title": "User ",
"type": "object",
"properties": {
"custom_name": {
"type": "string",
"pattern": "^[a-zA-Z\\s\\d]{0,35}$",
"description": "Only characters, numbers, spaces and max length 35"
}
},
"additionalProperties": false,
"description": "additionalProperties means that no new property can be created .... Data updated as whole object will overwrite whole set in database. Required property needs to be specified. Pattern is pattern in regex"
}
We grouped our routes into meaningful groups that may help you travers the API.
List of groups is sorted by most common to less and by recommended usage.
Our API supports two methods for authentication, authorization and data encryption. The first one, HMAC (Keyed-hash message authentication code), is widely used and easy to implement.
HMAC uses a cryptographic secure hash algorithm (SHA-256 in our case) to encode messages based on concatenation with a secret key. You need to request a public and private key pair from us before you can use this method.
The second method, OAuth 2.0, is an open standard for authorizing 3rd-party client applications to access server resources on behalf of a user without exchanging user credentials with clients.
OAuth requires registration of the client application with name and redirect URI (protected with TLS security). After successful registration the authorization service provides a client ID and a client secret.
Contact api@metos.at and provide the specified information depending on your selected authentication method:
The following techniques are used to protect your data and ensure secure communication with our services:
HMAC, or Hash Message Authentication Code, provides an easy mechanism for verifying both user authenticity and that a message hasn't
been tampered. This protocol uses a public and a private key which will be provided upon email request. HMAC is also widely
supported by different kinds of programming languages.
Easiest way to interact with our API. Supported by most programming languages.
NOTE: DEV routes are not available if using HMAC
We provide you with public and private key. Public key is known to everyone however private key is only known
to the user and the API service provider. Private key is being used to generate encoded signature which is afterwards
included in authorization header.
Mandatory HTTP header fields Header field name |
value |
---|---|
Authorization | hmac {PUBLIC-KEY}:{SIGNATURE} |
Date | Wed, 09 Aug 2017 20:32:38 GMT |
Signature
The HTTP header authorization signature is generated using the cryptographic SHA-256 algorithm based on
HTTP method, API route, current timestamp in RFC2616 format, and public key concatenated with the private key.
Find some examples in the section on the right.
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/data/{STATION-ID}/raw/last/5";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
package com.company;
import org.apache.commons.codec.binary.Hex;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.client.utils.DateUtils;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.protocol.HttpContext;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.ssl.SSLContexts;
import org.apache.http.util.EntityUtils;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.security.GeneralSecurityException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Date;
public class HMacExample {
public static void main(String[] args) throws IOException, GeneralSecurityException {
String publicKey = "YOUR PUBLIC HMAC KEY";
String privateKey = "YOUR PRIVATE HMAC KEY";
SSLContextBuilder builder = new SSLContextBuilder();
builder.loadTrustMaterial(null, new TrustStrategy() {
@Override
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
return true;
}
});
SSLConnectionSocketFactory sslSF = new SSLConnectionSocketFactory(builder.build(),
SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
HttpClient client = HttpClients.custom().setSSLSocketFactory(sslSF).build();
String method = "GET";
String path = "/data/SPECIFY YOUR STATION ID/raw/last/5";
// Creating date in appropriate format (RFC 1123) that is accepted by http header; apache http client library is used
String date = DateUtils.formatDate(new Date(System.currentTimeMillis()));
String contentToSign = method + path + date + publicKey;
String signature = generateHmacSHA256Signature(contentToSign, privateKey);
String authorizationString = "hmac " + publicKey + ":" + signature;
// Creating request by using RequestBuilder from apache http client library; headers are set in this step as well
HttpUriRequest request = RequestBuilder.get().setUri("https://api.fieldclimate.com/THIS-VERSION" + path)
.setHeader(HttpHeaders.ACCEPT, "application/json")
.setHeader(HttpHeaders.AUTHORIZATION, authorizationString)
.setHeader(HttpHeaders.DATE, date).build();
HttpResponse response = client.execute(request);
HttpEntity entity = response.getEntity();
System.out.println(response.getStatusLine());
//EntityUtils.consume(entity);
String responseString = EntityUtils.toString(entity, "UTF-8");
System.out.println(responseString);
}
// Static method that generates HmacSHA256 signiture as a hexademical string
public static String generateHmacSHA256Signature(String data, String key) throws GeneralSecurityException {
byte[] hmacData = null;
try
{
SecretKeySpec secretKey = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA256");
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(secretKey);
return Hex.encodeHexString(mac.doFinal(data.getBytes("UTF-8")));
} catch (UnsupportedEncodingException e) {
throw new GeneralSecurityException(e);
}
}
}
import requests
from requests.auth import AuthBase
from Crypto.Hash import HMAC
from Crypto.Hash import SHA256
from datetime import datetime,
from dateutil.tz import tzlocal
# Class to perform HMAC encoding
class AuthHmacMetosGet(AuthBase):
# Creates HMAC authorization header for Metos REST service GET request.
def __init__(self, apiRoute, publicKey, privateKey):
self._publicKey = publicKey
self._privateKey = privateKey
self._method = 'GET'
self._apiRoute = apiRoute
def __call__(self, request):
dateStamp = datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT')
print("timestamp: ", dateStamp)
request.headers['Date'] = dateStamp
msg = (self._method + self._apiRoute + dateStamp + self._publicKey).encode(encoding='utf-8')
h = HMAC.new(self._privateKey.encode(encoding='utf-8'), msg, SHA256)
signature = h.hexdigest()
request.headers['Authorization'] = 'hmac ' + self._publicKey + ':' + signature
return request
# Endpoint of the API, version for example: v1
apiURI = 'https://api.fieldclimate.com/ENTER-VERSION'
# HMAC Authentication credentials
publicKey = 'PROVIDED BY SERVICE PROVIDER'
privateKey = 'PROVIDED BY SERVICE PROVIDER'
# Service/Route that you wish to call
apiRoute = '/user'
auth = AuthHmacMetosGet(apiRoute, publicKey, privateKey)
response = requests.get(apiURI+apiRoute, headers={'Accept': 'application/json'}, auth=auth)
print(response.json())
Tested and working with following:
- Python 2.7
- Python 3.5
python-dateutil==2.7.2
pycrypto==2.6.1
requests==2.18.4
require 'net/http'
require 'digest/hmac'
require 'time'
# User public and private key
public_key = 'PROVIDED BY SERVICE PROVIDER';
private_key = 'PROVIDED BY SERVICE PROVIDER';
# Define the request parameters
method = 'GET';
call = '/data/{STATION-ID}/raw/last/5';
now = Time.now.httpdate # Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
# Concatenate the request into single string
content_to_sign = method + call + now + public_key
# Calc
ulate signature
signature = Digest::HMAC.hexdigest(content_to_sign, private_key, Digest::SHA256)
# Prepare and make http request
url = URI.parse('https://api.fieldclimate.com/THIS-VERSION' + call)
request = Net::HTTP::Get.new(url.to_s)
# Add required headers
request['Accept'] = 'application/json'
# Authorization: hmac public_key:signature
# Date: Wed, 25 Nov 2014 12:45:26 GMT
request['Authorization'] = 'hmac ' + public_key + ':' + signature
request['Date'] = now
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
response = http.request(request)
# Parse response as json and work on it
# ...
# ...
# output response
puts response.body
using System;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Cryptography;
using System.Globalization;
namespace DocsExample
{
class Program
{
static void Main(string[] args)
{
RunAsync().Wait();
}
static async Task RunAsync()
{
var apiBaseAddress = new Uri("https://api.fieldclimate.com/THIS-VERSION");
CustomDelegatingHandler customDelegatingHandler = new CustomDelegatingHandler(new HttpClientHandler());
HttpClient client = new HttpClient(customDelegatingHandler);
client.BaseAddress = apiBaseAddress;
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = await client.GetAsync("/user/stations");
if (response.IsSuccessStatusCode)
{
string responseString = await response.Content.ReadAsStringAsync();
// Process JSON here
Console.WriteLine("Status {0}:{1}", response.StatusCode, responseString);
}
else
{
// Handle response codes not equal to 200 here
Console.WriteLine("Status {0}:{1}", response.StatusCode, await response.Content.ReadAsStringAsync());
}
}
}
public class CustomDelegatingHandler : DelegatingHandler
{
private const string publicKey = "PROVIDED BY SERVICE PROVIDER";
private const string privateKey = "PROVIDED BY SERVICE PROVIDER";
static readonly CultureInfo enUsCulture = new CultureInfo("en-us");
public CustomDelegatingHandler(HttpClientHandler handler)
{
base.InnerHandler = handler;
}
protected async override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
HttpResponseMessage response = null;
string requestHttpMethod = request.Method.Method;
string requestPath = request.RequestUri.AbsolutePath;
DateTimeOffset date = DateTimeOffset.UtcNow;
request.Headers.Date = date;
string requestTimeStamp = date.ToString("ddd, dd MMM yyyy HH:mm:ss 'GMT'", enUsCulture);
string signatureRawData = String.Format("{0}{1}{2}{3}", requestHttpMethod, requestPath, requestTimeStamp, publicKey);
byte[] privateKeyByteArray = Encoding.UTF8.GetBytes(privateKey);
byte[] signature = Encoding.UTF8.GetBytes(signatureRawData);
using (HMACSHA256 hmac = new HMACSHA256(privateKeyByteArray))
{
byte[] signatureBytes = hmac.ComputeHash(signature);
string requestSignatureString = ByteArrayToString(signatureBytes);
request.Headers.Authorization = new AuthenticationHeaderValue("hmac", string.Format("{0}:{1}", publicKey, requestSignatureString));
}
response = await base.SendAsync(request, cancellationToken);
return response;
}
private string ByteArrayToString(byte[] ba)
{
StringBuilder hex = new StringBuilder(ba.Length * 2);
foreach (byte b in ba)
hex.AppendFormat("{0:x2}", b);
return hex.ToString();
}
}
}
OAuth 2.0 is the industry-standard protocol for authorization. OAuth 2.0 supersedes the work done on the original OAuth protocol created in 2006. OAuth 2.0 focuses on client developer simplicity while providing specific authorization flows for web applications, desktop applications, mobile phones, and living room devices.
In the right pane you can find an example for using OAuth 2.0.
NOTE: Below you can find our OAuth 2.0 server specifications
Clients can register their own client application(s) on our OAuth 2.0 server to access authorized Pessl Instruments GmbH user base. This means that you can register users to your own application and manage them autonomously without necessity to exchange user credentials or directly access Pessl Instruments GmbH accounts.
WORKFLOW: Master Account can have multiple Applications and each application can have multiple users.
All the users go into common Pessl Instruments GmbH user base and are able to access applications that are using this user base. We also offer an option that users registered by your application can access only this application or specified applications.
Please check routes DEV for available options. This routes are only available if you have OAuth 2.0 application and necessary rights.
Service | URL |
---|---|
OAuth 2.0 Server | https://oauth.fieldclimate.com |
OAuth 2.0 Authorize | https://oauth.fieldclimate.com/authorize |
OAuth 2.0 Token | https://oauth.fieldclimate.com/token |
Supported grants | Authentication grant, Client credentials, Refresh token |
session_start();
//sample working client
$clientId = "PROVIDED BY SERVICE PROVIDER";
$clientSecret = "PROVIDED BY SERVICE PROVIDER";
// if token is already in session one can make api calls, by passing the access token value in the header
if (isset($_SESSION['access_token'])){
echo "Access token is already in the session. Trying to make a sample API call (https://api.fieldclimate.com/station/00000146)... ";
$accessToken = $_SESSION['access_token'];
$sampleApiCall = "https://api.fieldclimate.com/THIS-VERSION/station/00000146";
$curl = curl_init( $sampleApiCall );
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt( $curl, CURLOPT_HTTPHEADER, array( 'Accept: application/json', 'Authorization: Bearer ' .$accessToken) );
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$redirect = curl_exec( $curl );
$http_status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
//optional step for automatic refreshing of tokens, since access token is expired in 1 hour (3600 seconds)
//first we check if token is expired the refresh token is sent and exchanged for new access token
if ($http_status_code == "401"){
if (isset($_SESSION['refresh_token'])){
$refreshToken = $_SESSION['refresh_token'];
$postFields = array('grant_type' => 'refresh_token', 'refresh_token' => $refreshToken);
$accessTokenUrl = "https://oauth.fieldclimate.com/token";
$r = curl_init($accessTokenUrl);
curl_setopt($r, CURLOPT_USERPWD, "{$clientId}:{$clientSecret}");
curl_setopt($r, CURLOPT_RETURNTRANSFER, true);
curl_setopt($r, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($r, CURLOPT_POST, true);
curl_setopt($r, CURLOPT_POSTFIELDS, $postFields);
// Download the given URL, and return output
$output = curl_exec($r);
// Close the cURL resource, and free system resources
curl_close($r);
}else {
print_r('something is wrong');
die;
}
}
} else {
//there is no access token in the session, user is redirected to the form
//checking if there is an authorization code in the URL then client can exchange this authorization code for the token
if ($_GET['code']){
$accessTokenUrl = "https://oauth.fieldclimate.com/token";
$authCode = $_GET['code'];
$postFields = array('grant_type' => 'authorization_code', 'code' => $authCode);
$r = curl_init($accessTokenUrl);
curl_setopt($r, CURLOPT_USERPWD, "{$clientId}:{$clientSecret}");
curl_setopt($r, CURLOPT_RETURNTRANSFER, true);
curl_setopt($r, CURLOPT_POST, true);
curl_setopt($r, CURLOPT_POSTFIELDS, $postFields);
// Download the given URL, and return output
$output = curl_exec($r);
// Close the cURL resource, and free system resources
curl_close($r);
$json = json_decode($output);
$_SESSION['access_token'] = $json->access_token;
$_SESSION['refresh_token'] = $json->refresh_token;
echo "Refresh token: ". $json->refresh_token ." Access token was not set in the session, but now it is. Just reload the page and you should see the results from the sample api call.";
} else {
//there is not token or authorization code, so user should ask for authorization code first. For this client needs to pass these three
//parameters to fieldclimate authorization server
header("Location: https://oauth.fieldclimate.com/authorize?response_type=code&client_id=".$clientId. "&state=xyz");
}
}
User routes enables you to manage information regarding user you used to authenticate with.
Schema | Function |
---|---|
schemas/UserUpdate.json | Updating user information |
HTTP Method | Endpoint | URL Params | Function |
---|---|---|---|
GET | /user | None | Read user information |
PUT | /user | None | Update user information |
DELETE | /user | None | Delete user account |
GET | /user/stations | None | Read list of stations of a user |
GET | /user/licenses | None | Read user licenses |
N/A
Reading user information.
Specification | Value |
---|---|
method | GET |
request | /user |
N/A
N/A
HTTP CODE | Description |
---|---|
200 | Success |
401 | Unauthorized |
Values that are not listed in table below are self explanatory.
Value | Description |
---|---|
created_by | By which application user was created |
unit_system | Metric or Imperial |
{
"username": "",
"info": {
"name": "",
"lastname": "",
"title": "",
"email": "",
"phone": "",
"cellphone": "",
"fax": ""
},
"company": {
"name": "",
"profession": "",
"department": ""
},
"address": {
"street": "",
"city": "",
"district": "",
"zip": "",
"country": ""
},
"settings": {
"language": "en",
"newsletter": false,
"unit_system": "metric"
},
"created_by": "",
"create_time": "",
"last_access": ""
}
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/user";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Updating user information.
Specification | Value |
---|---|
method | PUT |
request | /user |
N/A
Schema | Function |
---|---|
schemas/UserUpdate.json | Updating user information |
HTTP CODE | Description |
---|---|
200 | Success |
204 | No changes have been made |
400 | Validation errors |
401 | Unauthorized |
409 | Username already exists |
Values are self explanatory.
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "PUT";
$request = "/user";
// Body that you send needs to be JSON schema validated
$body = [
"username" => "dummyUsername",
"info.name" => "Dummy Name"
];
$body = json_encode( $body );
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_POST, TRUE );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $body );
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
{
"title": "User Update",
"description" : "Update user information",
"type": "object",
"properties": {
"username": {
"type": "string",
"pattern": "(*UTF8)^[[:alnum:]]+(?:[-_ ]?[[:alnum:]]+)*$",
"description": "Chars, Numbers, space, _, - but no other special chars"
},
"password": {
"type": "string",
"description": "Password"
},
"info.name": {
"type": "string"
},
"info.lastname": {
"type": "string"
},
"info.title": {
"type": "string"
},
"info.email": {
"type": "string"
},
"info.phone": {
"type": "string"
},
"info.cellphone": {
"type": "string"
},
"info.fax": {
"type": "string"
},
"company": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"profession": {
"type": "string"
},
"department": {
"type": "string"
},
"customer_id": {
"type": "integer"
},
"vat_id": {
"type": "string"
}
},
"required": [
"name"
],
"additionalProperties": false,
"description": "Data updated as whole object will overwrite whole set in database"
},
"address.street": {
"type": "string"
},
"address.city": {
"type": "string"
},
"address.district": {
"type": "string"
},
"address.zip": {
"type": "string"
},
"address.country": {
"type": "string"
},
"settings.language": {
"type": "string",
"pattern": "^[a-z]{2,2}$",
"description": "Language has to be in ISO 639-1 format"
},
"settings.newsletter": {
"type": "boolean",
"description": "Wanna receive newsletter"
},
"settings.unit_system": {
"type": "string",
"enum": ["metric", "imperial"],
"description": "Must be one of metric, imperial"
}
},
"additionalProperties": false
}
{
"username" :"",
"password" : "",
"info.name" : "",
"info.lastname": "",
"info.title": "",
"info.email": "",
"info.phone": "",
"info.cellphone": "",
"info.fax": "",
"company": {
"name": "",
"profession": "",
"department": "",
"customer_id": "",
"vat_id": ""
},
"address.street": "",
"address.city": "",
"address.district": "",
"address.zip": "",
"address.country": "",
"settings.unit_system" : ""
"settings.language": "",
"settings.newsletter": "",
"settings.unit_system": "",
}
User himself can remove his own account.
Specification | Value |
---|---|
method | DELETE |
request | /user |
N/A
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | Already removed |
401 | Unauthorized - Login required |
403 | No permissions - No rights |
Values are self explanatory.
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "DELETE";
$request = "/user";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Reading list of user devices. Returned value may not be used by your application.
Specification | Value |
---|---|
method | GET |
request | /user/stations |
N/A
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No devices |
401 | Unauthorized |
Values that are not listed in table below are self explanatory.
Most commonly used: name, info, dates, position, licenses
Value | Description |
---|---|
name.original | Station ID and can not be changed |
warnings.sensors | Warning per sensor code and channel |
licenses.model | Disease model licenses |
licenses.forecast | Weather forecast license |
[
{
"name": {
"original": "",
"custom": ""
},
"rights": "rw",
"info": {
"device_id": 7,
"device_name": "iMetos 3.3",
"uid": "2401010657289D25",
"firmware": "08.200.20170529",
"hardware": "29-0503",
"description": "iMetos 3.3, hw: 29-0503, fw: 08.200.20170529",
"max_time": null
},
"dates": {
"min_date": "2005-03-08 12:50:00",
"max_date": "2017-07-05 12:30:09",
"created_at": "2007-01-22 08:59:42",
"last_communication": "2017-07-05 11:22:57"
},
"position": {
"geo": {
"coordinates": [
15.444533,
47.0648576
]
},
"altitude": 359
},
"config": {
"timezone_offset": 60,
"dst": false,
"precision_reduction": 0.2,
"scheduler": 1398096,
"schedulerOld": "505515000000000000000000000000000000000000000000",
"fixed_transfer_interval": 0,
"rain_monitor": 0,
"water_level_monitor": 0,
"data_interval": 0,
"activity_mode": 0,
"emergency_sms_number": "+123124123123123",
"measuring_interval": 10,
"logging_interval": 15,
"x_min_transfer_interval": false
},
"metadata": {
"last_battery": "6009"
},
"networking": {
"mnc": "",
"mcc": "",
"apn": "",
"username": "",
"password": "",
"country": "",
"provider": "",
"type": "GPRS",
"imei": "",
"simid": ""
},
"warnings": {
"sensors": [
"0,16,0,0",
"0,16,0,-15",
],
"sms_numbers": [
{
"num": "",
"name": "",
"active": true
},
{
"num": "",
"name": "",
"active": true
}
]
},
"flags": {
"imeteopro": true
},
"licenses": {
"models": [
],
"Forecast": true
}
},...
]
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/user/stations";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Reading all licenses that user has for each of his device.
Specification | Value |
---|---|
method | GET |
request | /user/licenses |
N/A
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No licenses |
401 | Unauthorized |
Values are self explanatory.
{
"models": {
"CROP": {
"STATION-ID": [
{
"from": "DATE-TIME",
"to": "DATE-TIME"
}
],
"STATION-ID": [
{
"from": "DATE-TIME",
"to": "DATE-TIME"
}
],...
},
"CROP": {
"STATION-ID": [
{
"from": "DATE-TIME",
"to": "DATE-TIME"
}
],
"STATION-ID": [
{
"from": "DATE-TIME",
"to": "DATE-TIME"
}
],...
},...
},
"Forecast": {
"STATION-ID": [
{
"from": "DATE-TIME",
"to": "DATE-TIME"
}
],
"STATION-ID": [
{
"from": "DATE-TIME",
"to": "DATE-TIME"
}
],...
}
}
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/user/licenses";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
System routes gives you all information you require to understand the system and what is supported.
N/A
HTTP Method | Endpoint | URL Params | Function |
---|---|---|---|
GET | /system/status | None | System running correctly |
GET | /system/sensors | None | Supported sensors |
GET | /system/groups | None | Supported sensor groups |
GET | /system/group/sensors | None | Sensors organized in groups |
GET | /system/types | None | Type of devices |
GET | /system/countries | None | Countries for the languages |
GET | /system/timezones | None | Timezones |
GET | /system/diseases | None | Disease models |
N/A
Checking system status.
Specification | Value |
---|---|
method | GET |
request | /system/status |
N/A
N/A
HTTP CODE | Description |
---|---|
200 | Success |
401 | Unauthorized |
Values are self explanatory.
{
BOOLEAN
}
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/system/status";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Reading the list of all system sensors. Each sensor has unique sensor code and belongs to group with common specifications.
Specification | Value |
---|---|
method | GET |
request | /system/sensors |
N/A
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No sensors found |
401 | Unauthorized |
Values that are not listed in table below are self explanatory.
Value | Description |
---|---|
unit | Default unit |
units | Supported units |
group | Check understanding your device section |
code | Check understanding your device section |
aggr | Check understanding your device section |
vals | Range of sensor reading |
{
"0": {
"name": "Air temperature",
"unit": "°C",
"units": [
"°C",
"°F"
],
"code": 0,
"group": 1,
"decimals": 1,
"divider": 10,
"vals": {
"min": -400,
"max": 900
},
"aggr": {
"avg": 1,
"max": 1,
"min": 1
}
},
"1": {
"name": "Relative humidity",
"unit": "%",
"units": [
"%"
],
"code": 1,
"group": 2,
"decimals": 0,
"divider": 1,
"vals": {
"min": 0,
"max": 100
},
"aggr": {
"avg": 1
}
},
"2": {
"name": "Solar radiation",
"unit": "W/m2",
"units": [
"W/m2",
"J/m2",
"kJ/m2",
"MJ/m2"
],
"code": 2,
"group": 4,
"decimals": 0,
"divider": 1,
"vals": {
"min": 0,
"max": 32767
},
"aggr": {
"avg": 1
}
},...
}
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/system/sensors";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Reading the list of all system groups. Each sensor belongs to a group which indicates commons specifications.
Specification | Value |
---|---|
method | GET |
request | /system/groups |
N/A
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No groups found |
401 | Unauthorized |
Values that are not listed in table below are self explanatory.
Value | Description |
---|---|
name | Name of the group |
group | Group code |
{
"1": {
"name": "Air temperature",
"group": 1
},
"2": {
"name": "Relative humidity",
"group": 2
},
"3": {
"name": "Soil temperature",
"group": 3
},
"4": {
"name": "Solar radiation",
"group": 4
},
"5": {
"name": "Precipitation",
"group": 5
},...
}
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/system/groups";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Reading the list of all system groups and sensors belonging to them. Each sensor belongs to a group which indicates commons specifications.
Specification | Value |
---|---|
method | GET |
request | /system/group/sensors |
N/A
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No groups found |
401 | Unauthorized |
All values explained in routes: system/sensors and system/groups
{
"1": {
"name": "Air temperature",
"group": 1,
"sensors": {
"0": {
"name": "Air temperature",
"unit": "°C",
"units": [
"°C",
"°F"
],
"code": 0,
"group": 1,
"decimals": 1,
"divider": 10,
"vals": {
"min": -400,
"max": 900
},
"aggr": {
"avg": 1,
"max": 1,
"min": 1
}
},
"51": {
"name": "Si7021 Temperature",
"unit": "°C",
"units": [
"°C",
"°F"
],
"code": 51,
"group": 1,
"decimals": 2,
"divider": 100,
"vals": {
"min": -4000,
"max": 12500
},
"aggr": {
"avg": 1,
"max": 1,
"min": 1
}
},...
},
"2": {
"name": "Relative humidity",
"group": 2,
"sensors": {
"1": {
"name": "Relative humidity",
"unit": "%",
"units": [
"%"
],
"code": 1,
"group": 2,
"decimals": 0,
"divider": 1,
"vals": {
"min": 0,
"max": 100
},
"aggr": {
"avg": 1
}
},
"46": {
"name": "Water meter 100L",
"unit": false,
"units": [
"%"
],
"code": 46,
"group": 2,
"decimals": 0,
"divider": 1,
"vals": {
"min": 0,
"max": 4294967295
},
"aggr": {
"sum": 1
}
},...
},...
}
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/system/group/sensors";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Reading the list of all devices system supports.
Specification | Value |
---|---|
method | GET |
request | /system/types |
N/A
N/A
HTTP CODE | Description |
---|---|
200 | Success |
401 | Unauthorized |
Values that are not listed in table below are self explanatory.
Value | Description |
---|---|
index | ID of a device |
value | Name of the device |
{
"0": "iMetos 1",
"1": "iMetos 1",
"2": "iMetos 2",
"3": "iMetos SD",
"4": "iMetos AOS",
"5": "iMetos 3",
"6": "iMetos D2",
"7": "iMetos 3.3",
"8": "iMetos Eco D3",
"28": "iMetos ICA",
"50": "uMetos",
"70": "CropView"
}
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/system/types";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Reading the list of all countries that system supports.
Specification | Value |
---|---|
method | GET |
request | /system/countries |
N/A
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No countries found |
401 | Unauthorized |
Values are self explanatory.
[
{
"name": {
"english": "Afghanistan",
"native": ""
},
"phoneCode": "93",
"iso": {
"639-1": "AF",
"639-2": "AFG"
}
},
{
"name": {
"english": "Aland Islands",
"native": ""
},
"phoneCode": "+358-18",
"iso": {
"639-1": "AX",
"639-2": "ALA"
}
},
{
"name": {
"english": "Albania",
"native": ""
},
"phoneCode": "355",
"iso": {
"639-1": "AL",
"639-2": "ALB"
}
},
{
"name": {
"english": "Algeria",
"native": ""
},
"phoneCode": "213",
"iso": {
"639-1": "DZ",
"639-2": "DZA"
}
},...
]
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/system/countries";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Reading the list of timezones system supports.
Specification | Value |
---|---|
method | GET |
request | /system/timezones |
N/A
N/A
HTTP CODE | Description |
---|---|
200 | Success |
401 | Unauthorized |
Values are self explanatory.
{
"Pacific/Midway": {
"Name": "Pacific, Midway",
"GMT": "GMT-11:00",
"Minutes": -660
},
"Pacific/Niue": {
"Name": "Pacific, Niue",
"GMT": "GMT-11:00",
"Minutes": -660
},
"Pacific/Pago_Pago": {
"Name": "Pacific, Pago Pago",
"GMT": "GMT-11:00",
"Minutes": -660
},
"Pacific/Honolulu": {
"Name": "Pacific, Honolulu",
"GMT": "GMT-10:00",
"Minutes": -600
},
"Pacific/Johnston": {
"Name": "Pacific, Johnston",
"GMT": "GMT-10:00",
"Minutes": -600
},
"Pacific/Rarotonga": {
"Name": "Pacific, Rarotonga",
"GMT": "GMT-10:00",
"Minutes": -600
},...
}
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/system/timezones";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Reading the list of all disease models system currently supports.
Note that KEY returned with model itself is being used to fetch disease model data in requests data, disease, chart and ag-grid.
Specification | Value |
---|---|
method | GET |
request | /system/diseases |
N/A
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No disease models |
401 | Unauthorized |
Values are self explanatory.
[
{
"group": "Apple",
"models": [
{
"key": "GeneralAphidRisk",
"name": "Aphid Risk",
"version": "2.0",
"settings": {
"period": "2d",
"resolution": "hourly"
}
},
{
"key": "GeneralRainModel4mm",
"name": "Rain pesticide wash off",
"version": "1.0",
"settings": {
"period": "14d",
"resolution": "hourly"
}
},
{
"key": "GeneralFireblight",
"name": "Fireblight",
"version": "1.0",
"settings": {
"period": "1m",
"resolution": "daily"
}
},...
],
"title": "Apple",
"active": true
},
{
"group": "ApricotPlum",
"models": [
{
"key": "GeneralAphidRisk",
"name": "Aphid risk",
"version": "2.0",
"settings": {
"period": "2d",
"resolution": "hourly"
}
},
{
"key": "GeneralRainModel4mm",
"name": "Rain pesticide wash off",
"version": "1.0",
"settings": {
"period": "14d",
"resolution": "daily"
}
},
{
"key": "GeneralJBlossomInfection",
"name": "Xanthomonas arboricola infection",
"version": "1.0",
"settings": {
"period": "2d",
"resolution": "hourly"
}
},...
],
"title": "Apricot, Plum, Prune and Mirabelle",
"active": true
},...
]
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/system/diseases";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
All the information that is related to your device.
Schema | Function |
---|---|
schemas/NodeUpdate.json | Updating station name or node |
schemas/StationUpdate.json | Updating station settings |
schemas/UserStationInsert.json | Adding station to account |
schemas/StationSensorUpdate.json | Updating specific sensor of a station |
schemas/SensorSerialUpdate.json | Updating sensor serial name |
HTTP Method | Endpoint | URL Params | Function |
---|---|---|---|
GET | /station/{{STATION-ID}} | STATION-ID | Read station information |
PUT | /station/{{STATION-ID}} | STATION-ID | Update station information |
GET | /station/{{STATION-ID}}/sensors | STATION-ID | Get list of sensors of a station |
PUT | /station/{{STATION-ID}}/sensors | STATION-ID | Update station sensor name |
GET | /station/{{STATION-ID}}/nodes | STATION-ID | Get list of nodes (wireless devices) connected to a station |
PUT | /station/{{STATION-ID}}/nodes | STATION-ID | Update the name of a node itself |
GET | /station/{{STATION-ID}}/serials | STATION-ID | List of serials (of a sensor) and their names |
PUT | /station/{{STATION-ID}}/serials | STATION-ID | Update sensor with serial the name |
POST | /station/{{STATION-ID}}/{{STATION-KEY}} | STATION-ID, STATION-KEY | Add station to user account |
DELETE | /station/{{STATION-ID}}/{{STATION-KEY}} | STATION-ID, STATION-KEY | Remove station from user account |
GET | /station/{{STATION-ID}}/proximity/{{RADIUS}} | STATION-ID, RADIUS | Stations in close proximity of specified station |
GET | /station/{{STATION-ID}}/events/last/{{AMOUNT}}/{{SORT}} | STATION-ID, AMOUNT, SORT | Last station events |
GET | /station/{{STATION-ID}}/events/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP}}/{{SORT}} | STATION-ID, FROM-UNIX-TIMESTAMP, TO-UNIX-TIMESTAMP, SORT | Station events from to |
GET | /station/{{STATION-ID}}/history/{{FILTER}}/last/{{AMOUNT}}/{{SORT}} | STATION-ID, FILTER, AMOUNT, SORT | Last station communication history filter |
GET | /station/{{STATION-ID}}/history/{{FILTER}}/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP }}/{{SORT}} | STATION-ID, FILTER, FROM-UNIX-TIMESTAMP, TO-UNIX-TIMESTAMP, SORT | Station communication history from to filter |
GET | /station/{{STATION-ID}}/licenses | STATION-ID | Station licenses for disease models or forecast |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
STATION-KEY | Required | Key 1, Key 2 | Key 1 = RW, Key 2 = R and are supplied with a device |
RADIUS | Required | Xm, Xkm | Xm = miles, Xkm = Kilometers, X = Number |
AMOUNT | Required | INTEGER | Elements |
FILTER | Optional | unknown, success, resync, registration, no_data, xml_error, fw_update, apn_update | Filter out station history by its flag |
SORT | Optional | asc, desc | asc = ascended sort, desc = descended sort |
FROM-UNIX-TIMESTAMP | Required | Unix timestamp | Date/Time in unix timestamp |
TO-UNIX-TIMESTAMP | Required | Unix timestamp | Date/Time in unix timestamp |
Reading station information.
Specification | Value |
---|---|
method | GET |
request | /station/{{STATION-ID}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
401 | Unauthorized |
403 | No permissions - No rights |
500 | Something went wrong, read error message and contact support |
Values that are not listed in table below are self explanatory or not commonly used.
Value | Description |
---|---|
name.original | STATION-ID, unique identifier of a device |
info.device_id | Check System types, its unique ID of a device type |
dates.min_date | Data available from |
dates.max_date | Data available till |
{
"name": {
"original": "STATION-ID",
"custom": ""
},
"rights": "rw",
"info": {
"device_id": 7,
"device_name": "iMetos 3.3",
"uid": "2401010657289D25",
"firmware": "08.200.20170529",
"hardware": "29-0503",
"description": "iMetos 3.3, hw: 29-0503, fw: 08.200.20170529",
"max_time": null
},
"dates": {
"min_date": "2012-01-01 00:00:00",
"max_date": "2017-07-17 12:00:09",
"created_at": "2007-01-22 08:59:42",
"last_communication": "2017-07-17 10:10:41"
},
"position": {
"geo": {
"coordinates": [
15.6353239,
47.2056821
]
},
"altitude": 443
},
"config": {
"timezone_offset": 60,
"dst": false,
"precision_reduction": 0.2,
"scheduler": 1398096,
"schedulerOld": "505515000000000000000000000000000000000000000000",
"fixed_transfer_interval": 0,
"rain_monitor": 0,
"water_level_monitor": 0,
"data_interval": 0,
"activity_mode": 0,
"emergency_sms_number": "NUMBER",
"measuring_interval": 10,
"logging_interval": 15,
"x_min_transfer_interval": false
},
"metadata": {
"last_battery": "6009"
},
"networking": {
"mnc": "1",
"mcc": "MCC",
"apn": "APN",
"username": "EMAIL",
"password": "PASS",
"country": "Austria",
"provider": "PROVIDER",
"type": "GPRS",
"imei": "IMEI",
"simid": "SIMID"
},
"warnings": {
"sms_numbers": [
{
"num": "NUMBER",
"name": "NAME",
"active": true
},...
],
"sensors": [
"0,16,0,0",
"0,16,0,-15",...
]
},
"flags": {
"imeteopro": true
},
"licenses": {
"models": [
"Apple",
"ApricotPlum",
"Viticulture",...
],
"Forecast": true
}
}
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/station/{{STATION-ID}}";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Updating station information/settings.
Specification | Value |
---|---|
method | PUT |
request | /station/{{STATION-ID}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
Schema | Function |
---|---|
schemas/StationUpdate.json | Updating station information |
HTTP CODE | Description |
---|---|
200 | Success |
204 | No changes have been made |
400 | Validation errors |
401 | Unauthorized |
403 | No permissions - No rights |
Values are self explanatory.
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "PUT";
$request = "/station/{{STATION-ID}}";
// Body that you send needs to be JSON schema validated
$body = [
"name" => "New station name",
"position" => [
"geo" => [
"coordinates" => [
11.030232,
45.480726
]
],
"altitude" => 84
]
];
$body = json_encode( $body );
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_POST, TRUE );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $body );
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
{
"title": "Station Update",
"description" : "Update station configuration",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"position": {
"type": "object",
"properties": {
"geo": {
"type": "object",
"properties": {
"coordinates": {
"type": "array",
"items": {
"type": "number"
},
"minItems": 2,
"maxItems": 2
}
},
"required": [
"coordinates"
]
},
"altitude": {
"type": "number"
},
"timezoneCode": {
"type": "string",
"description": "Timezone code, has priority over timezone offset as it is more informative and can be used for DST auto-adjust"
}
},
"required": [
"geo",
"altitude"
]
},
"config.timezone": {
"type": "integer",
"minimum": -720,
"maximum": 840,
"description": "Timezone in minutes. GMT + 1 = 60"
},
"config.precision_reduction": {
"type": "number",
"description": "Precision reduction (0.1, 0.2, 0.5, 1). Rain gauge resolution."
},
"config.activity_mode": {
"type": "integer",
"minimum": 0,
"maximum": 2,
"description": "0 = Station is gathering and sending data, 1 = Station is gathering but not sending data, 2 = Station is not gathering and not sending data"
},
"config.monitor.water_level": {
"type": "integer",
"minimum": 0,
"maximum": 1,
"description": "Water level monitoring 0 (Off), 1(On)"
},
"config.monitor.rain": {
"type": "integer",
"minimum": 0,
"maximum": 1,
"description": "Rain monitoring 0 (Off), 1 (On)"
},
"config.interval.logging": {
"type": "integer",
"minimum": 15,
"maximum": 120,
"description": "Logging interval (Intervals = 15,30,60,120 minutes). Used for data grouping and aggregations."
},
"config.interval.measurement": {
"type": "object",
"patternProperties": {
"^[0-9]\\d*$": {
"type": "integer",
"minimum": 1,
"maximum": 60
}
},
"additionalProperties": false,
"description": "Measurement interval (sampling) 5 min by default for all stations. Per chain measurement interval only for EcoD3 and Metos 3.3 stations ( intervals are 5, 15, 30, 60 minutes but need to be less then logging interval)."
},
"config.upload.scheduler": {
"type": "string",
"description": "Schedule transfer data to server. 24h schedule format = 100000000000000000000001 (0 = Not sending, 1 = Sending). Example is transferring data at 01:00 and 24:00."
},
"config.upload.transfer_fixed": {
"type": "integer",
"description": "Only for iMetos 3.3, iMetos Eco D3 and iMetos Eco D2 fixed transfer interval 15 min. 0 (Off) or 1 (On)."
},
"config.cam1.active": {
"type": "integer",
"description": "Only for CropVIEW stations - Camera On/Off switch (1/0)"
},
"config.cam2.active": {
"type": "integer",
"description": "Only for CropVIEW stations - Camera On/Off switch (1/0)"
},
"config.cam1.auto_exposure": {
"type": "integer",
"description": "Only for CropVIEW stations - Automatic/Manual exposure (1/0)"
},
"config.cam2.auto_exposure": {
"type": "integer",
"description": "Only for CropVIEW stations - - Automatic/Manual exposure (1/0)"
},
"config.cam1.brightness_ref": {
"type": "integer",
"description": "Only for CropVIEW stations - Brightness reference for automatic exposure (default: 750)"
},
"config.cam2.brightness_ref": {
"type": "integer",
"description": "Only for CropVIEW stations - Brightness reference for automatic exposure (default: 750)"
},
"config.cam1.global_gain": {
"type": "integer",
"description": "Only for CropVIEW stations - Global gain for manual exposure (default: 6208)"
},
"config.cam2.global_gain": {
"type": "integer",
"description": "Only for CropVIEW stations - Global gain for manual exposure (default: 6208)"
},
"config.cam1.integration_time": {
"type": "integer",
"description": "Only for CropVIEW stations - Integration time for manual exposure (default: 1000)"
},
"config.cam2.integration_time": {
"type": "integer",
"description": "Only for CropVIEW stations - Integration time for manual exposure (default: 1000)"
},
"config.cam1.max_integration_time": {
"type": "integer",
"description": "Only for CropVIEW stations - Maximal integration time for automatic exposure (default: 2300)"
},
"config.cam2.max_integration_time": {
"type": "integer",
"description": "Only for CropVIEW stations - Maximal integration time for automatic exposure (default: 2300)"
},
"config.cam1.square_spots": {
"type": "integer",
"description": "Only for CropVIEW stations - 8 bit converted to dec (8 bits = 8 measure points)"
},
"config.cam2.square_spots": {
"type": "integer",
"description": "Only for CropVIEW stations - 8 bit converted to dec (8 bits = 8 measure points)"
},
"warnings.sms_numbers": {
"type": "array",
"items": {
"type": "object",
"properties": {
"num": {
"type": "string"
},
"name": {
"type": "string"
},
"active": {
"type": "boolean"
}
}
},
"description": "List of phone numbers that receive a text message upon warning alert (if a phone number is not active it will not receive the warning message)."
},
"warnings.sensors": {
"type": "array",
"items": {
"type": "string"
},
"description": "Warning sensors values: array of strings => 'sensor channel, sensor code, minmax(0/1), value'"
}
},
"additionalProperties": false
}
{
"name" : "",
"position": {
"geo": {
"coordinates": [
11.030232,
45.480726
]
},
"altitude": 84
},
"config.timezone" : 120,
"config.precision_reduction" : 0.2,
"config.activity" : 0,
"config.monitor.water_level" : 0,
"config.monitor.rain" : 0,
"config.interval.logging" : 60,
"config.interval.measurement" : {
"0": 5,
"1" : 5,
"2" : 5
},
"config.upload.scheduler" : "111111111111111111111111",
"config.upload.transfer_fixed" : 0,
"warnings.sensors" : [
"1,143,0,5.6",
"2,600,0,105.80",...
]
}
Reading the list of all sensors that your device has/had.
Specification | Value |
---|---|
method | GET |
request | /station/{{STATION-ID}}/sensors |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No sensors found |
401 | Unauthorized |
403 | No permissions - No rights |
Values that are not listed in table below are self explanatory.
Value | Description |
---|---|
unit | Default unit |
units | Available units for specified sensor |
ch | On which channel on a board is sensor present |
code | Unique ID of a sensor |
group | Sensors with common specs/behavior belong to same group |
mac | Nodes connected to a main station are identified by MAC. X marks no serial and is base station. |
serial | Sensor with multiple outputs can be identify by using serial number. X marks no serial. |
aggr | Sensors send data to a server with specific aggregation or aggregations (min, max, avg, last, sum, time) |
registered | When sensor was registered by the system |
isActive | Currently active sensor, there may be old sensors that are not currently active |
[
{
"name": "Wind direction",
"name_custom": null,
"color": "#1a1a1a",
"decimals": 0,
"divider": 1,
"unit": "deg",
"units": [
"deg"
],
"ch": 1,
"code": 143,
"group": 16,
"mac": "X",
"serial": "X",
"vals": {
"min": 0,
"max": 360
},
"aggr": {
"avg": 1,
"last": 1
},
"registered": "2017-06-30 18:00:00",
"isActive": true
},
{
"name": "Solar radiation",
"name_custom": null,
"color": "#ffff99",
"decimals": 0,
"divider": 1,
"unit": "W/m2",
"units": [
"W/m2",
"J/m2",
"kJ/m2",
"MJ/m2"
],
"ch": 2,
"code": 600,
"group": 4,
"mac": "X",
"serial": "X",
"vals": {
"min": 0,
"max": 32767
},
"aggr": {
"avg": 1
},
"registered": "2017-06-30 18:00:00",
"isActive": true
},
{
"name": "Solar Panel",
"name_custom": null,
"color": "#ff7f00",
"decimals": 0,
"divider": 1,
"unit": "mV",
"units": [
"mV",
"V"
],
"ch": 4,
"code": 30,
"group": 7,
"mac": "X",
"serial": "X",
"vals": {
"min": 0,
"max": 32767
},
"aggr": {
"last": 1
},
"registered": "2017-06-30 18:00:00",
"isActive": true
},...
]
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/station/{{STATION-ID}}/sensors";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Updating station sensor name, unit ...
Specification | Value |
---|---|
method | PUT |
request | /station/{{STATION-ID}}/sensors |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
Schema | Function |
---|---|
schemas/StationSensorUpdate.json | Updating station information |
HTTP CODE | Description |
---|---|
200 | Success |
204 | No changes have been made |
400 | Validation errors |
401 | Unauthorized |
403 | No permissions - No rights |
Values are self explanatory.
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "PUT";
$request = "/station/{{STATION-ID}}/sensors";
// Body that you send needs to be JSON schema validated
$body = [
"name" => "New sensor name",
"channel" => "SENSOR-CHANNEL",
"code" => "SENSOR-CODE",
"color" => "#000"
];
$body = json_encode( $body );
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_POST, TRUE );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $body );
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
{
"title": "Station sensor update",
"description" : "Update specific sensor of a station",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"channel": {
"type": "integer"
},
"code": {
"type": "integer"
},
"color": {
"type": "string",
"description": "Format has to be in HEX"
},
"unit": {
"type": "string"
}
},
"required": [
"channel",
"code",
"unit",
"color"
],
"additionalProperties": false
}
{
"name" : "New sensor name",
"channel" : "SENSOR-CHANNEL",
"code" : "SENSOR-CODE",
"color" : "#000"
}
Station nodes are wireless nodes connected to base station (STATION-ID). Here you can list custom names if any of a node has custom name.
To get list of nodes we suggest using call /station/{{STATION-ID}}/sensors and each sensor has MAC address.
Specification | Value |
---|---|
method | GET |
request | /station/{{STATION-ID}}/nodes |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No nodes settings |
401 | Unauthorized |
403 | No permissions - No rights |
Values that are not listed in table below are self explanatory or not commonly used.
Value | Description |
---|---|
name | Custom name of a node or base station |
{
"NODE-MAC": {
"name": "Each node that is not base station (STATION-ID) has MAC address"
},
"X": {
"name": "Base station MAC address is X (STATION-ID)"
}
}
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/station/{{STATION-ID}}/nodes";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Updating station sensor name, unit ...
Specification | Value |
---|---|
method | PUT |
request | /station/{{STATION-ID}}/nodes |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
Schema | Function |
---|---|
schemas/NodeUpdate.json | Updating the node |
HTTP CODE | Description |
---|---|
200 | Success |
204 | No changes have been made |
400 | Validation errors |
401 | Unauthorized |
403 | No permissions - No rights |
Values are self explanatory.
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "PUT";
$request = "/station/{{STATION-ID}}/nodes";
// Body that you send needs to be JSON schema validated
$body = [
"name" => "New node name",
"mac" => "MAC-ADDRESS-OF-A-NODE"
];
$body = json_encode( $body );
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_POST, TRUE );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $body );
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
{
"title": "Node update",
"description": "Update the name of a node. Node is wireless device connected to base station.",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"mac": {
"type": "string",
"description": "MAC address or Station ID as X (X indicates default station)"
}
},
"required": [
"name",
"mac"
],
"additionalProperties": false
}
{
"name" : "New node name",
"mac" : "MAC-ADDRESS-OF-A-NODE"
}
Sensor serials settings. If there are no settings we get no content response.
To get list of all sensors serials we suggest using call /station/{{STATION-ID}}/sensors where each sensor has serial tag.
Serial is normally used by drill and drop sensors where we get for one sensor 6 or more sensor outputs as drill and drop
contains multiple sensors at specific depth. To identify this sensor as a whole we introduced serial.
Specification | Value |
---|---|
method | GET |
request | /station/{{STATION-ID}}/serials |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No serials settings |
401 | Unauthorized |
403 | No permissions - No rights |
Values that are not listed in table below are self explanatory or not commonly used.
Value | Description |
---|---|
name | Custom name of a serial of a sensor |
{
"SERIAL": {
"name": "SERIAL-NAME"
},...
}
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/station/{{STATION-ID}}/serials";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Updating sensor serial information.
Specification | Value |
---|---|
method | PUT |
request | /station/{{STATION-ID}}/serials |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
Schema | Function |
---|---|
schemas/SensorSerialUpdate.json | Updating sensor serial |
HTTP CODE | Description |
---|---|
200 | Success |
204 | No changes have been made |
400 | Validation errors |
401 | Unauthorized |
403 | No permissions - No rights |
Values are self explanatory.
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "PUT";
$request = "/station/{{STATION-ID}}/serials";
// Body that you send needs to be JSON schema validated
$body = [
"name" => "New serial name",
"serial" => "SENSOR-SERIAL"
];
$body = json_encode( $body );
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_POST, TRUE );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $body );
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
{
"title": "Sensor serial update",
"description" : "Update sensor serial",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"serial": {
"type": "string",
"description": "If there is none put X"
}
},
"required": [
"name",
"serial"
],
"additionalProperties": false
}
{
"name": "New serial name",
"serial" : "SENSOR-SERIAL"
}
Adding station to user account. Key 1 and Key 2 are supplied with device itself.
If you add station with key 1 then that user has RW permissions for that station (configuration ... ) else with key 1 only read permissions.
RIGHTS:
Key 1: RW
key 2: R
Specification | Value |
---|---|
method | POST |
request | /station/{{STATION-ID}}/{{STATION-KEY}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
STATION-KEY | Required | STRING | Unique key 1 or 2 of a device |
Schema | Function |
---|---|
schemas/UserStationInsert.json | Adding station to user account |
HTTP CODE | Description |
---|---|
200 | Success |
204 | User already has this station |
400 | Validation errors |
401 | Unauthorized |
403 | No permissions - No rights |
Values are self explanatory.
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "POST";
$request = "/station/{{STATION-ID}}/{{STATION-KEY}}";
// Body that you send needs to be JSON schema validated
$body = [
"name" => "Custom station name"
];
$body = json_encode( $body );
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_POST, TRUE );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $body );
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
{
"title": "User station insert",
"description" : "Add a station to an user",
"type": "object",
"properties": {
"name": {
"type": "string",
"pattern": "^[a-zA-Z\\s\\d]{0,35}$",
"description": "Only characters, numbers, spaces and max length 35"
}
},
"additionalProperties": false
}
{
"name" : "Custom name of a station"
}
Removing station from current account. The keys come with device itself.
If station has been added with Key 1, key 1 has to be used to remove it.
If station has been added with Key 2, key 1 or key 2 has to be used to remove it.
Specification | Value |
---|---|
method | DELETE |
request | /station/{{STATION-ID}}/{{STATION-KEY}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
STATION-KEY | Required | STRING | Unique key 1 or 2 of a device |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | Nothing to be removed |
401 | Unauthorized - Login required |
403 | No permissions - No rights or incorrect key |
Values are self explanatory.
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "DELETE";
$request = "/station/{{STATION-ID}}/{{STATION-KEY}}";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Find stations in proximity of specified station.
Specification | Value |
---|---|
method | GET |
request | /station/{{STATION-ID}}/proximity/{{RADIUS}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
RADIUS | Required | Xm, Xkm | Xm = miles, Xkm = Kilometers, X = Number |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No stations found in proximity |
400 | Validation error |
401 | Unauthorized |
403 | No permissions - No rights |
Values are self explanatory.
{
"STATION-ID": {
"Longitude": Longitude,
"Latitude": latitude
},
"STATION-ID": {
"Longitude": Longitude,
"Latitude": latitude
},
"STATION-ID": {
"Longitude": Longitude,
"Latitude": latitude
},...
}
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/station/{{STATION-ID}}/proximity/{{RADIUS}}";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Read last X amount of station events. Optionally you can also sort them ASC or DESC.
Specification | Value |
---|---|
method | GET |
request | /station/{{STATION-ID}}/events/last/{{AMOUNT}}/{{SORT}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
AMOUNT | Required | INTEGER | Elements |
SORT | Optional | asc, desc | asc = ascended sort, desc = descended sorts |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No events found |
401 | Unauthorized |
403 | No permissions - No rights |
500 | System can not read event code |
Values are self explanatory.
[
{
"dateTime": "2016-10-09 11:01:22",
"code": 12,
"keyword": "SYSEVENT_CODE_SYSTEM_RESET_EXT",
"description": "External reset\n"
},
{
"dateTime": "2016-10-10 06:31:21",
"code": 12,
"keyword": "SYSEVENT_CODE_SYSTEM_RESET_EXT",
"description": "External reset\n"
},
{
"dateTime": "2016-10-11 07:06:31",
"code": 12,
"keyword": "SYSEVENT_CODE_SYSTEM_RESET_EXT",
"description": "External reset\n"
},
{
"dateTime": "2016-10-11 07:36:30",
"code": 12,
"keyword": "SYSEVENT_CODE_SYSTEM_RESET_EXT",
"description": "External reset\n"
},
{
"dateTime": "2016-10-20 05:01:22",
"code": 12,
"keyword": "SYSEVENT_CODE_SYSTEM_RESET_EXT",
"description": "External reset\n"
}
]
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/station/{{STATION-ID}}/events/last/{{AMOUNT}}/{{SORT}}";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Read station events between time period you select. Optionally you can also sort them ASC or DESC.
Specification | Value |
---|---|
method | GET |
request | /station/{{STATION-ID}}/events/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP}}/{{SORT}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
FROM-UNIX-TIMESTAMP | Required | Unix timestamp | Date/Time in unix timestamp |
TO-UNIX-TIMESTAMP | Required | Unix timestamp | Date/Time in unix timestamp |
SORT | Optional | asc, desc | asc = ascended sort, desc = descended sorts |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No events found |
401 | Unauthorized |
403 | No permissions - No rights |
500 | System can not read event code |
Values are self explanatory.
[
{
"dateTime": "2016-10-09 11:01:22",
"code": 12,
"keyword": "SYSEVENT_CODE_SYSTEM_RESET_EXT",
"description": "External reset\n"
},
{
"dateTime": "2016-10-10 06:31:21",
"code": 12,
"keyword": "SYSEVENT_CODE_SYSTEM_RESET_EXT",
"description": "External reset\n"
},
{
"dateTime": "2016-10-11 07:06:31",
"code": 12,
"keyword": "SYSEVENT_CODE_SYSTEM_RESET_EXT",
"description": "External reset\n"
},
{
"dateTime": "2016-10-11 07:36:30",
"code": 12,
"keyword": "SYSEVENT_CODE_SYSTEM_RESET_EXT",
"description": "External reset\n"
},
{
"dateTime": "2016-10-20 05:01:22",
"code": 12,
"keyword": "SYSEVENT_CODE_SYSTEM_RESET_EXT",
"description": "External reset\n"
}
]
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/station/{{STATION-ID}}/events/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP}}/{{SORT}}";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Read last X amount of station transmission history. Optionally you can also sort them ASC or DESC and filter.
Specification | Value |
---|---|
method | GET |
request | /station/{{STATION-ID}}/history/{{FILTER}}/last/{{AMOUNT}}/{{SORT}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
FILTER | Optional | unknown, success, resync, registration, no_data, xml_error, fw_update, apn_update | Filter out station history by its flag |
AMOUNT | Required | INTEGER | Elements |
SORT | Optional | asc, desc | asc = ascended sort, desc = descended sort |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No communication history |
401 | Unauthorized |
403 | No permissions - No rights |
Values are self explanatory.
[
{
"dateTime": "2016-10-26 11:02:00",
"xml_s": 6975,
"http_s": 7355,
"ip": "IP-ADDRESS",
"flags": [
"no_data",
"resync"
],
"df_st": "2016-10-25 20:50:00",
"df_end": "2016-10-26 14:00:00"
},
{
"dateTime": "2016-10-26 10:01:46",
"xml_s": 6973,
"http_s": 7353,
"ip": "IP-ADDRESS",
"flags": [
"no_data",
"resync"
],
"df_st": "2016-10-25 19:50:00",
"df_end": "2016-10-26 13:00:00"
},...
]
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/station/{{STATION-ID}}/history/{{FILTER}}/last/{{AMOUNT}}/{{SORT}}";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
s
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Read transmission history for specific time period. Optionally you can also sort them ASC or DESC and filter.
Specification | Value |
---|---|
method | GET |
request | /station/{{STATION-ID}}/history/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP}}/{{SORT}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
FILTER | Optional | unknown, success, resync, registration, no_data, xml_error, fw_update, apn_update | Filter out station history by its flag |
FROM-UNIX-TIMESTAMP | Required | Unix timestamp | Date/Time in unix timestamp |
TO-UNIX-TIMESTAMP | Required | Unix timestamp | Date/Time in unix timestamp |
SORT | Optional | asc, desc | asc = ascended sort, desc = descended sort |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No communication history |
401 | Unauthorized |
403 | No permissions - No rights |
Values are self explanatory.
[
{
"dateTime": "2016-10-26 09:01:51",
"xml_s": 6983,
"http_s": 7363,
"ip": "IP-ADDRESS",
"flags": [
"success"
],
"df_st": "2016-10-25 18:50:00",
"df_end": "2016-10-26 12:00:00"
},
{
"dateTime": "2016-10-26 08:02:11",
"xml_s": 6985,
"http_s": 7365,
"ip": "IP-ADDRESS",
"flags": [
"success"
],
"df_st": "2016-10-25 17:50:00",
"df_end": "2016-10-26 11:00:00"
},
{
"dateTime": "2016-10-26 07:01:55",
"xml_s": 6993,
"http_s": 7373,
"ip": "IP-ADDRESS",
"flags": [
"success"
],
"df_st": "2016-10-25 16:50:00",
"df_end": "2016-10-26 10:00:00"
},
{
"dateTime": "2016-10-26 05:21:40",
"xml_s": 5947,
"http_s": 6327,
"ip": "IP-ADDRESS",
"flags": [
"success"
],
"df_st": "2016-10-25 15:10:00",
"df_end": "2016-10-26 08:20:00"
},...
]
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/station/{{STATION-ID}}/history/{{FILTER}}/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP}}/{{SORT}}";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
s
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Retrieve all the licenses of your device. They are separated by the service (models, forecast ...).
Specification | Value |
---|---|
method | GET |
request | /station/{{STATION-ID}}/licenses |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No licenses |
401 | Unauthorized |
403 | No permissions - No rights |
Values are self explanatory.
{
"models": {
"Apple": [
{
"from": "2010-01-01 00:00:00",
"to": "2020-01-01 00:00:00"
}
],
"ApricotPlum": [
{
"from": "2010-01-01 00:00:00",
"to": "2020-01-01 00:00:00"
}
],
"Viticulture": [
{
"from": "2010-01-01 00:00:00",
"to": "2020-01-01 00:00:00"
}
],...
},
"Forecast": [
{
"from": "2010-01-01 00:00:00",
"to": "2020-01-01 00:00:00"
}
]
}
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/station/{{STATION-ID}}/licenses";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Retrieving and customizing the output of your device data. By default we return all the devices data and information (sensors ...) for specified period.
To customize which data and in what manner you get it, we developed an interface called VIEW into which we pass specific JSON rules so you can form data in your liking.
You are limited to retrieve MAX 10.000 data points.
Interface that enables you to form data into your liking, by passing specific JSON rules into it.
VIEW customization options:
We support different type of VIEWS. Predefined, customized and user defined.
To get a list of all pre-defined VIEWs in the system, you can perform API request /views/predefined to retrieve this information.
All what is required is to specify the name of pre-defined view.
Customized view is a pre-defined view customized by the client. To customize pre-defined VIEW with custom rule set you need to specify the same name of pre-defined view and make necessary changes to the rule set.
User defined view by the client itself. Note that name should not match one of pre-defined names. Schema and example of rule set options can be seen in the right pane.
There are three ways to retrieve disease model data. First one is by using /DISEASE requests which will return you only disease model data without correlated sensors.
Secondly you can use system defined, customized or user defined VIEW in which you specify DATA-->MODEL = DISEASE-MODEL-KEY which will return you sensors of a VIEW and disease model data.
Last and recommended way is to get it by using system defined VIEW for disease model. To get system defined VIEW of disease model all you need to do is to specify the VIEW NAME = disease. DISEASE-MODEL-KEY. Pre-defined disease model VIEW will return you disease model data and correlated sensor data.
List of supported disease models can be retrieved by using request system/diseases from which you use disease model KEY as NAME = disease, KEY in the VIEW.
Schema | Function |
---|---|
schemas/View.json | Customizing your data output |
HTTP Method | Endpoint | URL Params | Function |
---|---|---|---|
GET | /data/{{STATION-ID}} | STATION-ID | Min and Max date of data availability |
GET | /data/{{FORMAT}}/{{STATION-ID}}/{{DATA-GROUP}}/last/{{TIME-PERIOD}} | FORMAT, STATION-ID, DATA-GROUP, TIME-PERIOD | Reading last data |
GET | /data/{{FORMAT}}/{{STATION-ID}}/{{DATA-GROUP}}/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP}} | FORMAT, STATION-ID, DATA-GROUP, FROM-UNIX-TIMESTAMP, TO-UNIX-TIMESTAMP | Reading data of specific time period |
POST | /data/{{FORMAT}}/{{STATION-ID}}/{{DATA-GROUP}}/last/{{TIME-PERIOD}} | FORMAT, STATION-ID, DATA-GROUP, TIME-PERIOD | Filtered/Customized reading of last data |
POST | /data/{{FORMAT}}/{{STATION-ID}}/{{DATA-GROUP}}/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP}} | FORMAT, STATION-ID, DATA-GROUP, FROM-UNIX-TIMESTAMP, TO-UNIX-TIMESTAMP | Filtered/Customized reading of specified time period |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
FORMAT | Optional | normal, optimized | Different data output formats. Recommended is optimized |
DATA-GROUP | Required | raw, hourly, daily, monthly | Device data grouped |
TIME-PERIOD | Required | Xh, Xd, Xw, Xm, X | X = Number, h = hours, d = days, w = weeks, m = months |
FROM-UNIX-TIMESTAMP | Required | Unix timestamp | Date/Time in unix timestamp |
TO-UNIX-TIMESTAMP | Optional | Unix timestamp | Date/Time in unix timestamp, if not specified data will be taken till last available |
# 1. Filter data 5 - Wind speed, 4 - Leaf Wetness, 506 - Air temperature, 507 - Relative humidity
# 2. Data comes in imperial units
{
"sensors": {
"filter": {
"sensor-5": true,
"sensor-4": true,
"sensor-506": true,
"sensor-507": true
}
},
"data": {
"unit_system": "imperial"
}
}
{
"name":"disease, GeneralFireblight"
}
{
"properties": {
"description": "Pre-defined, combined or custom name",
"name": {
"type": "string"
},
"sensors": {
"properties": {
"filter": {
"description": "Filter by group, sensor, mac or serial and optionally specify aggregation",
"properties": {
"group-7": {
"items": {
"type": "string"
},
"type": "array",
"enum": [
"avg",
"min",
"max",
"sum",
"time",
"last",
"user"
]
},
"mac-MAC_ADDRESS": {
"type": "boolean"
},
"sensor-506": {
"items": {
"type": "string"
},
"type": "array",
"enum": [
"avg",
"min",
"max",
"sum",
"time",
"last",
"user"
]
},
"serial-SERIAL": {
"type": "boolean"
}
},
"type": "object"
},
"settings": {
"description": "Configure sensor output",
"properties": {
"group-7": {
"unit": "Custom unit",
"type": "string"
},
"sensor-506": {
"unit": "Custom unit",
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"data": {
"properties": {
"model": {
"description": "Disease model name",
"type": "string"
},
"sunrise_sunset": {
"description": "Get sunrise and sunset dates for specified period",
"type": "boolean"
},
"unit_system": {
"type": "string",
"description": "One of",
"enum": [
"imperial",
"metric"
]
}
},
"type": "object"
}
},
"type": "object"
}
{
# VIEW NAME: Pre-Defined, Combined, Custom
"name": "PRE-DEFINED, COMBINED OR CUSTOM ... NAME,
"sensors": {
"filter": {
# Filter out specific sensor
"sensor-506": 1,
# Filter out specific sensor and its aggregation
"sensor-506": [
"avg"
],
# Filter out specific sensors of a group
"group-7": 1,
# Filter out specific sensors of a group and its aggragation
"group-7": [
"avg"
],
# Filter out sensors on MAC
"mac-MAC_ADDRESS": true,
# Filter out sensors with Serial
"serial-SERIAL": true
},
"settings" : {
# Configure output of a sensor, by changing the unit manually
"sensor-506": [
"unit" : "sec"
],
# Configure output of a sensor group, by changing the unit manually
"group-7": [
"unit" : "sec"
]
}
},
"data": {
# UNIT SYSTEM: matric, imperial
"unit_system": "imperial",
# Sunrise and sunset dates
"sunrise_sunset" : true,
# DISEASE MODEL DATA
"model": "DISEASE-MODEL"
}
}
Retrieve min and max date of device data availability. This request can be used to check if device has sent new data which you
can retrieve, by just memorizing last max_date and compare it with current one.
Specification | Value |
---|---|
method | GET |
request | /data/{{STATION-ID}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No data |
401 | Unauthorized |
403 | No permissions - No rights, CropView type of stations do not support this call |
Values are self explanatory.
{
"min_date": "2012-01-01 00:00:00",
"max_date": "2017-07-21 06:00:10"
}
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/data/{{STATION-ID}}";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Retrieve last data that device sends. We recommend calling /data/{{STATION-ID}} first so you can see if
there is any new data.
NOTE that time period gives you flexibility:
You are limited to retrieve MAX 10.000 data points.
Specification | Value |
---|---|
method | GET |
request | /data/{{FORMAT}}/{{STATION-ID}}/{{DATA-GROUP}}/last/{{TIME-PERIOD}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
FORMAT | Optional | normal, optimized | Different data output formats. Recommended is optimized |
DATA-GROUP | Required | raw, hourly, daily, monthly | Device data grouped |
TIME-PERIOD | Required | Xh, Xd, Xw, Xm, X | X = Number, h = hours, d = days, w = weeks, m = months |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No data for specified time period |
400 | Data over limit |
401 | Unauthorized |
403 | No permissions - No rights |
406 | Specified params are not acceptable |
Values are self explanatory.
# NORMAL
# Data and sensors come separated and can be connected using unique TAG
# Dates and data are on the same level
# 1_X_X_143_avg tag is = CH_MAC_SERIAL_CODE_AGGREGATION
{
"sensors": [
{
"name": "Wind direction",
"name_custom": false,
"decimals": 0,
"unit": "deg",
"ch": 1,
"chain": 1,
"code": 143,
"group": 16,
"serial": "X",
"mac": "X",
"vals": {
"min": 0,
"max": 360
},
"aggr": {
"avg": 1,
"last": 1
},
"registered": "2017-06-30 18:00:00"
},
{
"name": "Solar radiation",
"name_custom": false,
"decimals": 0,
"unit": "W/m2",
"ch": 2,
"chain": 1,
"code": 600,
"group": 4,
"serial": "X",
"mac": "X",
"vals": {
"min": 0,
"max": 32767
},
"aggr": {
"avg": 1
},
"registered": "2017-06-30 18:00:00"
},..
],
"data": [
{
"date": "2017-07-21 05:00:00",
"1_X_X_143_avg": 39,
"1_X_X_143_last": 39,
"2_X_X_600_avg": 0,
"4_X_X_30_last": 0,...
},
{
"date": "2017-07-21 05:15:00",
"1_X_X_143_avg": 117,
"1_X_X_143_last": 117,
"2_X_X_600_avg": 0,
"4_X_X_30_last": 0,...
},...
]
}
# OPTIMIZED - Recommended
# Data can come in several aggravations inside the sensor information AGGR
# Dates come separated from the data but are in the same order
# All other information is sensor related information
# We recommend this format because of its simplicity and output size is smaller then normal one
# 1_X_X_143 tag is = CH_MAC_SERIAL_CODE
{
"dates": [
"2017-07-21 05:00:00",
"2017-07-21 05:15:00",
"2017-07-21 05:30:00",
"2017-07-21 05:45:00",
"2017-07-21 06:00:00"
],
"data": {
"1_X_X_143": {
"name": "Wind direction",
"name_custom": false,
"decimals": 0,
"unit": "deg",
"ch": 1,
"code": 143,
"group": 16,
"serial": "X",
"mac": "X",
"vals": {
"min": 0,
"max": 360
},
"aggr": {
"avg": [
39,
117,
85,
74,
74
],
"last": [
39,
117,
85,
74,
74
]
},
"registered": "2017-06-30 18:00:00"
},
"2_X_X_600": {
"name": "Solar radiation",
"name_custom": false,
"decimals": 0,
"unit": "W/m2",
"ch": 2,
"code": 600,
"group": 4,
"serial": "X",
"mac": "X",
"vals": {
"min": 0,
"max": 32767
},
"aggr": {
"avg": [
0,
0,
0,
0,
0
]
},
"registered": "2017-06-30 18:00:00"
},...
}
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/data/{{FORMAT}}/{{STATION-ID}}/{{DATA-GROUP}}/last/{{TIME-PERIOD}}";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Retrieve data between specified time periods. We recommend calling /data/{{STATION-ID}} first so you can see if
there is any new data. Times from and to need to be specified in unix timestamp.
You are limited to retrieve MAX 10.000 data points.
Specification | Value |
---|---|
method | GET |
request | /data/{{FORMAT}}/{{STATION-ID}}/{{DATA-GROUP}}/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP }} |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
FORMAT | Optional | normal, optimized | Different data output formats. Recommended is optimized |
DATA-GROUP | Required | raw, hourly, daily, monthly | Device data grouped |
FROM-UNIX-TIMESTAMP | Required | Unix timestamp | Date/Time in unix timestamp |
TO-UNIX-TIMESTAMP | Optional | Unix timestamp | Date/Time in unix timestamp, if not specified data will be taken till last available |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No data for specified time period |
400 | Data over limit |
401 | Unauthorized |
403 | No permissions - No rights |
406 | Specified params are not acceptable |
Values are self explanatory.
# NORMAL
# Data and sensors come separated and can be connected using unique TAG
# Dates and data are on the same level
# 1_X_X_143_avg tag is = CH_MAC_SERIAL_CODE_AGGREGATION
{
"sensors": [
{
"name": "Wind direction",
"name_custom": false,
"decimals": 0,
"unit": "deg",
"ch": 1,
"chain": 1,
"code": 143,
"group": 16,
"serial": "X",
"mac": "X",
"vals": {
"min": 0,
"max": 360
},
"aggr": {
"avg": 1,
"last": 1
},
"registered": "2017-06-30 18:00:00"
},
{
"name": "Solar radiation",
"name_custom": false,
"decimals": 0,
"unit": "W/m2",
"ch": 2,
"chain": 1,
"code": 600,
"group": 4,
"serial": "X",
"mac": "X",
"vals": {
"min": 0,
"max": 32767
},
"aggr": {
"avg": 1
},
"registered": "2017-06-30 18:00:00"
},..
],
"data": [
{
"date": "2017-07-21 05:00:00",
"1_X_X_143_avg": 39,
"1_X_X_143_last": 39,
"2_X_X_600_avg": 0,
"4_X_X_30_last": 0,...
},
{
"date": "2017-07-21 05:15:00",
"1_X_X_143_avg": 117,
"1_X_X_143_last": 117,
"2_X_X_600_avg": 0,
"4_X_X_30_last": 0,...
},...
]
}
# OPTIMIZED - Recommended
# Data can come in several aggravations inside the sensor information AGGR
# Dates come separated from the data but are in the same order
# All other information is sensor related information
# We recommend this format because of its simplicity and output size is smaller then normal one
# 1_X_X_143 tag is = CH_MAC_SERIAL_CODE
{
"dates": [
"2017-07-21 05:00:00",
"2017-07-21 05:15:00",
"2017-07-21 05:30:00",
"2017-07-21 05:45:00",
"2017-07-21 06:00:00"
],
"data": {
"1_X_X_143": {
"name": "Wind direction",
"name_custom": false,
"decimals": 0,
"unit": "deg",
"ch": 1,
"code": 143,
"group": 16,
"serial": "X",
"mac": "X",
"vals": {
"min": 0,
"max": 360
},
"aggr": {
"avg": [
39,
117,
85,
74,
74
],
"last": [
39,
117,
85,
74,
74
]
},
"registered": "2017-06-30 18:00:00"
},
"2_X_X_600": {
"name": "Solar radiation",
"name_custom": false,
"decimals": 0,
"unit": "W/m2",
"ch": 2,
"code": 600,
"group": 4,
"serial": "X",
"mac": "X",
"vals": {
"min": 0,
"max": 32767
},
"aggr": {
"avg": [
0,
0,
0,
0,
0
]
},
"registered": "2017-06-30 18:00:00"
},...
}
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/data/{{FORMAT}}/{{STATION-ID}}/{{DATA-GROUP}}/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP}}";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Retrieve last data that device sends in your liking. We recommend calling /data/{{STATION-ID}} first so you can see if
there is any new data.
NOTE that time period gives you flexibility:
You are limited to retrieve MAX 10.000 data points.
Specification | Value |
---|---|
method | POST |
request | /data/{{FORMAT}}/{{STATION-ID}}/{{DATA-GROUP}}/last/{{TIME-PERIOD}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
FORMAT | Optional | normal, optimized | Different data output formats. Recommended is optimized |
DATA-GROUP | Required | raw, hourly, daily, monthly | Device data grouped |
TIME-PERIOD | Required | Xh, Xd, Xw, Xm, X | X = Number, h = hours, d = days, w = weeks, m = months |
Schema | Function |
---|---|
schemas/View.json | Customizing your data output |
HTTP CODE | Description |
---|---|
200 | Success |
204 | No data for specified time period |
400 | Data over limit |
401 | Unauthorized |
403 | No permissions - No rights |
406 | Specified params are not acceptable |
Values are self explanatory.
# NORMAL
# Data and sensors come separated and can be connected using unique TAG
# Dates and data are on the same level
# 1_X_X_143_avg tag is = CH_MAC_SERIAL_CODE_AGGREGATION
{
"sensors": [
{
"name": "Wind direction",
"name_custom": false,
"decimals": 0,
"unit": "deg",
"ch": 1,
"chain": 1,
"code": 143,
"group": 16,
"serial": "X",
"mac": "X",
"vals": {
"min": 0,
"max": 360
},
"aggr": {
"avg": 1,
"last": 1
},
"registered": "2017-06-30 18:00:00"
},
{
"name": "Solar radiation",
"name_custom": false,
"decimals": 0,
"unit": "W/m2",
"ch": 2,
"chain": 1,
"code": 600,
"group": 4,
"serial": "X",
"mac": "X",
"vals": {
"min": 0,
"max": 32767
},
"aggr": {
"avg": 1
},
"registered": "2017-06-30 18:00:00"
},..
],
"data": [
{
"date": "2017-07-21 05:00:00",
"1_X_X_143_avg": 39,
"1_X_X_143_last": 39,
"2_X_X_600_avg": 0,
"4_X_X_30_last": 0,...
},
{
"date": "2017-07-21 05:15:00",
"1_X_X_143_avg": 117,
"1_X_X_143_last": 117,
"2_X_X_600_avg": 0,
"4_X_X_30_last": 0,...
},...
]
}
# OPTIMIZED - Recommended
# Data can come in several aggravations inside the sensor information AGGR
# Dates come separated from the data but are in the same order
# All other information is sensor related information
# We recommend this format because of its simplicity and output size is smaller then normal one
# 1_X_X_143 tag is = CH_MAC_SERIAL_CODE
{
"dates": [
"2017-07-21 05:00:00",
"2017-07-21 05:15:00",
"2017-07-21 05:30:00",
"2017-07-21 05:45:00",
"2017-07-21 06:00:00"
],
"data": {
"1_X_X_143": {
"name": "Wind direction",
"name_custom": false,
"decimals": 0,
"unit": "deg",
"ch": 1,
"code": 143,
"group": 16,
"serial": "X",
"mac": "X",
"vals": {
"min": 0,
"max": 360
},
"aggr": {
"avg": [
39,
117,
85,
74,
74
],
"last": [
39,
117,
85,
74,
74
]
},
"registered": "2017-06-30 18:00:00"
},
"2_X_X_600": {
"name": "Solar radiation",
"name_custom": false,
"decimals": 0,
"unit": "W/m2",
"ch": 2,
"code": 600,
"group": 4,
"serial": "X",
"mac": "X",
"vals": {
"min": 0,
"max": 32767
},
"aggr": {
"avg": [
0,
0,
0,
0,
0
]
},
"registered": "2017-06-30 18:00:00"
},...
}
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "POST";
$request = "/data/{{FORMAT}}/{{STATION-ID}}/{{DATA-GROUP}}/last/{{TIME-PERIOD}}";
// Body that you send needs to be JSON schema validated
$body = [
"sensors" => [
"filter" => [
"sensor-506" => TRUE
]
]
];
$body = json_encode( $body );
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_POST, TRUE );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $body );
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
{
"properties": {
"description": "Pre-defined, combined or custom name",
"name": {
"type": "string"
},
"sensors": {
"properties": {
"filter": {
"description": "Filter by group, sensor, mac or serial and optionally specify aggregation",
"properties": {
"group-7": {
"items": {
"type": "string"
},
"type": "array",
"enum": [
"avg",
"min",
"max",
"sum",
"time",
"last",
"user"
]
},
"mac-MAC_ADDRESS": {
"type": "boolean"
},
"sensor-506": {
"items": {
"type": "string"
},
"type": "array",
"enum": [
"avg",
"min",
"max",
"sum",
"time",
"last",
"user"
]
},
"serial-SERIAL": {
"type": "boolean"
}
},
"type": "object"
},
"settings": {
"description": "Configure sensor output",
"properties": {
"group-7": {
"unit": "Custom unit",
"type": "string"
},
"sensor-506": {
"unit": "Custom unit",
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"data": {
"properties": {
"model": {
"description": "Disease model name",
"type": "string"
},
"sunrise_sunset": {
"description": "Get sunrise and sunset dates for specified period",
"type": "boolean"
},
"unit_system": {
"type": "string",
"description": "One of",
"enum": [
"imperial",
"metric"
]
}
},
"type": "object"
}
},
"type": "object"
}
{
# VIEW NAME: Pre-Defined, Combined, Custom
"name": "PRE-DEFINED, COMBINED OR CUSTOM ... NAME,
"sensors": {
"filter": {
# Filter out specific sensor
"sensor-506": 1,
# Filter out specific sensor and its aggregation
"sensor-506": [
"avg"
],
# Filter out specific sensors of a group
"group-7": 1,
# Filter out specific sensors of a group and its aggragation
"group-7": [
"avg"
],
# Filter out sensors on MAC
"mac-MAC_ADDRESS": true,
# Filter out sensors with Serial
"serial-SERIAL": true
},
"settings" : {
# Configure output of a sensor, by changing the unit manually
"sensor-506": [
"unit" : "sec"
],
# Configure output of a sensor group, by changing the unit manually
"group-7": [
"unit" : "sec"
]
}
},
"data": {
# UNIT SYSTEM: matric, imperial
"unit_system": "imperial",
# Sunrise and sunset dates
"sunrise_sunset" : true,
# DISEASE MODEL DATA
"model": "DISEASE-MODEL"
}
}
Retrieve data between specified time periods in your liking. We recommend calling /data/{{STATION-ID}} first so you can see if
there is any new data. Times from and to need to be specified in unix timestamp.
You are limited to retrieve MAX 10.000 data points.
Specification | Value |
---|---|
method | POST |
request | /data/{{FORMAT}}/{{STATION-ID}}/{{DATA-GROUP}}/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP }} |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
FORMAT | Optional | normal, optimized | Different data output formats. Recommended is optimized |
DATA-GROUP | Required | raw, hourly, daily, monthly | Device data grouped |
FROM-UNIX-TIMESTAMP | Required | Unix timestamp | Date/Time in unix timestamp |
TO-UNIX-TIMESTAMP | Optional | Unix timestamp | Date/Time in unix timestamp, if not specified data will be taken till last available |
Schema | Function |
---|---|
schemas/View.json | Customizing your data output |
HTTP CODE | Description |
---|---|
200 | Success |
204 | No data for specified time period |
400 | Data over limit |
401 | Unauthorized |
403 | No permissions - No rights |
406 | Specified params are not acceptable |
Values are self explanatory.
# NORMAL
# Data and sensors come separated and can be connected using unique TAG
# Dates and data are on the same level
# 1_X_X_143_avg tag is = CH_MAC_SERIAL_CODE_AGGREGATION
{
"sensors": [
{
"name": "Wind direction",
"name_custom": false,
"decimals": 0,
"unit": "deg",
"ch": 1,
"chain": 1,
"code": 143,
"group": 16,
"serial": "X",
"mac": "X",
"vals": {
"min": 0,
"max": 360
},
"aggr": {
"avg": 1,
"last": 1
},
"registered": "2017-06-30 18:00:00"
},
{
"name": "Solar radiation",
"name_custom": false,
"decimals": 0,
"unit": "W/m2",
"ch": 2,
"chain": 1,
"code": 600,
"group": 4,
"serial": "X",
"mac": "X",
"vals": {
"min": 0,
"max": 32767
},
"aggr": {
"avg": 1
},
"registered": "2017-06-30 18:00:00"
},..
],
"data": [
{
"date": "2017-07-21 05:00:00",
"1_X_X_143_avg": 39,
"1_X_X_143_last": 39,
"2_X_X_600_avg": 0,
"4_X_X_30_last": 0,...
},
{
"date": "2017-07-21 05:15:00",
"1_X_X_143_avg": 117,
"1_X_X_143_last": 117,
"2_X_X_600_avg": 0,
"4_X_X_30_last": 0,...
},...
]
}
# OPTIMIZED - Recommended
# Data can come in several aggravations inside the sensor information AGGR
# Dates come separated from the data but are in the same order
# All other information is sensor related information
# We recommend this format because of its simplicity and output size is smaller then normal one
# 1_X_X_143 tag is = CH_MAC_SERIAL_CODE
{
"dates": [
"2017-07-21 05:00:00",
"2017-07-21 05:15:00",
"2017-07-21 05:30:00",
"2017-07-21 05:45:00",
"2017-07-21 06:00:00"
],
"data": {
"1_X_X_143": {
"name": "Wind direction",
"name_custom": false,
"decimals": 0,
"unit": "deg",
"ch": 1,
"code": 143,
"group": 16,
"serial": "X",
"mac": "X",
"vals": {
"min": 0,
"max": 360
},
"aggr": {
"avg": [
39,
117,
85,
74,
74
],
"last": [
39,
117,
85,
74,
74
]
},
"registered": "2017-06-30 18:00:00"
},
"2_X_X_600": {
"name": "Solar radiation",
"name_custom": false,
"decimals": 0,
"unit": "W/m2",
"ch": 2,
"code": 600,
"group": 4,
"serial": "X",
"mac": "X",
"vals": {
"min": 0,
"max": 32767
},
"aggr": {
"avg": [
0,
0,
0,
0,
0
]
},
"registered": "2017-06-30 18:00:00"
},...
}
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "POST";
$request = "/data/{{FORMAT}}/{{STATION-ID}}/{{DATA-GROUP}}/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP}}";
// Body that you send needs to be JSON schema validated
$body = [
"sensors" => [
"filter" => [
"sensor-506" => TRUE
]
]
];
$body = json_encode( $body );
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_POST, TRUE );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $body );
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
{
"properties": {
"description": "Pre-defined, combined or custom name",
"name": {
"type": "string"
},
"sensors": {
"properties": {
"filter": {
"description": "Filter by group, sensor, mac or serial and optionally specify aggregation",
"properties": {
"group-7": {
"items": {
"type": "string"
},
"type": "array",
"enum": [
"avg",
"min",
"max",
"sum",
"time",
"last",
"user"
]
},
"mac-MAC_ADDRESS": {
"type": "boolean"
},
"sensor-506": {
"items": {
"type": "string"
},
"type": "array",
"enum": [
"avg",
"min",
"max",
"sum",
"time",
"last",
"user"
]
},
"serial-SERIAL": {
"type": "boolean"
}
},
"type": "object"
},
"settings": {
"description": "Configure sensor output",
"properties": {
"group-7": {
"unit": "Custom unit",
"type": "string"
},
"sensor-506": {
"unit": "Custom unit",
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"data": {
"properties": {
"model": {
"description": "Disease model name",
"type": "string"
},
"sunrise_sunset": {
"description": "Get sunrise and sunset dates for specified period",
"type": "boolean"
},
"unit_system": {
"type": "string",
"description": "One of",
"enum": [
"imperial",
"metric"
]
}
},
"type": "object"
}
},
"type": "object"
}
{
# VIEW NAME: Pre-Defined, Combined, Custom
"name": "PRE-DEFINED, COMBINED OR CUSTOM ... NAME,
"sensors": {
"filter": {
# Filter out specific sensor
"sensor-506": 1,
# Filter out specific sensor and its aggregation
"sensor-506": [
"avg"
],
# Filter out specific sensors of a group
"group-7": 1,
# Filter out specific sensors of a group and its aggragation
"group-7": [
"avg"
],
# Filter out sensors on MAC
"mac-MAC_ADDRESS": true,
# Filter out sensors with Serial
"serial-SERIAL": true
},
"settings" : {
# Configure output of a sensor, by changing the unit manually
"sensor-506": [
"unit" : "sec"
],
# Configure output of a sensor group, by changing the unit manually
"group-7": [
"unit" : "sec"
]
}
},
"data": {
# UNIT SYSTEM: matric, imperial
"unit_system": "imperial",
# Sunrise and sunset dates
"sunrise_sunset" : true,
# DISEASE MODEL DATA
"model": "DISEASE-MODEL"
}
}
Retrieving forecast from your device. License is required so you are able to retrieve forecast data packages or images.
Forecast data packages can be combined using "PACKAGE-1__PACKAGE-2" as forecast option.
N/A
HTTP Method | Endpoint | URL Params | Function |
---|---|---|---|
GET | /forecast/{{STATION-ID}}/{{FORECAST-OPTION}} | STATION-ID | Forecast data package or image |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
FORECAST-OPTION | Required | DATA: basic-1h, basic-day, agro-1h, agro-day IMAGE: pictoprint, meteogram_agro, meteogram_one, meteogram_14day |
Get forecast data or selected image |
Reading forecast data. License is required so you are able to retrieve forecast data packages.
Forecast data packages can be combined using "PACKAGE-1__PACKAGE-2" as forecast option.
Specification | Value |
---|---|
method | GET |
request | /forecast/{{STATION-ID}}/{{FORECAST-OPTION}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
FORECAST-OPTION | Required | basic-1h, basic-day, agro-1h, agro-day | Get forecast data |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
401 | Unauthorized |
402 | License is required for this service |
403 | No permissions - No rights |
404 | Station not found |
406 | Specified params are not acceptable |
Values are self explanatory.
{
"metadata": {
"name": "",
"latitude": 15.64,
"longitude": 47.21,
"height": 761,
"timezone_abbrevation": "AST",
"utc_timeoffset": 3,
"modelrun_utc": "2017-07-24 00:00",
"modelrun_updatetime_utc": "2017-07-24 05:04"
},
"units": {
"time": "YYYY-MM-DD hh:mm",
"precipitation_probability": "percent",
"pressure": "hPa",
"relativehumidity": "percent",
"precipitation": "mm",
"temperature": "C",
"windspeed": "ms-1",
"winddirection": "degree"
},
"data_1h": {
"time": [
"2017-07-24 04:00",
"2017-07-24 05:00",
"2017-07-24 06:00",...
],
"precipitation": [
0,
0,
0,...
],
"snowfraction": [
0,
0,
0,...
],
"rainspot": [
"0000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000",...
],
"temperature": [
31.54,
30.55,
30.14,...
],...
}
}
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/forecast/{{STATION-ID}}/{{FORECAST-OPTION}}";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Getting forecast image. License is required so you are able to retrieve forecast image.
Specification | Value |
---|---|
method | GET |
request | /forecast/{{STATION-ID}}/{{FORECAST-OPTION}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
FORECAST-OPTION | Required | pictoprint, meteogram_agro, meteogram_one, meteogram_14day | Get forecast image |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
401 | Unauthorized |
402 | License is required for this service |
403 | No permissions - No rights |
404 | Station not found |
406 | Specified params are not acceptable |
Values are self explanatory.
URL_TO_DOWNLOAD_THE_IMAGE
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/forecast/{{STATION-ID}}/{{FORECAST-OPTION}}";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Retrieving disease model data. To do so license is required for most of them (exceptions are Evapotranspiration ).
List of supported disease models can be retrieved by using request system/diseases from which you use disease model KEY as NAME = KEY in the schema.
Calculations that do not require license are:
Schema | Function |
---|---|
schemas/Disease.json | Specifying which disease model or calculation |
HTTP Method | Endpoint | URL Params | Function |
---|---|---|---|
GET | /disease/{{STATION-ID}}/last/{{TIME-PERIOD}} | STATION-ID, TIME-PERIOD | Get last Evapotranspiration |
GET | /disease/{{STATION-ID}}/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP}} | STATION-ID, FROM-UNIX-TIMESTAMP, TO-UNIX-TIMESTAMP | Get Evapotranspiration for specified period |
POST | /disease/{{STATION-ID}}/last/{{TIME-PERIOD}} | STATION-ID, TIME-PERIOD | Get last specified disease model |
POST | /disease/{{STATION-ID}}/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP}} | STATION-ID, FROM-UNIX-TIMESTAMP, TO-UNIX-TIMESTAMP | Get specified disease model for period |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
TIME-PERIOD | Required | Xh, Xd, Xw, Xm, X | X = Number, h = hours, d = days, w = weeks, m = months |
FROM-UNIX-TIMESTAMP | Required | Unix timestamp | Date/Time in unix timestamp |
TO-UNIX-TIMESTAMP | Optional | Unix timestamp | Date/Time in unix timestamp, if not specified data will be taken till last available |
{
"properties": {
"description": "Disease model key",
"name": {
"type": "string"
}
},
"type": "object"
}
{
"name" : "DISEASE-KEY"
}
Retrieve last Evapotranspiration data that is calculated for your device.
NOTE that time period gives you flexibility:
You are limited to retrieve MAX 10.000 data points.
Specification | Value |
---|---|
method | GET |
request | /disease/{{STATION-ID}}/last/{{TIME-PERIOD}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
TIME-PERIOD | Required | Xh, Xd, Xw, Xm, X | X = Number, h = hours, d = days, w = weeks, m = months |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No data for specified time period |
400 | Data over limit |
401 | Unauthorized |
402 | License is required for this service |
403 | No permissions - No rights |
404 | Disease model not supported |
406 | Specified params are not acceptable |
Values are self explanatory.
[
{
"date": "2017-07-13 23:00:00",
"ETo[mm]": 5.3
},
{
"date": "2017-07-14 23:00:00",
"ETo[mm]": 1.3
},
{
"date": "2017-07-15 23:00:00",
"ETo[mm]": 2.6
},
{
"date": "2017-07-16 23:00:00",
"ETo[mm]": 3
}...
]
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/disease/{{{STATION-ID}}/last/{{TIME-PERIOD}}";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Retrieve Evapotranspiration data between specified time periods. Times from and to need to be specified in unix timestamp.
You are limited to retrieve MAX 10.000 data points.
Specification | Value |
---|---|
method | GET |
request | /disease/{{STATION-ID}}/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
FROM-UNIX-TIMESTAMP | Required | Unix timestamp | Date/Time in unix timestamp |
TO-UNIX-TIMESTAMP | Optional | Unix timestamp | Date/Time in unix timestamp, if not specified data will be taken till last available |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No data for specified time period |
400 | Data over limit |
401 | Unauthorized |
402 | License is required for this service |
403 | No permissions - No rights |
404 | Disease model not supported |
406 | Specified params are not acceptable |
Values are self explanatory.
[
{
"date": "2017-07-13 23:00:00",
"ETo[mm]": 5.3
},
{
"date": "2017-07-14 23:00:00",
"ETo[mm]": 1.3
},
{
"date": "2017-07-15 23:00:00",
"ETo[mm]": 2.6
},
{
"date": "2017-07-16 23:00:00",
"ETo[mm]": 3
}...
]
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/disease/{{STATION-ID}}/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP}}";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Retrieve last disease model data or calculation.
NOTE that time period gives you flexibility:
You are limited to retrieve MAX 10.000 data points.
Specification | Value |
---|---|
method | POST |
request | /disease/{{STATION-ID}}/last/{{TIME-PERIOD}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
TIME-PERIOD | Required | Xh, Xd, Xw, Xm, X | X = Number, h = hours, d = days, w = weeks, m = months |
Schema | Function |
---|---|
schemas/Disease.json | Specifying which disease model or calculation |
HTTP CODE | Description |
---|---|
200 | Success |
204 | No data for specified time period |
400 | Data over limit |
401 | Unauthorized |
402 | License is required for this service |
403 | No permissions - No rights |
404 | Disease model not supported |
406 | Specified params are not acceptable |
Values are self explanatory.
[
{
"date": "2017-07-24 10:00:00",
"Blight": 1,
"T Sum 3": 1154,
"Risk Sum": 400
},
{
"date": "2017-07-24 11:00:00",
"Blight": 1,
"T Sum 3": 1151,
"Risk Sum": 400
},
{
"date": "2017-07-24 12:00:00",
"Blight": 1,
"T Sum 3": 1150,
"Risk Sum": 400
},
{
"date": "2017-07-24 13:00:00",
"Blight": 1,
"T Sum 3": 1146,
"Risk Sum": 400
},
{
"date": "2017-07-24 14:00:00",
"Blight": 1,
"T Sum 3": 1142,
"Risk Sum": 400
}...
]
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "POST";
$request = "/disease/{{STATION-ID}}/last/{{TIME-PERIOD}}";
// Body that you send needs to be JSON schema validated
$body = [
"name" => "GeneralFireblight"
];
$body = json_encode( $body );
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_POST, TRUE );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $body );
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
{
"properties": {
"description": "Disease model key",
"name": {
"type": "string"
}
},
"type": "object"
}
{
"name" : "DISEASE-KEY"
}
Retrieve disease model data or calculation between specified time periods. Times from and to need to be specified in unix timestamp.
You are limited to retrieve MAX 10.000 data points.
Specification | Value |
---|---|
method | POST |
request | /disease/{{STATION-ID}}/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP }} |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
FROM-UNIX-TIMESTAMP | Required | Unix timestamp | Date/Time in unix timestamp |
TO-UNIX-TIMESTAMP | Optional | Unix timestamp | Date/Time in unix timestamp, if not specified data will be taken till last available |
Schema | Function |
---|---|
schemas/Disease.json | Specifying which disease model or calculation |
HTTP CODE | Description |
---|---|
200 | Success |
204 | No data for specified time period |
400 | Data over limit |
401 | Unauthorized |
402 | License is required for this service |
403 | No permissions - No rights |
404 | Disease model not supported |
406 | Specified params are not acceptable |
Values are self explanatory.
[
{
"date": "2017-07-24 10:00:00",
"Blight": 1,
"T Sum 3": 1154,
"Risk Sum": 400
},
{
"date": "2017-07-24 11:00:00",
"Blight": 1,
"T Sum 3": 1151,
"Risk Sum": 400
},
{
"date": "2017-07-24 12:00:00",
"Blight": 1,
"T Sum 3": 1150,
"Risk Sum": 400
},
{
"date": "2017-07-24 13:00:00",
"Blight": 1,
"T Sum 3": 1146,
"Risk Sum": 400
},
{
"date": "2017-07-24 14:00:00",
"Blight": 1,
"T Sum 3": 1142,
"Risk Sum": 400
}...
]
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "POST";
$request = "/disease/{{STATION-ID}}/from/{{FROM-UNIX-TIMESTAMP}}/to/{{{TO-UNIX-TIMESTAMP }}";
// Body that you send needs to be JSON schema validated
$body = [
"name" => "GeneralFireblight"
];
$body = json_encode( $body );
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_POST, TRUE );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $body );
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
{
"properties": {
"description": "Disease model key",
"name": {
"type": "string"
}
},
"type": "object"
}
{
"name" : "DISEASE-KEY"
}
If you are using OAuth 2.0 you are able to define multiple applications and register users to them. This enables you to overview/manage
your applications, users and stations.
If user belong to your application you are able to access their station information/data so you can offer support or consulting ... But remember that you are not able to modify the user itself or any other information that is considered private.
NOTE: This routes are only available if you are using OAuth 2.0 as authentication method
Schema | Function |
---|---|
schemas/UserInsert.json | Register new account |
schemas/UserStationInsert.json | Adding station to account |
schemas/UserPasswordReset.json | New password reset request |
schemas/UserPasswordUpdate.json | Password reset |
HTTP Method | Endpoint | URL Params | Function |
---|---|---|---|
GET | /dev/applications | N/A | List of applications |
GET | /dev/users/{{APP-ID}} | APP-ID | List of users of a application |
GET | /dev/stations/{{APP-ID}} | APP-ID | Stations of a application |
GET | /dev/user/{{USERNAME}}/stations | USERNAME | List of user stations |
POST | /dev/user/{{USERNAME}}/{{STATION-ID}}/{{STATION-KEY}} | USERNAME, STATION-ID, STATION-KEY | Adding new station to user |
DELETE | /dev/user/{{USERNAME}}/{{STATION-ID}} | USERNAME, STATION-ID | Remove station from user |
POST | /dev/user/{{APP-ID}} | APP-ID | Register new user to application |
GET | /dev/user/activate/{{ACTIVATION-KEY}} | ACTIVATION-KEY | Activate registered user account |
POST | /dev/user/{{APP-ID}}/password-reset | APP-ID | Request password reset |
POST | /dev/user/{{APP-ID}}/password-update/{{PASSWORD-KEY}} | APP-ID, PASSWORD-KEY | Change password |
Value | Optional/Required | Options | Description |
---|---|---|---|
APP-ID | Required | STRING | Unique identifier of a application |
USERNAME | Required | STRING | Account username |
STATION-ID | Required | STRING | Unique identifier of a device |
STATION-KEY | Required | Key 1, Key 2 | Key 1 = RW, Key 2 = R and are supplied with a device |
ACTIVATION-KEY | Required | STRING | Temporary activation key to activate account |
PASSWORD-KEY | Required | STRING | Temporary password key to change password |
Reading the list of applications.
Specification | Value |
---|---|
method | GET |
request | /dev/applications |
N/A
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No Applications |
401 | Unauthorized |
403 | No permissions - No rights |
Values are self explanatory.
[
"App name 1",
"App name 2",...
]
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/dev/applications";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Reading list users in the specified application.
Specification | Value |
---|---|
method | GET |
request | /dev/users/{{APP-ID}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
APP-ID | Required | STRING | Unique identifier of a application |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | You have no users for specified application |
401 | Unauthorized |
403 | No permissions - No rights |
Values are self explanatory.
[
{
"username": "USERNAME",
"usercode": NUMBER,
"salt": "",
"info": {
"name": "",
"lastname": "",
"title": null,
"email": "EMAIL",
"phone": null,
"cellphone": null,
"fax": null
},
"company": {
"name": "",
"profession": "",
"department": "",
"customer_id": null,
"vat_id": null
},
"address": {
"street": "",
"city": "",
"district": "",
"zip": NUMBER,
"country": ""
},
"settings": {
"language": "en"
},
"stations": [],
"activate_token": "",
"create_time": "",
"last_access": ""
},
{
"username": "USERNAME",
"usercode": NUMBER,
"salt": "",
"info": {
"name": "",
"lastname": "",
"title": null,
"email": "EMAIL",
"phone": null,
"cellphone": null,
"fax": null
},
"company": {
"name": "",
"profession": "",
"department": "",
"customer_id": null,
"vat_id": null
},
"address": {
"street": "",
"city": "",
"district": "",
"zip": NUMBER,
"country": ""
},
"settings": {
"language": "en"
},
"stations": [],
"activate_token": "",
"create_time": "",
"last_access": ""
},...
]
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/dev/users/{{APP-ID}}";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Reading list of station in the Application.
Specification | Value |
---|---|
method | GET |
request | /dev/stations/{{APP-ID}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
APP-ID | Required | STRING | Unique identifier of a application |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | You have no stations for specified application |
401 | Unauthorized |
403 | No permissions - No rights |
Values are self explanatory.
[
{
"name": {
"original": STRING
},
"rights": STRING,
"info": {
"device_id": "",
"device_name": "",
"uid": "",
"firmware": "",
"hardware": "",
"description": "",
"max_time": ""
},
"dates": {
"min_date": "",
"max_date": "",
"created_at": "",
"last_communication": ""
},
"position": {
"geo": {
"coordinates": [
NUMBER,
NUMBER
]
},
"altitude": NUMBER
},
"config": {
"timezone_offset": NUMBER,
"dst": false,
"precision_reduction": NUMBER,
"scheduler": NUMBER,
"fixed_transfer_interval": NUMBER,
"rain_monitor": NUMBER,
"water_level_monitor": NUMBER,
"data_interval": NUMBER,
"activity_mode": NUMBER,
"measuring_interval": NUMBER,
"logging_interval": NUMBER
},
"networking": {
"mnc": "",
"mcc": "",
"apn": null,
"username": null,
"password": null,
"country": "",
"provider": "",
"type": "",
"imei": null,
"simid": null
},
"warnings": {
"sms_numbers": [],
"sensors": [
"",
"",
"",
"",
""
]
},
"flags": {
"imeteopro": false
},
"users": [
...
]
},..
]
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/dev/stations/{{APP-ID}}";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Reading list of station in the Application.
Specification | Value |
---|---|
method | GET |
request | /dev/user/{{USER-ID}}/stations |
Value | Optional/Required | Options | Description |
---|---|---|---|
USER-ID | Required | STRING | Unique identifier of a user |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | You have no stations for specified user |
401 | Unauthorized |
403 | No permissions - No rights |
Values are self explanatory.
[
{
"name": {
"original": STRING
},
"rights": STRING,
"info": {
"device_id": "",
"device_name": "",
"uid": "",
"firmware": "",
"hardware": "",
"description": "",
"max_time": ""
},
"dates": {
"min_date": "",
"max_date": "",
"created_at": "",
"last_communication": ""
},
"position": {
"geo": {
"coordinates": [
NUMBER,
NUMBER
]
},
"altitude": NUMBER
},
"config": {
"timezone_offset": NUMBER,
"dst": false,
"precision_reduction": NUMBER,
"scheduler": NUMBER,
"fixed_transfer_interval": NUMBER,
"rain_monitor": NUMBER,
"water_level_monitor": NUMBER,
"data_interval": NUMBER,
"activity_mode": NUMBER,
"measuring_interval": NUMBER,
"logging_interval": NUMBER
},
"networking": {
"mnc": "",
"mcc": "",
"apn": null,
"username": null,
"password": null,
"country": "",
"provider": "",
"type": "",
"imei": null,
"simid": null
},
"warnings": {
"sms_numbers": [],
"sensors": [
"",
"",
"",
"",
""
]
},
"flags": {
"imeteopro": false
},
"users": [
...
]
},..
]
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/dev/user/{{USER-ID}}/stations";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Adding station to user account that belongs to your application. Key 1 and Key 2 are supplied with device itself.
If you add station with key 1 then that user has RW permissions for that station (configuration ... ) else with key 1 only read permissions.
RIGHTS:
Key 1: RW
key 2: R
Specification | Value |
---|---|
method | POST |
request | /dev/user/{{USERNAME}}/{{STATION-ID}}/{{STATION-KEY}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
USERNAME | Required | STRING | User name of a user that belongs to your application |
STATION-ID | Required | STRING | Unique identifier of a device |
STATION-KEY | Required | STRING | Unique key 1 or 2 of a device |
Schema | Function |
---|---|
schemas/UserStationInsert.json | Adding station to user account |
HTTP CODE | Description |
---|---|
200 | Success |
204 | User already has this station |
400 | Validation errors |
401 | Unauthorized |
403 | No permissions - No rights, station id or key is incorrect |
Values are self explanatory.
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "POST";
$request = "/dev/user/{{USERNAME}}/{{STATION-ID}}/{{STATION-KEY}}";
// Body that you send needs to be JSON schema validated
$body = [
"name" => "Custom station name"
];
$body = json_encode( $body );
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_POST, TRUE );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $body );
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
{
"title": "User station insert",
"description" : "Add a station to an user",
"type": "object",
"properties": {
"name": {
"type": "string",
"pattern": "^[a-zA-Z\\s\\d]{0,35}$",
"description": "Only characters, numbers, spaces and max length 35"
}
},
"additionalProperties": false
}
{
"name" : "Custom name of a station"
}
Removing station from account that belongs to your application.
Specification | Value |
---|---|
method | DELETE |
request | /dev/user/{{USERNAME}}/{{STATION-ID}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
USERNAME | Required | STRING | Username of account that belongs to your application |
STATION-ID | Required | STRING | Unique identifier of a device |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | Nothing to be removed |
401 | Unauthorized - Login required |
403 | No permissions |
Values are self explanatory.
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "DELETE";
$request = "/dev/user/{{USERNAME}}/{{STATION-ID}}";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Register a new user to your application. Activation key is returned after successful registration.
By default account is blocked and activation key has to be used to activate it. To do so
you need to design a process of account activation (send email to a client with link to activate his account).
To finish the process of activation on your side all you need to do is call /dev/user/activate/{{ACTIVATION-KEY}}.
Activation key is being used for identity validation.
Specification | Value |
---|---|
method | POST |
request | /dev/user/{{APP-ID}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
APP-ID | Required | STRING | Unique identifier of a application |
Schema | Function |
---|---|
schemas/UserInsert.json | Register new account |
HTTP CODE | Description |
---|---|
200 | Success |
400 | Validation errors |
401 | Unauthorized |
403 | No permissions - No rights |
409 | Username already exists |
Values are self explanatory.
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "POST";
$request = "{{api}}/dev/user/{{APP-ID}}";
// Body that you send needs to be JSON schema validated
$body = [
"username" => "USERNAME",
"password" => "PASSWORD",
"info" => [
"name" => "",
"lastname" => "",
"title" => "",
"email"=> "",
"phone" => "",
"cellphone" => "",
"fax" => ""
],
"company" => [
"name" => "",
"profession" => "",
"department" => "",
"customer_id" => "",
"vat_id" => ""
],
"address" => [
"street" => "",
"city" => "",
"district" => "",
"zip" => "",
"country" => ""
],
"settings" => [
"language" => "en",
"newsletter" => true
]
];
$body = json_encode( $body );
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_POST, TRUE );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $body );
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
{
"title": "User Insert Schema",
"type": "object",
"properties": {
"username": {
"type": "string",
"pattern": "(*UTF8)^[[:alnum:]]+(?:[-_ ]?[[:alnum:]]+)*$",
"description": "Chars, Numbers, space, _, - but no other special chars"
},
"password": {
"type": "string",
"minLength": 4,
"description": "Password"
},
"old_password": {
"type": "string",
"description": "For old Fieldclimate send password without encoding. Temporary solution."
},
"info": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"lastname": {
"type": "string"
},
"title": {
"type": "string"
},
"email": {
"type": "string",
"format": "email"
},
"phone": {
"type": "string"
},
"cellphone": {
"type": "string"
},
"fax": {
"type": "string"
}
},
"required": [
"name",
"lastname",
"email"
],
"additionalProperties": false,
"description": "Data updated as whole object will overwrite whole set in database"
},
"company": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"profession": {
"type": "string"
},
"department": {
"type": "string"
},
"customer_id": {
"type": "integer"
},
"vat_id": {
"type": "string"
}
},
"required": [
"name"
],
"additionalProperties": false,
"description": "Data updated as whole object will overwrite whole set in database"
},
"address": {
"type": "object",
"properties": {
"street": {
"type": "string"
},
"city": {
"type": "string"
},
"district": {
"type": "string"
},
"zip": {
"type": "string"
},
"country": {
"type": "string"
}
},
"required": [
"country"
],
"additionalProperties": false,
"description": "Data updated as whole object will overwrite whole set in database"
},
"settings": {
"type": "object",
"properties": {
"language": {
"type": "string",
"pattern": "^[a-z]{2,2}$"
},
"newsletter": {
"type": "boolean"
}
},
"required": [
"language"
],
"additionalProperties": false,
"description": "Language has to be in ISO 639-1 format. Data updated as whole object will overwrite whole set in database"
}
},
"required": [
"username",
"password",
"info",
"settings"
],
"additionalProperties": false,
"description": "additionalProperties means that no new property can be created ... Data updated as whole object will overwrite whole set in database.Required property needs to be specified. Pattern is pattern in regex"
}
{
"username" : "Username",
"password" : "Password",
"info" : {
"name" : "Name",
"lastname" : "Last name",
"email": "Email"
},
"settings" : {
"language" : "en",
"newsletter": true
}
}
Activate registered user account after the call /dev/user/{{APP-ID}} from which you will
receive activation key upon successful registration.
Specification | Value |
---|---|
method | GET |
request | /dev/user/activate/{{ACTIVATION-KEY}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
ACTIVATION-KEY | Required | STRING | Temporary activation key to activate account |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
401 | Unauthorized |
403 | No permissions - No rights |
Values are self explanatory.
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/user/activate/{{ACTIVATION-KEY}}";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Requesting application to change password of a user that belongs to your application.
Password key is returned which is used to change old password with new one. Intended process is that password key is send to users email in combination with URL and then user is able to change his password by following the URL.
When user follows the URL back to your site all you need to do is proceed with call /dev/user/{{APP-ID}}/password-update/{{PASSWORD-KEY}} which enables password change.
Password key is used for validation of identity.
Specification | Value |
---|---|
method | POST |
request | /dev/user/{{APP-ID}}/password-reset |
Value | Optional/Required | Options | Description |
---|---|---|---|
APP-ID | Required | STRING | Unique identifier of a application |
Schema | Function |
---|---|
schemas/UserPasswordReset.json | New password reset request |
HTTP CODE | Description |
---|---|
200 | Success |
400 | Validation errors |
401 | Unauthorized |
403 | No permissions - No rights, station id or key is incorrect |
404 | User does not exist |
Values are self explanatory.
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "POST";
$request = "/dev/user/{{APP-ID}}/password-reset";
// Body that you send needs to be JSON schema validated
$body = [
"username" => "Username of account you wish to reset"
];
$body = json_encode( $body );
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_POST, TRUE );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $body );
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
{
"title": "User password reset",
"description": "Reset a password for specific user",
"type": "object",
"properties": {
"username": {
"type": "string",
"pattern": "(*UTF8)^[[:alnum:]]+(?:[-_ ]?[[:alnum:]]+)*$",
"description": "Chars, Numbers, space, _, - but no other special chars"
}
},
"additionalProperties": false
}
{
"username":"Username"
}
Changing password of user account. You need to acquire password key from call /dev/user/{{APP-ID}}/password-reset.
Specification | Value |
---|---|
method | POST |
request | /dev/user/{{APP-ID}}/password-update/{{PASSWORD-KEY}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
APP-ID | Required | STRING | Unique identifier of a application |
PASSWORD-KEY | Required | STRING | Temporary password key to change password |
Schema | Function |
---|---|
schemas/UserPasswordUpdate.json | Password reset |
HTTP CODE | Description |
---|---|
200 | Success |
400 | Validation errors |
401 | Unauthorized |
403 | No permissions - No rights |
Values are self explanatory.
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "POST";
$request = "/user/{{APP-ID}}/password-update/{{PASSWORD-KEY}}";
// Body that you send needs to be JSON schema validated
$body = [
"password" => "Password",
"password_repeat" => "Password repeat"
];
$body = json_encode( $body );
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_POST, TRUE );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $body );
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
{
"title": "User password update",
"description": "Update user password",
"type": "object",
"properties": {
"password": {
"type": "string",
"minLength": 4,
"description": "Password"
},
"password_repeat": {
"type": "string",
"minLength": 4,
"description": "Repeat Password"
}
},
"additionalProperties": false
}
{
"password":"Password",
"password_repeat": "Password repeat"
}
Retrieving and customizing your charts. Please go to Data section of documentation where we describe how views are working, because Chart is following the same principle.
You are limited to retrieve MAX 10.000 data points.
Schema | Function |
---|---|
schemas/View.json | Customizing your data output |
HTTP Method | Endpoint | URL Params | Function |
---|---|---|---|
GET | /chart/{{TYPE}}/{{STATION-ID}}/{{DATA-GROUP}}/last/{{TIME-PERIOD}} | TYPE, STATION-ID, DATA-GROUP, TIME-PERIOD | Charting last data |
GET | /chart/{{TYPE}}/{{STATION-ID}}/{{DATA-GROUP}}/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP}} | TYPE, STATION-ID, DATA-GROUP, FROM-UNIX-TIMESTAMP, TO-UNIX-TIMESTAMP | Charting for period |
POST | /chart/{{TYPE}}/{{STATION-ID}}/{{DATA-GROUP}}/last/{{TIME-PERIOD}} | TYPE, STATION-ID, DATA-GROUP, TIME-PERIOD | Charting customized last data |
POST | /chart/{{TYPE}}/{{STATION-ID}}/{{DATA-GROUP}}/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP}} | TYPE, STATION-ID, DATA-GROUP, FROM-UNIX-TIMESTAMP, TO-UNIX-TIMESTAMP | Charting customized for period |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
TYPE | Optional | image, images, highchart | Image, multiple images or highchart options |
DATA-GROUP | Required | raw, hourly, daily, monthly | Device data grouped |
TIME-PERIOD | Required | Xh, Xd, Xw, Xm, X | X = Number, h = hours, d = days, w = weeks, m = months |
FROM-UNIX-TIMESTAMP | Required | Unix timestamp | Date/Time in unix timestamp |
TO-UNIX-TIMESTAMP | Optional | Unix timestamp | Date/Time in unix timestamp, if not specified data will be taken till last available |
# 1. Filter data 5 - Wind speed, 4 - Leaf Wetness, 506 - Air temperature, 507 - Relative humidity
# 2. Data comes in imperial units
{
"sensors": {
"filter": {
"sensor-5": true,
"sensor-4": true,
"sensor-506": true,
"sensor-507": true
}
},
"data": {
"unit_system": "imperial"
}
}
{
"name":"disease, GeneralFireblight"
}
{
"properties": {
"description": "Pre-defined, combined or custom name",
"name": {
"type": "string"
},
"sensors": {
"properties": {
"filter": {
"description": "Filter by group, sensor, mac or serial and optionally specify aggregation",
"properties": {
"group-7": {
"items": {
"type": "string"
},
"type": "array",
"enum": [
"avg",
"min",
"max",
"sum",
"time",
"last",
"user"
]
},
"mac-MAC_ADDRESS": {
"type": "boolean"
},
"sensor-506": {
"items": {
"type": "string"
},
"type": "array",
"enum": [
"avg",
"min",
"max",
"sum",
"time",
"last",
"user"
]
},
"serial-SERIAL": {
"type": "boolean"
}
},
"type": "object"
},
"settings": {
"description": "Configure sensor output",
"properties": {
"group-7": {
"unit": "Custom unit",
"type": "string"
},
"sensor-506": {
"unit": "Custom unit",
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"data": {
"properties": {
"model": {
"description": "Disease model name",
"type": "string"
},
"sunrise_sunset": {
"description": "Get sunrise and sunset dates for specified period",
"type": "boolean"
},
"unit_system": {
"type": "string",
"description": "One of",
"enum": [
"imperial",
"metric"
]
}
},
"type": "object"
}
},
"type": "object"
}
{
# VIEW NAME: Pre-Defined, Combined, Custom
"name": "PRE-DEFINED, COMBINED OR CUSTOM ... NAME,
"sensors": {
"filter": {
# Filter out specific sensor
"sensor-506": 1,
# Filter out specific sensor and its aggregation
"sensor-506": [
"avg"
],
# Filter out specific sensors of a group
"group-7": 1,
# Filter out specific sensors of a group and its aggragation
"group-7": [
"avg"
],
# Filter out sensors on MAC
"mac-MAC_ADDRESS": true,
# Filter out sensors with Serial
"serial-SERIAL": true
},
"settings" : {
# Configure output of a sensor, by changing the unit manually
"sensor-506": [
"unit" : "sec"
],
# Configure output of a sensor group, by changing the unit manually
"group-7": [
"unit" : "sec"
]
}
},
"data": {
# UNIT SYSTEM: matric, imperial
"unit_system": "imperial",
# Sunrise and sunset dates
"sunrise_sunset" : true,
# DISEASE MODEL DATA
"model": "DISEASE-MODEL"
}
}
Retrieve chart from last data that device sends. We recommend calling /data/{{STATION-ID}} first so you can see if
there is any new data.
NOTE that time period gives you flexibility:
You are limited to retrieve MAX 10.000 data points.
Specification | Value |
---|---|
method | GET |
request | /chart/{{TYPE}}/{{STATION-ID}}/{{DATA-GROUP}}/last/{{TIME-PERIOD}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
TYPE | Optional | image, images, highchart | Type of output |
STATION-ID | Required | STRING | Unique identifier of a device |
DATA-GROUP | Required | raw, hourly, daily, monthly | Device data grouped |
TIME-PERIOD | Required | Xh, Xd, Xw, Xm, X | X = Number, h = hours, d = days, w = weeks, m = months |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No data for specified time period |
400 | Data over limit |
401 | Unauthorized |
403 | No permissions - No rights |
406 | Specified params are not acceptable |
Values are self explanatory.
IMAGE PATH
IMAGES PATH
HIGHCHART
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/chart/{{TYPE}}/{{STATION-ID}}/{{DATA-GROUP}}/last/{{TIME-PERIOD}}";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Charting data between specified time periods. We recommend calling /data/{{STATION-ID}} first so you can see if
there is any new data. Times from and to need to be specified in unix timestamp.
You are limited to retrieve MAX 10.000 data points.
Specification | Value |
---|---|
method | GET |
request | /chart/{{TYPE}}/{{STATION-ID}}/{{DATA-GROUP}}/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP }} |
Value | Optional/Required | Options | Description |
---|---|---|---|
TYPE | Optional | image, images, highchart | Type of output |
STATION-ID | Required | STRING | Unique identifier of a device |
DATA-GROUP | Required | raw, hourly, daily, monthly | Device data grouped |
FROM-UNIX-TIMESTAMP | Required | Unix timestamp | Date/Time in unix timestamp |
TO-UNIX-TIMESTAMP | Optional | Unix timestamp | Date/Time in unix timestamp, if not specified data will be taken till last available |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No data for specified time period |
400 | Data over limit |
401 | Unauthorized |
403 | No permissions - No rights |
406 | Specified params are not acceptable |
Values are self explanatory.
IMAGE PATH
IMAGES PATH
HIGHCHART
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/chart/{{TYPE}}/{{STATION-ID}}/{{DATA-GROUP}}/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP}}";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Retrieve customized chart from last data that device sends. We recommend calling /data/{{STATION-ID}} first so you can see if
there is any new data.
NOTE that time period gives you flexibility:
You are limited to retrieve MAX 10.000 data points.
Specification | Value |
---|---|
method | POST |
request | /chart/{{TYPE}}/{{STATION-ID}}/{{DATA-GROUP}}/last/{{TIME-PERIOD}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
TYPE | Optional | image, images, highchart | Type of output |
STATION-ID | Required | STRING | Unique identifier of a device |
DATA-GROUP | Required | raw, hourly, daily, monthly | Device data grouped |
TIME-PERIOD | Required | Xh, Xd, Xw, Xm, X | X = Number, h = hours, d = days, w = weeks, m = months |
Schema | Function |
---|---|
schemas/View.json | Customizing your data output |
HTTP CODE | Description |
---|---|
200 | Success |
204 | No data for specified time period |
400 | Data over limit |
401 | Unauthorized |
403 | No permissions - No rights |
406 | Specified params are not acceptable |
Values are self explanatory.
IMAGE PATH
IMAGES PATH
HIGHCHART
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "POST";
$request = "/chart/{{TYPE}}/{{STATION-ID}}/{{DATA-GROUP}}/last/{{TIME-PERIOD}}";
// Body that you send needs to be JSON schema validated
$body = [
"sensors" => [
"filter" => [
"sensor-506" => TRUE
]
]
];
$body = json_encode( $body );
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_POST, TRUE );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $body );
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
{
"properties": {
"description": "Pre-defined, combined or custom name",
"name": {
"type": "string"
},
"sensors": {
"properties": {
"filter": {
"description": "Filter by group, sensor, mac or serial and optionally specify aggregation",
"properties": {
"group-7": {
"items": {
"type": "string"
},
"type": "array",
"enum": [
"avg",
"min",
"max",
"sum",
"time",
"last",
"user"
]
},
"mac-MAC_ADDRESS": {
"type": "boolean"
},
"sensor-506": {
"items": {
"type": "string"
},
"type": "array",
"enum": [
"avg",
"min",
"max",
"sum",
"time",
"last",
"user"
]
},
"serial-SERIAL": {
"type": "boolean"
}
},
"type": "object"
},
"settings": {
"description": "Configure sensor output",
"properties": {
"group-7": {
"unit": "Custom unit",
"type": "string"
},
"sensor-506": {
"unit": "Custom unit",
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"data": {
"properties": {
"model": {
"description": "Disease model name",
"type": "string"
},
"sunrise_sunset": {
"description": "Get sunrise and sunset dates for specified period",
"type": "boolean"
},
"unit_system": {
"type": "string",
"description": "One of",
"enum": [
"imperial",
"metric"
]
}
},
"type": "object"
}
},
"type": "object"
}
{
# VIEW NAME: Pre-Defined, Combined, Custom
"name": "PRE-DEFINED, COMBINED OR CUSTOM ... NAME,
"sensors": {
"filter": {
# Filter out specific sensor
"sensor-506": 1,
# Filter out specific sensor and its aggregation
"sensor-506": [
"avg"
],
# Filter out specific sensors of a group
"group-7": 1,
# Filter out specific sensors of a group and its aggragation
"group-7": [
"avg"
],
# Filter out sensors on MAC
"mac-MAC_ADDRESS": true,
# Filter out sensors with Serial
"serial-SERIAL": true
},
"settings" : {
# Configure output of a sensor, by changing the unit manually
"sensor-506": [
"unit" : "sec"
],
# Configure output of a sensor group, by changing the unit manually
"group-7": [
"unit" : "sec"
]
}
},
"data": {
# UNIT SYSTEM: matric, imperial
"unit_system": "imperial",
# Sunrise and sunset dates
"sunrise_sunset" : true,
# DISEASE MODEL DATA
"model": "DISEASE-MODEL"
}
}
Charting customized data between specified time periods. We recommend calling /data/{{STATION-ID}} first so you can see if
there is any new data. Times from and to need to be specified in unix timestamp.
You are limited to retrieve MAX 10.000 data points.
Specification | Value |
---|---|
method | POST |
request | /chart/{{TYPE}}/{{STATION-ID}}/{{DATA-GROUP}}/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP }} |
Value | Optional/Required | Options | Description |
---|---|---|---|
TYPE | Optional | image, images, highchart | Type of output |
STATION-ID | Required | STRING | Unique identifier of a device |
DATA-GROUP | Required | raw, hourly, daily, monthly | Device data grouped |
FROM-UNIX-TIMESTAMP | Required | Unix timestamp | Date/Time in unix timestamp |
TO-UNIX-TIMESTAMP | Optional | Unix timestamp | Date/Time in unix timestamp, if not specified data will be taken till last available |
Schema | Function |
---|---|
schemas/View.json | Customizing your data output |
HTTP CODE | Description |
---|---|
200 | Success |
204 | No data for specified time period |
400 | Data over limit |
401 | Unauthorized |
403 | No permissions - No rights |
406 | Specified params are not acceptable |
Values are self explanatory.
IMAGE PATH
IMAGES PATH
HIGHCHART
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "POST";
$request = "/chart/{{TYPE}}/{{STATION-ID}}/{{DATA-GROUP}}/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP}}";
// Body that you send needs to be JSON schema validated
$body = [
"sensors" => [
"filter" => [
"sensor-506" => TRUE
]
]
];
$body = json_encode( $body );
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_POST, TRUE );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $body );
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
{
"properties": {
"description": "Pre-defined, combined or custom name",
"name": {
"type": "string"
},
"sensors": {
"properties": {
"filter": {
"description": "Filter by group, sensor, mac or serial and optionally specify aggregation",
"properties": {
"group-7": {
"items": {
"type": "string"
},
"type": "array",
"enum": [
"avg",
"min",
"max",
"sum",
"time",
"last",
"user"
]
},
"mac-MAC_ADDRESS": {
"type": "boolean"
},
"sensor-506": {
"items": {
"type": "string"
},
"type": "array",
"enum": [
"avg",
"min",
"max",
"sum",
"time",
"last",
"user"
]
},
"serial-SERIAL": {
"type": "boolean"
}
},
"type": "object"
},
"settings": {
"description": "Configure sensor output",
"properties": {
"group-7": {
"unit": "Custom unit",
"type": "string"
},
"sensor-506": {
"unit": "Custom unit",
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"data": {
"properties": {
"model": {
"description": "Disease model name",
"type": "string"
},
"sunrise_sunset": {
"description": "Get sunrise and sunset dates for specified period",
"type": "boolean"
},
"unit_system": {
"type": "string",
"description": "One of",
"enum": [
"imperial",
"metric"
]
}
},
"type": "object"
}
},
"type": "object"
}
{
# VIEW NAME: Pre-Defined, Combined, Custom
"name": "PRE-DEFINED, COMBINED OR CUSTOM ... NAME,
"sensors": {
"filter": {
# Filter out specific sensor
"sensor-506": 1,
# Filter out specific sensor and its aggregation
"sensor-506": [
"avg"
],
# Filter out specific sensors of a group
"group-7": 1,
# Filter out specific sensors of a group and its aggragation
"group-7": [
"avg"
],
# Filter out sensors on MAC
"mac-MAC_ADDRESS": true,
# Filter out sensors with Serial
"serial-SERIAL": true
},
"settings" : {
# Configure output of a sensor, by changing the unit manually
"sensor-506": [
"unit" : "sec"
],
# Configure output of a sensor group, by changing the unit manually
"group-7": [
"unit" : "sec"
]
}
},
"data": {
# UNIT SYSTEM: matric, imperial
"unit_system": "imperial",
# Sunrise and sunset dates
"sunrise_sunset" : true,
# DISEASE MODEL DATA
"model": "DISEASE-MODEL"
}
}
All the information that is related to your camera device.
N/A
HTTP Method | Endpoint | URL Params | Function |
---|---|---|---|
GET | /camera/{{STATION-ID}}/photos/info | STATION-ID | Read station information |
GET | /camera/{{STATION-ID}}/photos/last/{{AMOUNT}}/{{CAMERA}} | STATION-ID, AMOUNT, CAMERA | Last amount of pictures |
GET | /camera/{{STATION-ID}}/photos/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP}}/{{CAMERA}} | STATION-ID, FROM-UNIX-TIMESTAMP, TO-UNIX-TIMESTAMP, CAMERA | Retrieve pictures for specified period |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
AMOUNT | Required | INTEGER | Amount of last pictures you wish to have |
CAMERA | Optional | 0, 1, 2 | 0 - Both cameras, 1 - Wide Camera, 2 - Zoom Camera |
FROM-UNIX-TIMESTAMP | Optional | Unix timestamp | Date/Time in unix timestamp |
TO-UNIX-TIMESTAMP | Optional | Unix timestamp | Date/Time in unix timestamp |
Retrieve min and max date of device data availability. This request can be used to check if device has sent new data which you
can retrieve, by just memorizing last date and compare it with current one.
Specification | Value |
---|---|
method | GET |
request | /camera/{{STATION-ID}}/photos/info |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No data |
401 | Unauthorized |
403 | No permissions - No rights |
406 | Device specified is not camera device |
Values are self explanatory.
{
"dates": {
"first_picture": {
"date": "YYYY-MM-DD HH:MM:SS.MSC",
"timezone_type": 1,
"timezone": "+00:00"
},
"last_picture": {
"date": "YYYY-MM-DD HH:MM:SS.MSC",
"timezone_type": 1,
"timezone": "+00:00"
}
}
}
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/camera/YOUR-CAMERA-STATION/photos/info";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Retrieve last data that device sends.
Specification | Value |
---|---|
method | GET |
request | /camera/{{STATION-ID}}/photos/last/{{AMOUNT}}/{{CAMERA}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
AMOUNT | Required | INTEGER | Amount of last pictures you wish to have |
CAMERA | Optional | 0, 1, 2 | 0 - Both cameras, 1 - Wide Camera, 2 - Zoom Camera |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No data |
401 | Unauthorized |
403 | No permissions - No rights |
406 | Device specified is not camera device or specified params are not acceptable |
Values are self explanatory.
[
{
"time": "DATE-TIME",
"nm": "STATION-ID",
"cam_id": 1,
"pic_id": 456,
"filename": "PATH-TO-RAW-FILE",
"rectangles": [
{
"x_min": 0.47980349344978,
"y_min": 0.082605531295488,
"x_max": 0.50982532751092,
"y_max": 0.122634643377,
"probability": 1,
"label": "moth",
"generated_by": "system"
},
{
"x_min": 0.2953056768559,
"y_min": 0.13937409024745,
"x_max": 0.3367903930131,
"y_max": 0.19468704512373,
"probability": 1,
"label": "moth",
"generated_by": "system"
},
...
],
"url": "PATH-TO-THE-JPG-IMAGE",
"urlPNG": "PATH-TO-THE-PNG-IMAGE",
"thumb": "PATH-TO-THE-PNG-IMAGE-THUMB"
},
...
]
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/camera/{{STATION-ID}}/photos/last/{{AMOUNT}}/{{CAMERA}}";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;
Retrieve photos between specified period that device sends.
Specification | Value |
---|---|
method | GET |
request | /camera/{{STATION-ID}}/photos/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP}}/{{CAMERA}} |
Value | Optional/Required | Options | Description |
---|---|---|---|
STATION-ID | Required | STRING | Unique identifier of a device |
CAMERA | Optional | 0, 1, 2 | 0 - Both cameras, 1 - Wide Camera, 2 - Zoom Camera |
FROM-UNIX-TIMESTAMP | Optional | Unix timestamp | Date/Time in unix timestamp |
TO-UNIX-TIMESTAMP | Optional | Unix timestamp | Date/Time in unix timestamp |
N/A
HTTP CODE | Description |
---|---|
200 | Success |
204 | No data |
401 | Unauthorized |
403 | No permissions - No rights |
406 | Device specified is not camera device or specified params are not acceptable |
Values are self explanatory.
[
{
"time": "DATE-TIME",
"nm": "STATION-ID",
"cam_id": 1,
"pic_id": 456,
"filename": "PATH-TO-RAW-FILE",
"rectangles": [
{
"x_min": 0.47980349344978,
"y_min": 0.082605531295488,
"x_max": 0.50982532751092,
"y_max": 0.122634643377,
"probability": 1,
"label": "moth",
"generated_by": "system"
},
{
"x_min": 0.2953056768559,
"y_min": 0.13937409024745,
"x_max": 0.3367903930131,
"y_max": 0.19468704512373,
"probability": 1,
"label": "moth",
"generated_by": "system"
},
...
],
"url": "PATH-TO-THE-JPG-IMAGE",
"urlPNG": "PATH-TO-THE-PNG-IMAGE",
"thumb": "PATH-TO-THE-PNG-IMAGE-THUMB"
},
...
]
// Clients public and private key provided by service provider
$public_key = "PROVIDED BY SERVICE PROVIDER";
$private_key = "PROVIDED BY SERVICE PROVIDER";
// Define the request parameter's
$method = "GET";
$request = "/camera/{{STATION-ID}}/photos/from/{{FROM-UNIX-TIMESTAMP}}/to/{{TO-UNIX-TIMESTAMP}}/{{CAMERA}}";
$timestamp = gmdate('D, d M Y H:i:s T'); // Date as per RFC2616 - Wed, 25 Nov 2014 12:45:26 GMT
// Creating content to sign with private key
$content_to_sign = $method.$request.$timestamp.$public_key;
// Hash content to sign into HMAC signature
$signature = hash_hmac("sha256", $content_to_sign, $private_key);
// Add required headers
// Authorization: hmac public_key:signature
// Date: Wed, 25 Nov 2014 12:45:26 GMT
$headers = [
"Accept: application/json",
"Authorization: hmac {$public_key}:{$signature}",
"Date: {$timestamp}"
];
// Prepare and make https request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fieldclimate.com/THIS-VERSION" . $request);
// SSL important
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
// Parse response as json and work on it ..
echo $output. PHP_EOL;