Skip to main content

A client for the Archive-It and Webrecorder WASAPI Data Transer API

Project description

py-wasapi-client Build Status

A client for the WASAPI Data Transfer API. Initially developed according to the Archive-It specification, the client now additionally supports Webrecorder.io.

Requirements

  • Python 3.4-3.7

Installation

To run the latest code, the WASAPI client may be downloaded or cloned from GitHub. From inside the top-level of the py-wasapi-client directory, install with:

 $ python setup.py install

Alternatively, the most recent release (not guaranteed to be the latest code) may be installed from PyPi:

 $ pip install py-wasapi-client

Once installed, run the client at the command line with:

 $ wasapi-client --help

That gives you usage instructions:

usage: wasapi-client [-h] [-b BASE_URI] [-d DESTINATION] [-l LOG] [-n] [-v]
                     [--profile PROFILE | -u USER | -t TOKEN]
                     [-c | -m | -p PROCESSES | -s | -r]
                     [--collection COLLECTION [COLLECTION ...]]
                     [--filename FILENAME] [--crawl CRAWL]
                     [--crawl-time-after CRAWL_TIME_AFTER]
                     [--crawl-time-before CRAWL_TIME_BEFORE]
                     [--crawl-start-after CRAWL_START_AFTER]
                     [--crawl-start-before CRAWL_START_BEFORE]

        Download WARC files from a WASAPI access point.

        Acceptable date/time formats are:
         2017-01-01
         2017-01-01T12:34:56
         2017-01-01 12:34:56
         2017-01-01T12:34:56Z
         2017-01-01 12:34:56-0700
         2017
         2017-01

optional arguments:
  -h, --help            show this help message and exit
  -b BASE_URI, --base-uri BASE_URI
                        base URI for WASAPI access; default:
                        https://partner.archive-it.org/wasapi/v1/webdata
  -d DESTINATION, --destination DESTINATION
                        location for storing downloaded files
  -l LOG, --log LOG     file to which logging should be written
  -n, --no-manifest     do not generate checksum files (ignored when used in
                        combination with --manifest)
  -v, --verbose         log verbosely; -v is INFO, -vv is DEBUG
  --profile PROFILE     profile to use for API authentication
  -u USER, --user USER  username for API authentication
  -t TOKEN, --token TOKEN
                        token for API authentication
  -c, --count           print number of files for download and exit
  -m, --manifest        generate checksum files only and exit
  -p PROCESSES, --processes PROCESSES
                        number of WARC downloading processes
  -s, --size            print count and total size of files and exit
  -r, --urls            list URLs for downloadable files only and exit

query parameters:
  parameters for webdata request

  --collection COLLECTION [COLLECTION ...]
                        collection identifier
  --filename FILENAME   exact webdata filename to download
  --crawl CRAWL         crawl job identifier
  --crawl-time-after CRAWL_TIME_AFTER
                        request files created on or after this date/time
  --crawl-time-before CRAWL_TIME_BEFORE
                        request files created before this date/time
  --crawl-start-after CRAWL_START_AFTER
                        request files from crawl jobs starting on or after
                        this date/time
  --crawl-start-before CRAWL_START_BEFORE
                        request files from crawl jobs starting before this
                        date/time

Configuration

When you are using the tool to query an Archive-It or Webrecorder WASAPI endpoint, you will need to supply a username and password for the API. You have three options to provide these credentials.

  1. Supply a username with -u, and you will be prompted for a password.
  2. Set an environment variable called 'WASAPI_USER' to supply a username and a variable called 'WASAPI_PASS' to supply a password.
  3. Supply a profile --profile defined in a configuration file. The configuration file should be at ~/.wasapi-client.

An example profile:

[unt]
username = exampleUser
password = examplePassword

Order of precedence is command line, environment, config file.

Example Usage

The following command downloads the WARC files available from a crawl with crawl id 256119 and logs program output to a file named out.log. The program will prompt the user to enter the password for user myusername. Downloads are carried out by one process.

 $ wasapi-client -u myusername --crawl 256119 --log /tmp/out.log -p 1

The following command downloads similarly, but user credentials are supplied by a configuration file.

 $ wasapi-client --profile unt --crawl 256119 --log out.log -p 1

You may supply an API token instead of user credentials.

 $ wasapi-client --token thisistheAPItokenIwasgiven --crawl 256119 --log out.log -p 1

The following command downloads the WARC files available from crawls that occurred in the specified time range. Verbose logging is being written to a file named out.log. Downloads are happening via four processes and written to a directory at /tmp/wasapi_warcs/.

 $ wasapi-client --profile unt --crawl-start-after 2016-12-22T13:01:00 --crawl-start-before 2016-12-22T15:11:00  -vv --log out.log -p 4 -d /tmp/wasapi_warcs/

The following command produces the size and file count of all content available to the user.

 $ wasapi-client --profile unt -s 

The following command gives the user the number of files available by the given query parameters.

 $ wasapi-client --profile unt --crawl 256119 -c 

The following command downloads the file called example.warc.gz to the current working directory.

$ wasapi-client --profile unt --filename example.warc.gz

By default, manifest files are generated to provide checksums for the files to be downloaded. One manifest file is generated for each hash algorithm provided by the WASAPI access point. The manifest files are written to the download destination. If you don't want manifest files, use the --no-manifest flag.

$ wasapi-client --profile unt --crawl 256119 --log out.log --no-manifest

If you want to generate manifest files for your available webdata files without actually downloading the webdata files, use the --manifest flag.

$ wasapi-client --profile unt --crawl 256119 --manifest

If you would like to produce a list of URLs where your webdata files can later be downloaded by another tool (such as wget) rather than having wasapi-client do the downloading, use the --urls flag.

$ wasapi-client --profile unt --crawl 256119 --urls

To use the client with Webrecorder (not all query parameters may be supported), supply the base URL with -b.

$ wasapi-client -b https://webrecorder.io/api/v1/download/webdata --profile webrecorder --collection my_collection -d warcs

Run the Tests

$ python setup.py test

or

$ pip install tox
$ tox

Project details


Download files

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

Source Distribution

py-wasapi-client-1.1.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

py_wasapi_client-1.1.0-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file py-wasapi-client-1.1.0.tar.gz.

File metadata

  • Download URL: py-wasapi-client-1.1.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for py-wasapi-client-1.1.0.tar.gz
Algorithm Hash digest
SHA256 9f677deaf735854ac054d6425e9e98f8b5cc30e039310e12789b00ebfa6efafc
MD5 9d1b4b17e13e7150b53fb4e94704965b
BLAKE2b-256 34bcac8d33dfc8889173022c523517fb621b6eee2c51d4488c1d8b00c2848bd1

See more details on using hashes here.

File details

Details for the file py_wasapi_client-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: py_wasapi_client-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for py_wasapi_client-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 377bbfc0c24ba860222b52b23778a3281ff0b549a66865fc6f539c5b5988aa0f
MD5 58e4ba270afd8a1db95d4f99a9eda128
BLAKE2b-256 caa815ed2c6f496917ff8b36b20e6042b847fcd567947fd8daeb9227c47572f8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page