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

This class provides a wrapper for Oceans 2.0 API requests. All the client library's functionality is provided as methods of this class.

Create an ^ONC | Onc | Onc object to access this library's functionalities.


Constructor parameters

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

Onc('token': string, 'production': logical, 'showInfo': logical, 'outPath': string, 'timeout': int)
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'

'output'
timeoutint

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

Default: 60

30

Example: Creating an Onc object
from onc.onc import ONC

# Create an ONC object
onc = ONC('YOUR_TOKEN_HERE')

# Create an ONC object with custom configuration parameters
onc = ONC('YOUR_TOKEN_HERE', showInfo=True, outPath='onc-files')
  • No labels