Page tree
Skip to end of metadata
Go to start of metadata

The following samples illustrate how to use the deviceCategories discovery service to find the device categories that are available to meet your criteria, so that you can use the deviceCategoryCode from the service response to request data using the dataProductDelivery service.

 

 Get all device categories

This example returns all of the device categories and prints the results, one device category at a time

Python 3.x
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/deviceCategories'
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):
	deviceCategories= json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for deviceCateogory in deviceCategories:
		print(deviceCategory)
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))
Python 2.x
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/deviceCategories'
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):
	deviceCategories= json.loads(str(response.content)) # convert the json response to an object
	for deviceCateogory in deviceCategories:
		print(deviceCategory)
else:
	if(response.status_code == 400):
		error = json.loads(str(response.content))
		print(error) # json response contains a list of errors, with an errorMessage and parameter
	else:
		print ('Error {} - {}'.format(response.status_code,response.reason))
MATLAB
url = ['https://data.oceannetworks.ca/api/deviceCategories' ...
        '?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
    deviceCategories = response.Body.Data;
    for i=1:numel(deviceCategories)
        deviceCategory = deviceCategories(i);
        disp(deviceCategory);
    end
elseif (response.StatusCode == 400) % HTTP Status - Bad Request
    disp(response.Body.Data.errors);
else % all other HTTP Statuses
    disp(char(response.StatusLine));
end
R
library(httr)
r <- GET("https://data.oceannetworks.ca/api/deviceCategories", 
         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 {
  deviceCategories = content(r)
  for (deviceCategory in deviceCategories){
    str(deviceCategory)
  }
}
 Get the device category for a specific deviceCategoryCode

This example returns the device category for the deviceCategoryCode 'ADCP150KHZ' and prints the results.

Parameters:

  • deviceCategoryCode=ADCP150KHZ
Python 3.x
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/deviceCategories'
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':'ADCP150KHZ'}
 
response = requests.get(url,params=parameters)
 
if (response.ok):
	deviceCateogories = json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for deviceCategory in deviceCategories:
		print(deviceCategory)
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))
Python 2.x
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/deviceCategories'
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':'ADCP150KHZ'}
 
response = requests.get(url,params=parameters)
 
if (response.ok):
	deviceCateogories = json.loads(str(response.content)) # convert the json response to an object
	for deviceCategory in deviceCategories:
		print(deviceCategory)
else:
	if(response.status_code == 400):
		error = json.loads(str(response.content))
		print(error) # json response contains a list of errors, with an errorMessage and parameter
	else:
		print ('Error {} - {}'.format(response.status_code,response.reason))
MATLAB
url = ['https://data.oceannetworks.ca/api/deviceCategories' ...
        '?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=ADCP150KHZ'];
      
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
    deviceCategories = response.Body.Data;
    for i=1:numel(deviceCategories)
        deviceCategory = deviceCategories(i);
        disp(deviceCategory);
    end
elseif (response.StatusCode == 400) % HTTP Status - Bad Request
    disp(response.Body.Data.errors);
else % all other HTTP Statuses
    disp(char(response.StatusLine));
end
R
library(httr)
r <- GET("https://data.oceannetworks.ca/api/deviceCategories", 
         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="ADCP150KHZ"))

if (http_error(r)) {
  if (r$status_code == 400){
    error = content(r)
    str(error)
  } else {
    str(http_status(r)$message)
  }
} else {
  deviceCategories = content(r)
  for (deviceCategory in deviceCategories){
    str(deviceCategory)
  }
}
 Get all device categories which have a certain word in the name

This example returns all of the device categories which have the 'adcp' in the name and prints the results, one device category at a time. The deviceCategoryName filter is case in-sensitive, so capitalized 'ADCP' will also be returned.

Parameters:

  • deviceCategoryName=adcp
Python 3.x
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/deviceCategories'
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.
			'deviceCategoryName':'adcp'}
 
response = requests.get(url,params=parameters)
 
if (response.ok):
	deviceCategories = json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for deviceCategory in deviceCategories:
		print(deviceCategory)
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))
Python 2.x
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/deviceCategories'
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.
			'deviceCategoryName':'adcp'}
 
response = requests.get(url,params=parameters)
 
if (response.ok):
	deviceCategories = json.loads(str(response.content)) # convert the json response to an object
	for deviceCategory in deviceCategories:
		print(deviceCategory)
else:
	if(response.status_code == 400):
		error = json.loads(str(response.content))
		print(error) # json response contains a list of errors, with an errorMessage and parameter
	else:
		print ('Error {} - {}'.format(response.status_code,response.reason))
MATLAB
url = ['https://data.oceannetworks.ca/api/deviceCategories' ...
        '?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.
        '&deviceCategoryName=adcp'];

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
    deviceCategories = response.Body.Data;
    for i=1:numel(deviceCategories)
        deviceCategory = deviceCategories(i);
        disp(deviceCategory);
    end
elseif (response.StatusCode == 400) % HTTP Status - Bad Request
    disp(response.Body.Data.errors);
else % all other HTTP Statuses
    disp(char(response.StatusLine));
end
R
library(httr)
r <- GET("https://data.oceannetworks.ca/api/deviceCategories", 
         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.
                      deviceCategoryName="adcp"))

if (http_error(r)) {
  if (r$status_code == 400){
    error = content(r)
    str(error)
  } else {
    str(http_status(r)$message)
  }
} else {
  deviceCategories = content(r)
  for (deviceCategory in deviceCategories){
    str(deviceCategory)
  }
}
 Get all device categories which have a certain word in the description

This example returns all of the device categories which have the 'doppler' in the description and prints the results, one device category at a time. The description filter is case in-sensitive, so capitalized 'Doppler' will also be returned.

Parameters:

  • description=doppler
Python 3.x
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/deviceCategories'
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.
			'description':'doppler'}
 
response = requests.get(url,params=parameters)
 
if (response.ok):
	deviceCategories = json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for deviceCategory in deviceCategories:
		print(deviceCategory)
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))
Python 2.x
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/deviceCategories'
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.
			'description':'doppler'}
 
response = requests.get(url,params=parameters)
 
if (response.ok):
	deviceCategories = json.loads(str(response.content)) # convert the json response to an object
	for deviceCategory in deviceCategories:
		print(deviceCategory)
else:
	if(response.status_code == 400):
		error = json.loads(str(response.content))
		print(error) # json response contains a list of errors, with an errorMessage and parameter
	else:
		print ('Error {} - {}'.format(response.status_code,response.reason))
MATLAB
url = ['https://data.oceannetworks.ca/api/deviceCategories' ...
        '?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.
        '&description=doppler'];


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
    deviceCategories = response.Body.Data;
    for i=1:numel(deviceCategories)
        deviceCategory = deviceCategories(i);
        disp(deviceCategory);
    end
elseif (response.StatusCode == 400) % HTTP Status - Bad Request
    disp(response.Body.Data.errors);
else % all other HTTP Statuses
    disp(char(response.StatusLine));
end
R
library(httr)
r <- GET("https://data.oceannetworks.ca/api/deviceCategories", 
         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.
                      description="doppler"))

if (http_error(r)) {
  if (r$status_code == 400){
    error = content(r)
    str(error)
  } else {
    str(http_status(r)$message)
  }
} else {
  deviceCategories = content(r)
  for (deviceCategory in deviceCategories){
    str(deviceCategory)
  }
}
 Get all of the device categories that are available at a specific location

This example returns all of the device categories that are available at the location with the locationCode of 'BACAX' ('Barkley Canyon Axis (POD1)' and prints out the results, one device category at a time. The locationCode filter is case sensitive and must match a valid locationCode exactly. See locations for further details

Parameters:

  • locationCode=BACAX
Python 3.x
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/deviceCategories'
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):
	deviceCategories= json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for deviceCategory in deviceCategories:
		print(deviceCategory)
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))
Python 2.x
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/deviceCategories'
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):
	deviceCategories= json.loads(str(response.content)) # convert the json response to an object
	for deviceCategory in deviceCategories:
		print(deviceCategory)
else:
	if(response.status_code == 400):
		error = json.loads(str(response.content))
		print(error) # json response contains a list of errors, with an errorMessage and parameter
	else:
		print ('Error {} - {}'.format(response.status_code,response.reason))
MATLAB
url = ['https://data.oceannetworks.ca/api/deviceCategories' ...
        '?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
    deviceCategories = response.Body.Data;
    for i=1:numel(deviceCategories)
        deviceCategory = deviceCategories(i);
        disp(deviceCategory);
    end
elseif (response.StatusCode == 400) % HTTP Status - Bad Request
    disp(response.Body.Data.errors);
else % all other HTTP Statuses
    disp(char(response.StatusLine));
end
R
library(httr)
r <- GET("https://data.oceannetworks.ca/api/deviceCategories", 
         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 {
  deviceCategories = content(r)
  for (deviceCategory in deviceCategories){
    str(deviceCategory)
  }
}
 Get all the device categories which have devices that have a specific property

This example returns all of the device categories which have devices with the property 'salinity' and prints the results, one device category at a time. The propertyCode filter is case sensitive and must match a valid propertyCode exactly. See properties service for further details.

Parameters:

  • propertyCode=salinity
Python 3.x
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/deviceCategories'
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':'differentialtemperature'}
 
response = requests.get(url,params=parameters)
 
if (response.ok):
	deviceCategories = json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for deviceCategory in deviceCategories:
		print(deviceCategory)
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))
Python 2.x
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/deviceCategories'
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':'differentialtemperature'}
 
response = requests.get(url,params=parameters)
 
if (response.ok):
	deviceCategories = json.loads(str(response.content)) # convert the json response to an object
	for deviceCategory in deviceCategories:
		print(deviceCategory)
else:
	if(response.status_code == 400):
		error = json.loads(str(response.content))
		print(error) # json response contains a list of errors, with an errorMessage and parameter
	else:
		print ('Error {} - {}'.format(response.status_code,response.reason))
MATLAB
url = ['https://data.oceannetworks.ca/api/deviceCategories' ...
        '?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=differentialtemperature'];

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
    deviceCategories = response.Body.Data;
    for i=1:numel(deviceCategories)
        deviceCategory = deviceCategories(i);
        disp(deviceCategory);
    end
elseif (response.StatusCode == 400) % HTTP Status - Bad Request
    disp(response.Body.Data.errors);
else % all other HTTP Statuses
    disp(char(response.StatusLine));
end
R
library(httr)
r <- GET("https://data.oceannetworks.ca/api/deviceCategories", 
         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="differentialtemperature"))

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

 

 

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