Skip to main content

Pythonic API to WMO OSCAR Web Services

Project description


Pythonic API to WMO OSCAR

Build Status


pyoscar provides a Pythonic API atop the WMO OSCAR HTTP API.




Dependencies are listed in requirements.txt. Dependencies are automatically installed during pyoscar installation.

Installing pyoscar

For users

To install the latest stable version:

pip install pyoscar

To keep up to date with stable updates:

pip install pyoscar -U

For developers

# setup virtualenv
python3 -m venv pyoscar
cd pyoscar
source bin/activate

# clone codebase and install
git clone
cd pyoscar
python build
python install

Running pyoscar via the Command Line

# help
pyoscar --help

# get version
pyoscar --version

# all subcommands support the following options:
# --env (depl or prod, default depl)
# --verbosity (ERROR, WARNING, INFO, DEBUG, default NONE)

# get all station identifiers
pyoscar stations

# get all station identifiers by country
pyoscar stations --country=CAN

# get all station identifiers by program affiliation
pyoscar stations --program=GAW

# get a single station by WIGOS identifier
pyoscar station --identifier 0-20000-0-71151

# get a single station by WIGOS identifier in WIGOS XML format
pyoscar station --identifier 0-20000-0-71151 --format=XML

# add verbose mode (ERROR, WARNING, INFO, DEBUG)
pyoscar station --identifier 0-20000-0-71151 --verbosity=DEBUG

# get contact by country
pyoscar contact -c Canada

# get contact by surname
pyoscar contact -s Karn

# get contact by organization
pyoscar contact -o "Environment Canada"

# upload WMDR XML (to production environment)
pyoscar upload -x /path/to/wmdr.xml -at API_TOKEN -e prod

# upload WMDR XML (to production environment) and save results to file
pyoscar upload -x /path/to/wmdr.xml -at API_TOKEN -e prod -l results.log

Using the pyoscar API

from pyoscar import OSCARClient

client = OSCARClient()

# get all Canadian stations
stations = client.get_stations(country='CAN')

# get all Canadian stations
stations = client.get_stations(program='GAW')

# get invididual station report
stn_leo = client.get_station_report('LEO')

# upload WMDR XML

## instantiate client to OSCAR DEPL (default)
client = OSCARClient(api_token='foo')

## ...or to OSCAR production
client = OSCARClient(api_token='foo', env='prod')

with open('some-wmdr-file.xml') as fh:
    data =

response = client.upload(data)


Running Tests

# install dev requirements
pip install -r requirements-dev.txt

# run tests like this:
cd tests

# or like this:
python test

# measure code coverage
coverage run --source pyoscar test
coverage report -m


python sdist bdist_wheel --universal
twine upload dist/*

Code Conventions

Bugs and Issues

All bugs, enhancements and issues are managed on GitHub.


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyoscar, version 0.3.0
Filename, size File type Python version Upload date Hashes
Filename, size pyoscar-0.3.0-py2.py3-none-any.whl (8.4 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size pyoscar-0.3.0.tar.gz (7.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page