Skip to main content

# Poetpy

[![Documentation Status](https://readthedocs.org/projects/poetpy/badge/?version=latest)](https://poetpy.readthedocs.io/en/latest/?badge=latest) [![Build Status](https://travis-ci.org/aschleg/poetpy.svg?branch=master)](https://travis-ci.org/aschleg/poetpy) [![Build status](https://ci.appveyor.com/api/projects/status/jprq31sokv9rlbuh?svg=true)](https://ci.appveyor.com/project/aschleg/poetpy) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/7abf894070ba46418181f9d07af68838)](https://www.codacy.com/app/aschleg/poetpy?utm_source=github.com&utm_medium=referral&utm_content=aschleg/poetpy&utm_campaign=Badge_Grade) [![Coverage Status](https://coveralls.io/repos/github/aschleg/poetpy/badge.svg?branch=master)](https://coveralls.io/github/aschleg/poetpy?branch=master) ![https://pypi.org/project/poetpy/](https://img.shields.io/badge/pypi%20version-1.1.1-blue.svg) ![https://pypi.org/project/petpy/](https://img.shields.io/badge/python-3.4%2C%203.5%2C%203.6%2C%203.7-blue.svg)

Python wrapper of the [PoetryDB API](http://poetrydb.org/).

## 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 setup.py 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](https://en.wikipedia.org/wiki/John_Milton) poetry with [Paradise Lost](https://en.wikipedia.org/wiki/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

[![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/aschleg/poetpy/master?filepath=notebooks)

A set of [Jupyter Notebooks](http://jupyter.org/) that further explore the potential usage of poetpy and the PoetryDB API. The notebooks can also be opened interactively using [binder](https://mybinder.org/)

## Requirements

  • Python 3.4+

  • requests >= 2.18

## See Also

  • [PoetryDB](https://github.com/thundercomb/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](http://poetrydb.org/index.html) was created and is currently maintained by [@thundercomb](https://twitter.com/thundercomb). They blog about poetry and related technology and other topics at [thecombedthunderclap.blogspot.com](http://thecombedthunderclap.blogspot.com/).

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

GPL-2.0

Metadata

Release files for poetpy 1.1.1

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

Source distribution (sdist)

Source distribution for poetpy 1.1.1
File Size Uploaded
poetpy-1.1.1.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for poetpy 1.1.1
File Interpreter ABI Platform
poetpy-1.1.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 16.2 kB

Release files / poetpy-1.1.1.tar.gz

Download URL poetpy-1.1.1.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d173e7265f9e06559bde674cc07bb312563851ae074e109c04cb093ff7fae750
BLAKE2b-256 checksum
How to use checksums
809f0472ef1219b4f42cef4621c3ddbdb69344b236c961f2e45055bb92d283cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.24.0 CPython/3.7.3

Release files / poetpy-1.1.1-py2.py3-none-any.whl

Download URL poetpy-1.1.1-py2.py3-none-any.whl
Size 11.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
740013a554e1bf11e318049e01d4e6fb02664a516cde999cf2df1482f541b277
BLAKE2b-256 checksum
How to use checksums
165e8ae832d6394c616681960103fb91c0987cf1372d992a0a858a20e84108a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.24.0 CPython/3.7.3

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

3 release files

1.0.0

2 release files

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