Ocean Networks Canada
Provides easy access to Ocean Networks Canada data in Python.
https://github.com/oceannetworkscanada/api-python-client
Category: Hydrosphere
Sub Category: Ocean and Hydrology Data Access
Keywords
api data-science ocean-sciences onc python
Keywords from Contributors
optimize archiving measur transforms generic compose observation conversion projection animals
Last synced: about 16 hours ago
JSON representation
Repository metadata
Provides easy access to ONC data in Python
- Host: GitHub
- URL: https://github.com/oceannetworkscanada/api-python-client
- Owner: OceanNetworksCanada
- License: apache-2.0
- Created: 2019-07-25T21:01:32.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2026-04-23T18:27:47.000Z (3 months ago)
- Last Synced: 2026-07-07T16:26:01.726Z (11 days ago)
- Topics: api, data-science, ocean-sciences, onc, python
- Language: Python
- Homepage: https://oceannetworkscanada.github.io/api-python-client/
- Size: 8.5 MB
- Stars: 17
- Watchers: 6
- Forks: 9
- Open Issues: 11
- Releases: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
README.md
onc: client library for accessing Oceans 3.0 API
onc is a Python client library that facilitates access to scientific data hosted by Ocean Networks Canada
through the Oceans 3.0 API public web services.
It can help you explore and download our data, by consuming our
discovery,
data product download,
archive file download, and
near real-time data access services.
Getting Started
Installation
onc can be installed from PyPI:
pip install onc
Obtaining a token
A unique Oceans 3.0 API token is required to access our data.
To obtain a token, follow the steps below:
-
Register for an Oceans 3.0 account at https://data.oceannetworks.ca/Registration.
-
Log into your account at https://data.oceannetworks.ca by clicking the Log In link.
-
Click the Profile link (top right corner) to access your account profile.
-
Access the Web Services API tab and click Copy Token.
-
If you forget your token, you can always find it again in your Oceans 3.0 account profile.
Searching with discovery methods
To download ONC data, you need to specify the type of data you require
and where in particular (i.e. location, device) it originates from.
In the Oceans 3.0 API, there's a unique code that identifies every location, device, property, data product type, etc.
Include these codes in a group of filters (these will be used as URL parameters when making HTTP requests)
that determine the data you're interested in.
Discovery methods allow you to explore the hierarchy of the ONC database to obtain the codes for your filters
(they work like a "search" function).
The example below uses the getLocations method to search for locations that include "Burrard" in their name (i.e. "Burrard Inlet"):
from onc import ONC
onc = ONC("YOUR_TOKEN")
onc = ONC() # This works if the env variable "ONC_TOKEN" is set
onc.getLocations({"locationName": "Burrard"})
The previous code prints a list with locations that match the search filters provided.
Each location in the list includes a dataSearchURL that points to the Data Search Tool,
and a locationCode ("BIPP" and "BISS" in this example) that can be used to continue searching "inside" it,
as in the following example:
onc.getDeviceCategories({"locationCode": "BIIP"})
onc.getDataProducts({"locationCode": "BIIP", "deviceCategoryCode": "CTD"})
Check more on the discovery methods guide
and code examples.
Downloading data products
Once you determine the exact dictionary of filters that identifies the data you are interested in,
there are multiple methods to download it.
One method is to request the ONC servers to generate a custom data product with the data.
This is done through the data product download methods.
The following example downloads two PNG files with plots for 30 seconds of data from a CTD in Campbell River:
params = {
"locationCode": "BIIP",
"deviceCategoryCode": "CTD",
"dataProductCode": "TSSP",
"extension": "png",
"dateFrom": "2019-06-20T00:00:00.000Z",
"dateTo": "2019-06-20T00:30:00.000Z",
"dpo_qualityControl": "1",
"dpo_resample": "none",
}
onc.orderDataProduct(params, includeMetadataFile=False)
The filters above include codes for location, deviceCategory, and dataProduct,
as well as the file extension and a time interval (in UTC).
They also include a couple of filters to configure this specific data product type (starting with the "dpo_" prefix),
which can be obtained from the Data Product Options documentation.
You can download more than 120 different types of data products including audio & video.
Check more on the data product download methods guide
and code examples.
Obtaining sensor readings in (near) real-time
Another method to obtain ONC data is by directly obtaining a time series of sensor readings
(available as soon as they reach our database).
In the following example, we obtain 5 seconds of conductivity readings from the CTD at Burrard Inlet:
params = {
"locationCode": "BIIP",
"deviceCategoryCode": "CTD",
"propertyCode": "conductivity",
"dateFrom": "2019-06-20T00:00:00.000Z",
"dateTo": "2019-06-20T00:00:05.000Z",
}
onc.getScalardata(params)
# Longer method name
# onc.getScalardataByLocation(params)
The result includes matching lists of "values" and "sampleTimes" (increases performance for long time ranges).
We also use the property code "conductivity" to limit results to a specific property available in this CTD.
Check more on the near real-time data access methods guide
and code examples.
Downloading archived files
ONC scripts auto-generate and archive data products of different types at set time intervals.
You can directly download these data product files from our files archive, as long as you know their unique filename.
In the following example, we get a list of archived files available for a camera at Ridley Island (in a certain time span),
and download one of the files:
params = {
"locationCode": "RISS",
"deviceCategoryCode": "VIDEOCAM",
"dateFrom": "2016-12-01T00:00:00.000Z",
"dateTo": "2016-12-01T00:05:00.000Z",
}
result = onc.getArchivefile(params, allPages=True)
# Longer method name
# result = onc.getArchivefileByLocation(params, allPages=True)
# Download one of the files from result["files"]
onc.downloadArchivefile("AXISQ6044PTZACCC8E334C53_20161201T000001.000Z.jpg", overwrite=True)
You can use the method downloadArchivefile() as above to download individual files or the method downloadDirectArchivefile()
to download all the files that match your filters.
Alternatively, if you prefer using a download manager like aria2 or Free Download Manager, getArchivefileUrls and getArchivefileUrl can return the download URLs of the archivefile
without downloading the files.
Check more on the archive file download methods guide
and code examples.
Documentation
The client library documentation is hosted on GitHub Pages.
For documentation and examples about Oceans 3.0 API, visit the wiki
and OpenAPI page on the Oceans 3.0 Data Portal website.
Multithreading issue
We kindly ask users to not use too many threads when using threading/multiprocessing libraries on download tasks.
It can cause issues for both server and client and may not appreciably increase download speeds.
Contributing
All contributions are welcome and appreciated!
Please refer to the Contributing guide before submitting any issues or pull requests.
Owner metadata
- Name: Ocean Networks Canada
- Login: OceanNetworksCanada
- Email:
- Kind: organization
- Description: Ocean Networks Canada operates world-leading ocean observatories for the advancement of science and the benefit of Canada.
- Website: http://www.oceannetworks.ca/
- Location: Victoria, BC, Canada
- Twitter:
- Company:
- Icon url: https://avatars.githubusercontent.com/u/29385151?v=4
- Repositories: 15
- Last ynced at: 2023-08-02T03:03:46.194Z
- Profile URL: https://github.com/OceanNetworksCanada
GitHub Events
Total
- Release event: 2
- Delete event: 9
- Pull request event: 20
- Fork event: 1
- Issues event: 11
- Watch event: 7
- Issue comment event: 20
- Push event: 25
- Pull request review comment event: 10
- Pull request review event: 20
- Create event: 10
Last Year
- Release event: 1
- Delete event: 2
- Pull request event: 4
- Issues event: 5
- Watch event: 3
- Issue comment event: 8
- Push event: 7
- Pull request review event: 6
- Pull request review comment event: 4
- Create event: 4
Committers metadata
Last synced: 9 days ago
Total Commits: 105
Total Committers: 6
Avg Commits per committer: 17.5
Development Distribution Score (DDS): 0.314
Commits in past year: 10
Committers in past year: 1
Avg Commits per committer in past year: 10.0
Development Distribution Score (DDS) in past year: 0.0
| Name | Commits | |
|---|---|---|
| Kan Fu | f****u@g****m | 72 |
| Dany Cabrera | d****a@u****a | 18 |
| Jake | 3****s | 9 |
| Renfu Li | r****i@o****m | 4 |
| dependabot[bot] | 4****] | 1 |
| Spencer Plovie | 6****e | 1 |
Committer domains:
- uvic.ca: 1
Issue and Pull Request metadata
Last synced: 2 months ago
Total issues: 29
Total pull requests: 64
Average time to close issues: 3 months
Average time to close pull requests: 9 days
Total issue authors: 3
Total pull request authors: 5
Average comments per issue: 0.31
Average comments per pull request: 1.08
Merged pull request: 52
Bot issues: 0
Bot pull requests: 2
Past year issues: 3
Past year pull requests: 9
Past year average time to close issues: 3 months
Past year average time to close pull requests: 15 days
Past year issue authors: 1
Past year pull request authors: 2
Past year average comments per issue: 0.33
Past year average comments per pull request: 1.67
Past year merged pull request: 4
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- kan-fu (22)
- Jacob-Stevens-Haas (6)
- aschlesin (1)
Top Pull Request Authors
- kan-fu (54)
- Renfu-Li (3)
- Jacob-Stevens-Haas (3)
- IanTBlack (2)
- dependabot[bot] (2)
Top Issue Labels
- enhancement (6)
- bug (4)
- backend (3)
- documentation (3)
- Internal (2)
Top Pull Request Labels
- dependencies (2)
Package metadata
- Total packages: 2
-
Total downloads:
- pypi: 2,600 last-month
- Total dependent packages: 2 (may contain duplicates)
- Total dependent repositories: 4 (may contain duplicates)
- Total versions: 46
- Total maintainers: 4
proxy.golang.org: github.com/oceannetworkscanada/api-python-client
- Homepage:
- Documentation: https://pkg.go.dev/github.com/oceannetworkscanada/api-python-client#section-documentation
- Licenses: apache-2.0
- Latest release: v2.6.0+incompatible (published 8 months ago)
- Last Synced: 2026-06-19T02:02:50.541Z (29 days ago)
- Versions: 5
- Dependent Packages: 0
- Dependent Repositories: 0
-
Rankings:
- Dependent packages count: 5.395%
- Average: 5.576%
- Dependent repos count: 5.758%
pypi.org: onc
Oceans 3.0 API Python Client Library
- Homepage: https://data.oceannetworks.ca/OpenAPI
- Documentation: https://oceannetworkscanada.github.io/api-python-client/
- Licenses: Apache Software License
- Latest release: 2.6.0 (published 8 months ago)
- Last Synced: 2026-06-19T02:02:54.283Z (29 days ago)
- Versions: 41
- Dependent Packages: 2
- Dependent Repositories: 4
- Downloads: 2,600 Last month
-
Rankings:
- Dependent packages count: 4.787%
- Average: 7.068%
- Dependent repos count: 7.484%
- Downloads: 8.934%
- Maintainers (4)
Dependencies
- humanize *
- python-dateutil *
- requests *
- actions/checkout v4 composite
- actions/setup-python v4 composite
Score: 12.991069479719997