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.


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

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 
    if not deviceCategories == []:
        for deviceCategory in deviceCategories:
            print(deviceCategory,'\n ')
    else:
        print('There are no results for your requested parameters.') 

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/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


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)
  }
}



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

Parameters:

  • deviceCategoryCode=ADCP150KHZ
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   
	if not deviceCategories == []:
        for deviceCategory in deviceCategories:
            print(deviceCategory,'\n ')
    else:
        print('There are no results for your requested parameters.')   
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/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


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)
  }
}



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=acoustic
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':'acoustic'}
 
response = requests.get(url,params=parameters)
 
if (response.ok):
	deviceCategories = json.loads(str(response.content,'utf-8')) # convert the json response to an object  
	if not deviceCategories == []:
        for deviceCategory in deviceCategories:
            print(deviceCategory,'\n ')
    else:
        print('There are no results for your requested parameters.')   
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/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=acoustic'];

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


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="acoustic"))

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)
  }
}



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
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  
	if not deviceCategories == []:
        for deviceCategory in deviceCategories:
            print(deviceCategory,'\n ')
    else:
        print('There are no results for your requested parameters.')   
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/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


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)
  }
}



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
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  
	if not deviceCategories == []:
        for deviceCategory in deviceCategories:
            print(deviceCategory,'\n ')
    else:
        print('There are no results for your requested parameters.')   
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/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


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)
  }
}



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
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   
	if not deviceCategories == []:
        for deviceCategory in deviceCategories:
            print(deviceCategory,'\n ')
    else:
        print('There are no results for your requested parameters.')   

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/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


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 3.0 Help Centre