Skip to main content

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

Metadata

Release files for py-wasapi-client 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-wasapi-client 1.1.0
File Size Uploaded Provenance
py-wasapi-client-1.1.0.tar.gz 10.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for py-wasapi-client 1.1.0
File Interpreter ABI Platform
py_wasapi_client-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.9 kB

Release files / py-wasapi-client-1.1.0.tar.gz

Download URL py-wasapi-client-1.1.0.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9f677deaf735854ac054d6425e9e98f8b5cc30e039310e12789b00ebfa6efafc
BLAKE2b-256 checksum
How to use checksums
34bcac8d33dfc8889173022c523517fb621b6eee2c51d4488c1d8b00c2848bd1
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / py_wasapi_client-1.1.0-py3-none-any.whl

Download URL py_wasapi_client-1.1.0-py3-none-any.whl
Size 19.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
377bbfc0c24ba860222b52b23778a3281ff0b549a66865fc6f539c5b5988aa0f
BLAKE2b-256 checksum
How to use checksums
caa815ed2c6f496917ff8b36b20e6042b847fcd567947fd8daeb9227c47572f8
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for py-wasapi-client 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page