The following samples illustrate how to use the devices discovery service to obtain the deviceCode from the service response. Use the deviceCode to request data using the dataProductDelivery service.


This example returns all Devices and prints the results.

import requests
import json
 
url = 'https://data.oceannetworks.ca/api/devices'
parameters = {'method':'get',
			'token':'YOUR_TOKEN_HERE'} # replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
 
response = requests.get(url,params=parameters)
 
if (response.ok):
	devices= json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for device in devices:
		print(device,'\n ')
else:
	if(response.status_code == 400):
		error = json.loads(str(response.content,'utf-8'))
		print(error) # json response contains a list of errors, with an errorMessage and parameter
	else:
		print ('Error {} - {}'.format(response.status_code,response.reason))



url = ['https://data.oceannetworks.ca/api/devices' ...
        '?method=get' ...
        '&token=YOUR_TOKEN_HERE'];                          %replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
     
request = matlab.net.http.RequestMessage;
uri = matlab.net.URI(url);
options = matlab.net.http.HTTPOptions('ConnectTimeout',60);
 
response = send(request,uri,options);
 
if (response.StatusCode == 200)    % HTTP Status - OK
    devices = response.Body.Data;
    for i=1:numel(devices)
        device = devices(i);
        disp(device);
    end
elseif (response.StatusCode == 400) % HTTP Status - Bad Request
    disp(response.Body.Data.errors);
else % all other HTTP Statuses
    disp(char(response.StatusLine));
end


library(httr)
r <- GET("https://data.oceannetworks.ca/api/devices", 
         query = list(method="get", 
                      token="YOUR_TOKEN_HERE")) #>replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.

if (http_error(r)) {
  if (r$status_code == 400){
    error = content(r)
    str(error)
  } else {
    str(http_status(r)$message)
  }
} else {
  devices = content(r)
  for (device in devices){
    str(device)
  }
}



This example returns the device with deviceCode 'NORTEKAQDPRO8398' and prints the results. The deviceCode filter is case sensitive and must match a valid deviceCode exactly.

Parameters:

  • deviceCode=NORTEKAQDPRO8398
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/devices'
parameters = {'method':'get',
			'token':'YOUR_TOKEN_HERE', # replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
			'deviceCode':'NORTEKAQDPRO8398'}
 
response = requests.get(url,params=parameters)
 
if (response.ok):
	devices = json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for device in devices:
		print(device,'\n ')
else:
	if(response.status_code == 400):
		error = json.loads(str(response.content,'utf-8'))
		print(error) # json response contains a list of errors, with an errorMessage and parameter
	else:
		print ('Error {} - {}'.format(response.status_code,response.reason))



url = ['https://data.oceannetworks.ca/api/devices' ...
        '?method=get' ...
        '&token=YOUR_TOKEN_HERE' ...           %replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
        '&deviceCode=NORTEKAQDPRO8398'];

request = matlab.net.http.RequestMessage;
uri = matlab.net.URI(url);
options = matlab.net.http.HTTPOptions('ConnectTimeout',60);
 
response = send(request,uri,options);
 
if (response.StatusCode == 200)    % HTTP Status - OK
    devices = response.Body.Data;
    for i=1:numel(devices)
        device = devices(i);
        disp(device);
    end
elseif (response.StatusCode == 400) % HTTP Status - Bad Request
    disp(response.Body.Data.errors);
else % all other HTTP Statuses
    disp(char(response.StatusLine));
end


library(httr)
r <- GET("https://data.oceannetworks.ca/api/devices", 
         query = list(method="get", 
                      token="YOUR_TOKEN_HERE", #>replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
                      deviceCode="NORTEKAQDPRO8398"))

if (http_error(r)) {
  if (r$status_code == 400){
    error = content(r)
    str(error)
  } else {
    str(http_status(r)$message)
  }
} else {
  devices = content(r)
  for (device in devices){
    str(device)
  }
}



This example returns all Devices with 'jasco' in the name and prints the results. The deviceName filter is NOT case sensitive, so capitalized 'JASCO' will also be returned.

Parameters:

  • locationName=underwater
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/devices'
parameters = {'method':'get',
			'token':'YOUR_TOKEN_HERE', # replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
			'deviceName':'jasco'}
 
response = requests.get(url,params=parameters)
 
if (response.ok):
	devices = json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for device in devices:
		print(device,'\n ')
else:
	if(response.status_code == 400):
		error = json.loads(str(response.content,'utf-8'))
		print(error) # json response contains a list of errors, with an errorMessage and parameter
	else:
		print ('Error {} - {}'.format(response.status_code,response.reason))



url = ['https://data.oceannetworks.ca/api/devices' ...
        '?method=get' ...
        '&token=YOUR_TOKEN_HERE' ...           %replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
        '&deviceName=jasco'];

request = matlab.net.http.RequestMessage;
uri = matlab.net.URI(url);
options = matlab.net.http.HTTPOptions('ConnectTimeout',60);
 
response = send(request,uri,options);
 
if (response.StatusCode == 200)    % HTTP Status - OK
    devices = response.Body.Data;
    for i=1:numel(devices)
        device = devices(i);
        disp(device);
    end
elseif (response.StatusCode == 400) % HTTP Status - Bad Request
    disp(response.Body.Data.errors);
else % all other HTTP Statuses
    disp(char(response.StatusLine));
end


library(httr)
r <- GET("https://data.oceannetworks.ca/api/devices", 
         query = list(method="get", 
                      token="YOUR_TOKEN_HERE", #>replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
                      deviceName="jasco"))

if (http_error(r)) {
  if (r$status_code == 400){
    error = content(r)
    str(error)
  } else {
    str(http_status(r)$message)
  }
} else {
  devices = content(r)
  for (device in devices){
    str(device)
  }
}



This example returns all Devices that have been deployed at the location with locationCode 'BACAX' and prints out the results. The locationCode filter is case sensitive and must match a valid locationCode exactly. See locations for further details

Parameters:

  • locationCode=BACAX
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/devices'
parameters = {'method':'get',
			'token':'YOUR_TOKEN_HERE', # replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
			'locationCode':'BACAX'}
 
response = requests.get(url,params=parameters)
 
if (response.ok):
	devices = json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for device in devices:
		print(device,'\n ')
else:
	if(response.status_code == 400):
		error = json.loads(str(response.content,'utf-8'))
		print(error) # json response contains a list of errors, with an errorMessage and parameter
	else:
		print ('Error {} - {}'.format(response.status_code,response.reason))



url = ['https://data.oceannetworks.ca/api/devices' ...
        '?method=get' ...
        '&token=YOUR_TOKEN_HERE' ...           %replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
        '&locationCode=BACAX'];

request = matlab.net.http.RequestMessage;
uri = matlab.net.URI(url);
options = matlab.net.http.HTTPOptions('ConnectTimeout',60);
 
response = send(request,uri,options);
 
if (response.StatusCode == 200)    % HTTP Status - OK
    devices = response.Body.Data;
    for i=1:numel(devices)
        device = devices(i);
        disp(device);
    end
elseif (response.StatusCode == 400) % HTTP Status - Bad Request
    disp(response.Body.Data.errors);
else % all other HTTP Statuses
    disp(char(response.StatusLine));
end


library(httr)
r <- GET("https://data.oceannetworks.ca/api/devices", 
         query = list(method="get", 
                      token="YOUR_TOKEN_HERE", #>replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
                      locationCode="BACAX"))

if (http_error(r)) {
  if (r$status_code == 400){
    error = content(r)
    str(error)
  } else {
    str(http_status(r)$message)
  }
} else {
  devices = content(r)
  for (device in devices){
    str(device)
  }
}



This example returns all Devices with the deviceCategoryCode 'ADCP2MHZ' and prints the results. The deviceCategoryCode filter is case sensitive and must match a valid deviceCategoryCode exactly. See deviceCategories service for further details

Parameters:

  • deviceCategoryCode=ADCP2MHZ
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/devices'
parameters = {'method':'get',
			'token':'YOUR_TOKEN_HERE', # replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
			'deviceCategoryCode':'ADCP2MHZ'}
 
response = requests.get(url,params=parameters)
 
if (response.ok):
	devices = json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for device in devices:
		print(device,'\n ')
else:
	if(response.status_code == 400):
		error = json.loads(str(response.content,'utf-8'))
		print(error) # json response contains a list of errors, with an errorMessage and parameter
	else:
		print ('Error {} - {}'.format(response.status_code,response.reason))



url = ['https://data.oceannetworks.ca/api/devices' ...
        '?method=get' ...
        '&token=YOUR_TOKEN_HERE' ...           %replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
        '&deviceCategoryCode=ADCP2MHZ'];

request = matlab.net.http.RequestMessage;
uri = matlab.net.URI(url);
options = matlab.net.http.HTTPOptions('ConnectTimeout',60);
 
response = send(request,uri,options);
 
if (response.StatusCode == 200)    % HTTP Status - OK
    devices = response.Body.Data;
    for i=1:numel(devices)
        device = devices(i);
        disp(device);
    end
elseif (response.StatusCode == 400) % HTTP Status - Bad Request
    disp(response.Body.Data.errors);
else % all other HTTP Statuses
    disp(char(response.StatusLine));
end


library(httr)
r <- GET("https://data.oceannetworks.ca/api/devices", 
         query = list(method="get", 
                      token="YOUR_TOKEN_HERE", #>replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
                      deviceCategoryCode="ADCP2MHZ"))

if (http_error(r)) {
  if (r$status_code == 400){
    error = content(r)
    str(error)
  } else {
    str(http_status(r)$message)
  }
} else {
  devices = content(r)
  for (device in devices){
    str(device)
  }
}



This example returns all Devices that measures the property 'oxygen' and prints the results. The propertyCode filter is case sensitive and must match a valid propertyCode exactly. See properties service for further details.

Parameters:

  • propertyCode=oxygen
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/devices'
parameters = {'method':'get',
			'token':'YOUR_TOKEN_HERE', # replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
			'propertyCode':'oxygen'}
 
response = requests.get(url,params=parameters)
 
if (response.ok):
	devices = json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for device in devices:
		print(device,'\n ')
else:
	if(response.status_code == 400):
		error = json.loads(str(response.content,'utf-8'))
		print(error) # json response contains a list of errors, with an errorMessage and parameter
	else:
		print ('Error {} - {}'.format(response.status_code,response.reason))



url = ['https://data.oceannetworks.ca/api/devices' ...
        '?method=get' ...
        '&token=YOUR_TOKEN_HERE' ...           %replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
        '&propertyCode=oxygen'];

request = matlab.net.http.RequestMessage;
uri = matlab.net.URI(url);
options = matlab.net.http.HTTPOptions('ConnectTimeout',60);
 
response = send(request,uri,options);
 
if (response.StatusCode == 200)    % HTTP Status - OK
    devices = response.Body.Data;
    for i=1:numel(devices)
        device = devices(i);
        disp(device);
    end
elseif (response.StatusCode == 400) % HTTP Status - Bad Request
    disp(response.Body.Data.errors);
else % all other HTTP Statuses
    disp(char(response.StatusLine));
end


library(httr)
r <- GET("https://data.oceannetworks.ca/api/devices", 
         query = list(method="get", 
                      token="YOUR_TOKEN_HERE", #>replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
                      propertyCode="oxygen"))

if (http_error(r)) {
  if (r$status_code == 400){
    error = content(r)
    str(error)
  } else {
    str(http_status(r)$message)
  }
} else {
  devices = content(r)
  for (device in devices){
    str(device)
  }
}



This example returns all Devices that has the device category 'CTD' and property 'pressure' and prints the results. The deviceCategoryCode filter is case sensitive and must match a valid deviceCategoryCode exactly. See deviceCategories service for further details. The propertyCode filter is case sensitive and must match a valid propertyCode exactly. See properties service for further details.

Parameters:

  • deviceCategoryCode=CTD
  • propertyCode=pressure
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/devices'
parameters = {'method':'get',
			'token':'YOUR_TOKEN_HERE', # replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
			'deviceCategoryCode':'CTD',
			'propertyCode':'pressure'}
 
response = requests.get(url,params=parameters)
 
if (response.ok):
	devices = json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for device in devices:
		print(device,'\n ')
else:
	if(response.status_code == 400):
		error = json.loads(str(response.content,'utf-8'))
		print(error) # json response contains a list of errors, with an errorMessage and parameter
	else:
		print ('Error {} - {}'.format(response.status_code,response.reason))



url = ['https://data.oceannetworks.ca/api/devices' ...
        '?method=get' ...
        '&token=YOUR_TOKEN_HERE' ...           %replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
        '&deviceCategoryCode=CTD' ...
        '&propertyCode=pressure'];

request = matlab.net.http.RequestMessage;
uri = matlab.net.URI(url);
options = matlab.net.http.HTTPOptions('ConnectTimeout',60);
 
response = send(request,uri,options);
 
if (response.StatusCode == 200)    % HTTP Status - OK
    devices = response.Body.Data;
    for i=1:numel(devices)
        device = devices(i);
        disp(device);
    end
elseif (response.StatusCode == 400) % HTTP Status - Bad Request
    disp(response.Body.Data.errors);
else % all other HTTP Statuses
    disp(char(response.StatusLine));
end


library(httr)
r <- GET("https://data.oceannetworks.ca/api/devices", 
         query = list(method="get", 
                      token="YOUR_TOKEN_HERE", #>replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
                      propertyCode="pressure"))

if (http_error(r)) {
  if (r$status_code == 400){
    error = content(r)
    str(error)
  } else {
    str(http_status(r)$message)
  }
} else {
  devices = content(r)
  for (device in devices){
    str(device)
  }
}



This example returns all Devices that support the dataProductCode 'IBPP' ('Ice Buoy Profile Plots') and prints the results. The dataProductCode filter is case sensitive and must match a valid dataProductCode exactly. See dataProductCode service for further details.

Parameters:

  • dataProductCode=IBPP
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/devices'
parameters = {'method':'get',
			'token':'YOUR_TOKEN_HERE', # replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
			'dataProductCode':'IBPP'}
 
response = requests.get(url,params=parameters)
 
if (response.ok):
	devices= json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for device in devices:
		print(device,'\n ')
else:
	if(response.status_code == 400):
		error = json.loads(str(response.content,'utf-8'))
		print(error) # json response contains a list of errors, with an errorMessage and parameter
	else:
		print ('Error {} - {}'.format(response.status_code,response.reason))



url = ['https://data.oceannetworks.ca/api/devices' ...
        '?method=get' ...
        '&token=YOUR_TOKEN_HERE' ...           %replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
        '&dataProductCode=IBPP'];

request = matlab.net.http.RequestMessage;
uri = matlab.net.URI(url);
options = matlab.net.http.HTTPOptions('ConnectTimeout',60);
 
response = send(request,uri,options);
 
if (response.StatusCode == 200)    % HTTP Status - OK
    devices = response.Body.Data;
    for i=1:numel(devices)
        device = devices(i);
        disp(device);
    end
elseif (response.StatusCode == 400) % HTTP Status - Bad Request
    disp(response.Body.Data.errors);
else % all other HTTP Statuses
    disp(char(response.StatusLine));
end


library(httr)
r <- GET("https://data.oceannetworks.ca/api/devices", 
         query = list(method="get", 
                      token="YOUR_TOKEN_HERE", #>replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
                      dataProductCode="IBPP"))

if (http_error(r)) {
  if (r$status_code == 400){
    error = content(r)
    str(error)
  } else {
    str(http_status(r)$message)
  }
} else {
  devices = content(r)
  for (device in devices){
    str(device)
  }
}



This example returns all Devices deployed between 1 July 2010 and 30 June 2012, and prints the results. Both the dateFrom and dateTo must be included and be valid UTC date/time values in the format yyyy-MM-dd'T'HH:mm:ss.SSS'Z' and the dateFrom date/time must be before the dateTo date/time.

Parameters:

  • dateFrom=2010-07-01T00:00:00.000Z
  • dateTo=2012-06-30T23:59:59.999Z
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/devices'
parameters = {'method':'get',
			'token':'YOUR_TOKEN_HERE', # replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
			'dateFrom':'2010-07-01T00:00:00.000Z',
			'dateTo':'2012-06-30T23:59:59.999Z'}
 
response = requests.get(url,params=parameters)
 
if (response.ok):
	devices= json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for device in devices:
		print(device,'\n ')
else:
	if(response.status_code == 400):
		error = json.loads(str(response.content,'utf-8'))
		print(error) # json response contains a list of errors, with an errorMessage and parameter
	else:
		print ('Error {} - {}'.format(response.status_code,response.reason))



url = ['https://data.oceannetworks.ca/api/devices' ...
        '?method=get' ...
        '&token=YOUR_TOKEN_HERE' ...           %replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
        '&dateFrom=2010-07-01T00:00:00.000Z' ...
        '&dateTo=2012-06-30T23:59:59.999Z'];

request = matlab.net.http.RequestMessage;
uri = matlab.net.URI(url);
options = matlab.net.http.HTTPOptions('ConnectTimeout',60);
 
response = send(request,uri,options);
 
if (response.StatusCode == 200)    % HTTP Status - OK
    devices = response.Body.Data;
    for i=1:numel(devices)
        device = devices(i);
        disp(device);
    end
elseif (response.StatusCode == 400) % HTTP Status - Bad Request
    disp(response.Body.Data.errors);
else % all other HTTP Statuses
    disp(char(response.StatusLine));
end


library(httr)
r <- GET("https://data.oceannetworks.ca/api/devices", 
         query = list(method="get", 
                      token="YOUR_TOKEN_HERE", #>replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
                      dateFrom="2010-07-01T00:00:00.000Z",
                      dateTo="2012-06-30T23:59:59.999Z"))

if (http_error(r)) {
  if (r$status_code == 400){
    error = content(r)
    str(error)
  } else {
    str(http_status(r)$message)
  }
} else {
  devices = content(r)
  for (device in devices){
    str(device)
  }
}



This example returns all Devices deployed between 1July 2010 and 30 June 2011, at the location with the locationCode 'BACAX' ('Barkely Canyon Axis (POD1)'), and prints the results. Both the dateFrom and dateTo must be included and be valid UTC date/time values in the format yyyy-MM-dd'T'HH:mm:ss.SSS'Z' and the dateFrom date/time must be before the dateTo date/time.

Parameters:

  • locationCode=BACAX
  • dateFrom=2010-07-01T00:00:00.000Z
  • dateTo=2012-06-30T23:59:59.999Z
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/devices'
parameters = {'method':'get',
			'token':'YOUR_TOKEN_HERE', # replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
			'locationCode':'BACAX',
			'dateFrom':'2010-07-01T00:00:00.000Z',
			'dateTo':'2011-06-30T23:59:59.999Z'}
 
response = requests.get(url,params=parameters)
 
if (response.ok):
	devices = json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for device in devices:
		print(device,'\n ')
else:
	if(response.status_code == 400):
		error = json.loads(str(response.content,'utf-8'))
		print(error) # json response contains a list of errors, with an errorMessage and parameter
	else:
		print ('Error {} - {}'.format(response.status_code,response.reason))



url = ['https://data.oceannetworks.ca/api/devices' ...
        '?method=get' ...
        '&token=YOUR_TOKEN_HERE' ...           %replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
        '&locationCode=BACAX' ...
        '&dateFrom=2010-07-01T00:00:00.000Z' ...
        '&dateTo=2012-06-30T23:59:59.999Z'];

request = matlab.net.http.RequestMessage;
uri = matlab.net.URI(url);
options = matlab.net.http.HTTPOptions('ConnectTimeout',60);
 
response = send(request,uri,options);
 
if (response.StatusCode == 200)    % HTTP Status - OK
    devices = response.Body.Data;
    for i=1:numel(devices)
        device = devices(i);
        disp(device);
    end
elseif (response.StatusCode == 400) % HTTP Status - Bad Request
    disp(response.Body.Data.errors);
else % all other HTTP Statuses
    disp(char(response.StatusLine));
end


library(httr)
r <- GET("https://data.oceannetworks.ca/api/devices", 
         query = list(method="get", 
                      token="YOUR_TOKEN_HERE", #>replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
                      locationCode="BACAX",
                      dateFrom="2010-07-01T00:00:00.000Z",
                      dateTo="2011-06-30T23:59:59.999Z"))

if (http_error(r)) {
  if (r$status_code == 400){
    error = content(r)
    str(error)
  } else {
    str(http_status(r)$message)
  }
} else {
  devices = content(r)
  for (device in devices){
    str(device)
  }
}



This example returns all Devices deployed between 1 July 2010 and 30 June 2011, at the location with the locationCode 'BACAX' ('Barkely Canyon Axis (POD1)'), with the propertyCode 'seawatertemperature', and prints the results. Both the dateFrom and dateTo must be included and be valid UTC date/time values in the format yyyy-MM-dd'T'HH:mm:ss.SSS'Z' and the dateFrom date/time must be before the dateTo date/time.

Parameters:

  • locationCode=BACAX
  • propertyCode=seawatertemperature
  • dateFrom=2010-07-01T00:00:00.000Z
  • dateTo=2012-06-30T23:59:59.999Z
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/devices'
parameters = {'method':'get',
			'token':'YOUR_TOKEN_HERE', # replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
			'locationCode':'BACAX',
			'propertyCode':'seawatertemperature',
			'dateFrom':'2010-07-01T00:00:00.000Z',
			'dateTo':'2011-06-30T23:59:59.999Z'}
 
response = requests.get(url,params=parameters)
 
if (response.ok):
	devices = json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for device in devices:
		print(device,'\n ')
else:
	if(response.status_code == 400):
		error = json.loads(str(response.content,'utf-8'))
		print(error) # json response contains a list of errors, with an errorMessage and parameter
	else:
		print ('Error {} - {}'.format(response.status_code,response.reason))



url = ['https://data.oceannetworks.ca/api/devices' ...
        '?method=get' ...
        '&token=YOUR_TOKEN_HERE' ...           %replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
        '&locationCode=BACAX' ...
        '&propertyCode=seawatertemperature' ...
        '&dateFrom=2010-07-01T00:00:00.000Z' ...
        '&dateTo=2011-06-30T23:59:59.999Z'];

request = matlab.net.http.RequestMessage;
uri = matlab.net.URI(url);
options = matlab.net.http.HTTPOptions('ConnectTimeout',60);
 
response = send(request,uri,options);
 
if (response.StatusCode == 200)    % HTTP Status - OK
    devices = response.Body.Data;
    for i=1:numel(devices)
        device = devices(i);
        disp(device);
    end
elseif (response.StatusCode == 400) % HTTP Status - Bad Request
    disp(response.Body.Data.errors);
else % all other HTTP Statuses
    disp(char(response.StatusLine));
end


library(httr)
r <- GET("https://data.oceannetworks.ca/api/devices", 
         query = list(method="get", 
                      token="YOUR_TOKEN_HERE", #>replace YOUR_TOKEN_HERE with your personal token obtained from the 'Web Services API' tab at https://data.oceannetworks.ca/Profile when logged in.
                      locationCode="BACAX",
                      propertyCode="seawatertemperature",
                      dateFrom="2010-07-01T00:00:00.000Z",
                      dateTo="2011-06-30T23:59:59.999Z"))

if (http_error(r)) {
  if (r$status_code == 400){
    error = content(r)
    str(error)
  } else {
    str(http_status(r)$message)
  }
} else {
  devices = content(r)
  for (device in devices){
    str(device)
  }
}




Please report all issues with the web services, documentation, samples and client libraries to the Oceans 3.0 Help Centre