Skip to main content

Python wrappers for the HathiTrust APIs

Project description

hathitrust-api

A simple interface for the HathiTrust APIs. The package contains basic classes and associated methods for querying the Bibliographic API, Data API, and the HTRC Solr Proxy.

The package is compatible with Python 2 and Python 3.

Installation

Clone and install from this repository:

git clone https://github.com/rlmv/hathitrust-api.git
cd hathitrust-api
python setup.py install

Or install directly using pip:

pip install hathitrust-api

DataAPI

The Data API retrieves non-google public domain works from the HathiTrust.

An OAuth keyset from HathiTrust is required to use the Data API.

Example usage:

>>> from hathitrust_api import DataAPI
>>> data_api = DataAPI(your_oauth_key, your_oauth_secret)
>>> ocrtext = data_api.getpageocr('nyp.33433082228226', 120)

BibAPI

The bibliographic API delivers HathiTrust bibliographic data and MARC records in JSON format.

Example:

>>> from hathitrust_api import BibAPI
>>> bib_api = BibAPI()
>>> bib_info = bib_api.get_single_record_json('htid', 'dul1.ark:/13960/t00z82c1q')
>>> bib_info.keys()
[u'records', u'items']
>>> bib_info['records']['010944133']['publishDates']
[u'1670']

SolrAPI

The HTRC Solr Proxy is a search index over the public domain collection.

>>> from hathitrust_api import SolrAPI
>>> solr = SolrAPI()
>>> results = solr.query("new zealand", fields=['title'])
>>> results
{u'responseHeader': {u'status': 0, u'QTime': 19}, u'response': {u'start': 0, u'numFound': 366613, u'docs': [{u'title': [u'The statues of New Zealand ...']}, {u'title': [u'New Zealand.']}, {u'title': [u"Wise's New Zealand index"]}, {u'title': [u'Palaeontological bulletin.']}, {u'title': [u'New Zealand,']}, {u'title': [u'The New Zealand official year-book.']}, {u'title': [u'The New Zealand official year-book.']}, {u'title': [u'The New Zealand official year-book.']}, {u'title': [u'The New Zealand official year-book.']}, {u'title': [u'The New Zealand official year-book.']}]}}

Needed:

  • Write test cases.

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

hathitrust_api-0.1.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hathitrust_api-0.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file hathitrust_api-0.1.0.tar.gz.

File metadata

File hashes

Hashes for hathitrust_api-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b9a9a579573088927f236f2e5b6dac93a2cb6d7da7fedbc51de225c618bee569
MD5 3951cdc17aa64e5a06bb0668b0447c62
BLAKE2b-256 3fbfab02873991174f5cbb88d170ce48958c32d536d180b1a87a56d5d897bfd6

See more details on using hashes here.

File details

Details for the file hathitrust_api-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hathitrust_api-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e191369f05a31bf28360bf829cf6ea9cea4e3c1841c97d9a86bf3965676dc2f6
MD5 8eaee1c611142394e5cf4b0e4bd3ba14
BLAKE2b-256 939fd5091c4b997b1231de17b7de3138657c7370e7c00d3538ba90af0389e037

See more details on using hashes here.

Supported by

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