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

The following samples illustrate how to use the deployments discovery service to obtain the locationCode, deviceCode, deployment dates and spatial information from the service response. Use the locationCode or deviceCode and begin and end dates to request data using the dataProductDelivery service.

 

 Get all Deployments

This example returns all Deployments and prints the results.

Python 3.x
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/deployments'
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):
	deployments = json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for deployment in deployments:
		print(device)
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/deployments'
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):
	deployments= json.loads(str(response.content)) # convert the json response to an object
	for deployment in deployments:
		print(deployment)
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/deployments' ...
        '?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
    deployments = response.Body.Data;
    for i=1:numel(deployments)
        deployment = deployments(i);
        disp(deployment);
    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/deployments", 
         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 {
  deployments = content(r)
  for (deployment in deployments){
    str(deployment)
  }
}
 Get all Deployments for a specific device code

This example returns the Deployments for 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
Python 3.x
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/deployments'
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):
	deployments = json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for deployment in deployments:
		print(deployment)
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/deployments'
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):
	deployments = json.loads(str(response.content)) # convert the json response to an object
	for deployment in deployments:
		print(deployment)
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/deployments' ...
        '?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
    deployments = response.Body.Data;
    for i=1:numel(deployments)
        deployment = deployments(i);
        disp(deployment);
    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/deployments", 
         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 {
  deployments = content(r)
  for (deployment in deployments){
    str(deployment)
  }
}
 Get all Deployments at a specific location

This example returns all Deployments 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
Python 3.x
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/deployments'
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):
	deployments = json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for deployment in deployments:
		print(deployment)
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/deployments'
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):
	deployments = json.loads(str(response.content)) # convert the json response to an object
	for deployment in deployments:
		print(deployment)
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/deployments' ...
        '?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
    deployments = response.Body.Data;
    for i=1:numel(deployments)
        deployment = deployments(i);
        disp(deployment);
    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/deployments", 
         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 {
  deployments = content(r)
  for (deployment in deployments){
    str(deployment)
  }
}
 Get all Deployments with a specific device category

This example returns all Deployments 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
Python 3.x
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/deployments'
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):
	deployments = json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for deployment in deployments:
		print(deployment)
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/deployments'
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):
	deployments = json.loads(str(response.content)) # convert the json response to an object
	for deployment in deployments:
		print(deployment)
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/deployments' ...
        '?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
    deployments = response.Body.Data;
    for i=1:numel(deployments)
        deployment = deployments(i);
        disp(deployment);
    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/deployments", 
         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 {
  deployments = content(r)
  for (deployment in deployments){
    str(deployment)
  }
}
 Get all Deployments with a specific property

This example returns all Deployments with instruments that measure 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
Python 3.x
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/deployments'
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):
	deployments = json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for deployment in deployments:
		print(deployment)
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/deployments'
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):
	deployments = json.loads(str(response.content)) # convert the json response to an object
	for deployment in deployments:
		print(deployment)
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/deployments' ...
        '?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
    deployments = response.Body.Data;
    for i=1:numel(deployments)
        deployment = deployments(i);
        disp(deployment);
    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/deployments", 
         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 {
  deployments = content(r)
  for (deployment in deployments){
    str(deployment)
  }
}
 Get all Deployments with a specific device category and a specific property

This example returns all Deployments that have devices with 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
Python 3.x
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/deployments'
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):
	deployments = json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for deployment in deployments:
		print(deployment)
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/deployments'
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):
	deployments = json.loads(str(response.content)) # convert the json response to an object
	for deployment in deployments:
		print(deployment)
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/deployments' ...
        '?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
    deployments = response.Body.Data;
    for i=1:numel(deployments)
        deployment = deployments(i);
        disp(deployment);
    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/deployments", 
         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 {
  deployments = content(r)
  for (deployment in deployments){
    str(deployment)
  }
}
 Get all Deployments between two dates

This example returns all Deployments 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:

  • =2010-07-01T00:00:00.000Z
  • dateTo=2012-06-30T23:59:59.999Z
Python 3.x
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/deployments'
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):
	deployments= json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for deployment in deployments:
		print(deployment)
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/deployments'
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):
	deployments= json.loads(str(response.content)) # convert the json response to an object
	for deployment in deployments:
		print(deployment)
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/deployments' ...
        '?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
    deployments = response.Body.Data;
    for i=1:numel(deployments)
        deployment = deployments(i);
        disp(deployment);
    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/deployments", 
         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 {
  deployments = content(r)
  for (deployment in deployments){
    str(deployment)
  }
}
 Get all Deployments at a specific location, between two dates

This example returns all Deployments 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
Python 3.x
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/deployments'
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):
	deployments = json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for deployment in deployments:
		print(deployment)
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/deployments'
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):
	deployments = json.loads(str(response.content)) # convert the json response to an object
	for deployment in deployments:
		print(deployment)
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/deployments' ...
        '?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
    deployments = response.Body.Data;
    for i=1:numel(deployments)
        deployment = deployments(i);
        disp(deployment);
    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/deployments", 
         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 {
  deployments = content(r)
  for (deployment in deployments){
    str(deployment)
  }
}
 Get all Deployments at a specific location, between two dates, with a sensor with a specific property code

This example returns all Deployments 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
Python 3.x
import requests
import json
 
url = 'https://data.oceannetworks.ca/api/deployments'
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):
	deployments = json.loads(str(response.content,'utf-8')) # convert the json response to an object
	for deployment in deployments:
		print(deployment)
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/deployments'
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):
	deployments = json.loads(str(response.content)) # convert the json response to an object
	for deployment in deployments:
		print(deployment)
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/deployments' ...
        '?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
    deployments = response.Body.Data;
    for i=1:numel(deployments)
        deployment = deployments(i);
        disp(deployment);
    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/deployments", 
         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 {
  deployments = content(r)
  for (deployment in deployments){
    str(deployment)
  }
}



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