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

This class provides a wrapper for the most common Oceans 2.0 API requests.

Use an ONC object to invoke all the methods in the API Client (Discovery, Data Product Download, Real-Time access, Archived File Download).

Constructor

Constructor
ONC(token: str, production: bool, showInfo: bool, outPath: str, timeout: int)

Parameter

Type

Description

Example

tokenstring

Your ONC API token.

Once logged in at https://data.oceannetworks.ca/login, your token can be retrieved or generated at https://data.oceannetworks.ca/Profile. Click on the "Web Services" tab, then click "Generate Token".

'YOUR_TOKEN_HERE'
productionboolean

Indicates whether the ONC Production server URL is used for service requests.

  • True: Use the production server.
  • False: Use the internal ONC test server (reserved for ONC staff IP addresses).

Default: True

True
showInfoboolean

Indicates whether verbose script messages are displayed, such as request url and processing time information.

  • True: Print all information and debug messages (intended for debugging).
  • False: Only print information messages

Default: False

True
outPathstring

When using methods that download files, the path that files are saved to (relative to the current directory).

If the path provided doesn't exist, it will be created.

Default: 'output'

'c:/ONC/Download'
timeoutint

Number of seconds before a request to the API is canceled due to a timeout.

Default: 60

30
Example: Create an ONC object
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE')
Example: Create an ONC object with custom configuration
from onc.onc import ONC
onc = ONC('YOUR_TOKEN_HERE', showInfo=True, outPath='C:/onc-files')



  • No labels