Giter VIP home page Giter VIP logo

kb-python-api's Introduction

Koninklijke Bibliotheek Logo

KB python API: Access to National Library of the Netherlands datasets

Downloads

Pypi version

Pypi version

build status

Travis build status

KB-Python-API is a simple API for Python, the API provides easy access to free and CC-BY-NC-ND datasets provided by the National Library of the Netherlands (KB).

It relies on the back-end infrastructure of the KB which consists of an SRU and OAI-MPH service. The KB Python API makes it easy to interact with historical data, for more information on the provided datasets and data-rights take a look at the DataServices page of the KB.

For example usage have a look at the provided example.py file, or consult the /test directory.

This package is also available from the pypi website. To do a quick install:

pip install kb

OAI example

>>> from kb.nl.api import oai
>>> from kb.nl.helpers import alto_to_text
>>> oai.list_sets()
['ANP', 'BYVANCK', 'DPO', 'SGD']
>>> records = oai.list_records("ANP")
>>> records.identifiers[:3]
['anp:1937:10:01:1', 'anp:1937:10:01:2', 'anp:1937:10:01:3']
>>> len(oai.resumptiontoken)
42
>>> record = oai.get(records.identifiers[0])
>>> alto_record = record.alto
>>> alto_to_text(alto_record[0]).split("\\n")[1][:27]
u' RADIO 1 van 1 Ootober 1937'
>> image_record = record.image
>>> len(image_record)
721035

SRU example

>>> from kb.nl.api import sru
>>> from kb.nl.helpers import alto_to_text
>>> response = sru.search("Beatrix AND Juliana AND Bernhard AND telegram", "ANP")
>>> for record in response.records:
...     print("Date: %s" % record.date)
...     print("Abstract: %s" % record.abstract) 
...     print("Title: %s" % record.title)

kb-python-api's People

Contributors

bitsgalore avatar stitchplus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

kb-python-api's Issues

API key

Add option for API key usage.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.