Skip to main content

Python wrapper for the PoetryDB API.

Project description

# Poetpy

[![Documentation Status](]( [![Build Status](]( [![Build status](]( [![Codacy Badge](]( [![Coverage Status](]( ![]( ![](

Python wrapper of the [PoetryDB API](

## Installation

poetpy is must easily installed using pip.

~~~ python pip install poetpy ~~~

Otherwise, the project repository can be download and installed through invoking the python install command.

~~~ python python install ~~~

## Examples

Extracting poetry and poets from the PoetryDB API requires at least one input_term parameter. The input_term parameter results can be further refined with a corresponding search term. For example, let’s say we are interested in finding all of William Shakespeare’s poems and sonnets available in the PoetryDB API.

~~~ python w = poetpy.get_poetry(‘author’, ‘William Shakespeare’) ~~~

In the above example, the input_term is ‘author’ and the author we are interested in finding is ‘William Shakespeare’.

If we wanted to only output the lines and line counts of all of Shakespeare’s poetry and sonnets, we can use the output parameter to narrow the returned results.

~~~ python w = poetpy.get_poetry(‘author’, ‘William Shakespeare’, ‘lines,linecounts’) ~~~

The default output format from the PoetryDB API is JSON; however, we can change the output to text by specifying the output_format parameter.

~~~ python w = poetpy.get_poetry(‘author’, ‘William Shakespeare’, ‘lines,linecounts’, ‘text’) ~~~

The output text format will be newline escaped.

Combination searches are also allowed to enable users to further refine the returned search results. Each input_term should be given a corresponding search term delimited by a semi-colon. For example, let’s say we want to find all of []John Milton’s]( poetry with [Paradise Lost]( in the title.

~~~ python get_poetry(‘title,author’, ‘Paradise Lost;Milton’) ~~~

Different input_term parameter combinations can also be performed. Taking the above example, let’s say we are actually only interested in finding Wordworth’s poem I Wandered Lonely As A Cloud.

~~~ python w = poetpy.get_poetry(‘author,title’, ‘William Shakespeare;I Wandered Lonely As A Cloud’) ~~~

## Further Examples and Notebooks


A set of [Jupyter Notebooks]( that further explore the potential usage of poetpy and the PoetryDB API. The notebooks can also be opened interactively using [binder](

## Requirements

  • Python 3.4+

  • requests >= 2.18

## See Also

  • [PoetryDB]( Github page with more information regarding the implementation and design of PoetryDB and its API. The README of the repository also contains other examples for working with the API (though not in Python).

## About PoetryDB

[PoetryDB]( was created and is currently maintained by [@thundercomb]( They blog about poetry and related technology and other topics at [](

Please note, I am in no way affiliated with the creator of PoetryDB. My intention with poetpy is to help spread the word and hopefully increase interest in poetry and related projects that attempt to create comprehensive databases of publicly available knowledge.

## License


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

poetpy-1.1.1.tar.gz (4.8 kB view hashes)

Uploaded Source

Built Distribution

poetpy-1.1.1-py2.py3-none-any.whl (11.5 kB view hashes)

Uploaded Python 2 Python 3

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