Web Services – Python

Overview

These examples work with /ws/v2 by default, but can be easily modified to work with /ws/v1 (now deprecated).

It’s possible to use the DAP Web Service with the standard libraries in Python (e.g. urllib), but using the Requests module makes things simpler.  It may already be part of your Python distribution, but if you need to install it, try:

 

pip install requests

The examples below use the Requests module, and retrieve DAP metadata in JSON format.

Using the Code

You can download the code examples from the CSIRO Bitbucket server: https://bitbucket.csiro.au/projects/RDS/repos/examples.

When using endpoints that contain a collection identifier, you have a number of options. If you know the particular DAP collection that you want (e.g. you have found it in the DAP user interface), it’s not obvious how you would access the collection using the Web Service.  To simplify things, these examples import a function called encodeIdentifier().  All you need to do is provide the function with the persistent URL you find on the collection’s page, e.g. https://doi.org/10.4225/08/563869A931CFE

The persistent URL is found on the " "Descriptions" tab in a text box titled "Permalink". There is a "copy" button next to it that allows you to copy the URL to your clipboard

You can use encodeIdentifier() to extract the identifier from the URL and format it for use with the Web Service, e.g.:

Examples

Search Collections

Retrieve a Collection

Retrieve a List of a Collection’s versions

Retrieve a List of a Collection’s Metadata Streams

Retrieve a Collection’s XML Metadata Stream

Retrieve a List of External System Tags

Retrieve a List of Collections for an External System Tag

Retrieve a Licence

Files

Retrieve a List of a Collection’s Data Files

Retrieve a Data File from a Collection

Retrieve a List of a Collection’s Supporting Files

Retrieve a Supporting File from a Collection