Code Monkey home page Code Monkey logo

poetrydb's Introduction

PoetryDB

Introduction

PoetryDB is an API for internet poets. But what is an API?

An API ensures that a program (such as a browser) always returns data in an expected format. JSON is one of the most popular formats in use today.

"Why should poets care?" The answer is blowing in the data winds. Internet technology is making words endlessly manipulable, and traditional poets and writers are getting left behind. I want to change this, by giving us all a leg up into a more empowered future.

How does it work?

You send a URL like so:

https://poetrydb.org/title/Ozymandias/lines.json

And hey, presto! out comes the lines of Shelley's famous sonnet:

[
  {
    "lines": [
      "I met a traveller from an antique land",
      "Who said: \"Two vast and trunkless legs of stone",
      "Stand in the desert. Near them on the sand,",
      "Half sunk, a shattered visage lies, whose frown",
      "And wrinkled lip and sneer of cold command",
      "Tell that its sculptor well those passions read",
      "Which yet survive, stamped on these lifeless things,",
      "The hand that mocked them and the heart that fed.",
      "And on the pedestal these words appear:",
      "'My name is Ozymandias, King of Kings:",
      "Look on my works, ye mighty, and despair!'",
      "Nothing beside remains. Round the decay",
      "Of that colossal wreck, boundless and bare,",
      "The lone and level sands stretch far away\"."
    ]
  }
]

But what do we do with text in json format? The real power of PoetryDB's API becomes apparent when combined with a program. Consider the following Ruby code:

require 'httparty'

response = HTTParty.get("https://poetrydb.org/author,linecount/Shakespeare;14/lines").to_a
(0..13).each { |i| puts response[rand(154)]['lines'][i] }

This fairly simple code is capable of surprising poetry! The program asks PoetryDB for all poems that are 14 lines in length, then writes out a new sonnet based on the results. Astute readers will know that this is the first step towards creating your own version of Raymond Queneau's One Hundred Thousand Billion Sonnets, this time based on some of the most beautiful lines ever written in the English language.

Here is an example:

Since I left you, mine eye is in my mind;
Full character'd with lasting memory,
The rose looks fair, but fairer we it deem
For that sweet odour, which doth in it live.
Yet, in good faith, some say that thee behold,
Thy face hath not the power to make love groan;
But the defendant doth that plea deny,
By seeing farther than the eye hath shown.
Thou art the grave where buried love doth live,
It is my love that keeps mine eye awake:
Are windows to my breast, where-through the sun
Unless thou take that honour from thy name:
  Therefore I lie with her, and she with me,
  Compar'd with loss of thee, will not seem so.

Architecture and code

The API is written in Ruby and uses Sinatra to resolve API routes. The poetry data is stored in a MongoDB database. The Ruby code is provided here as Open Source. The PoetryDB database is not directly accessible, in order to preserve its integrity.

Architecture Diagram

API Reference

General format of API:

/<input field>/<search term>[;<search term>][..][:<search type>][/<output field>][,<output field>][..][.<format>]
  • <input field> can be one of:

    author: The name, or part of the name, of the author of a poem
    title: The title, or part of the title, of a poem
    lines: Part of a line or lines of a poem
    linecount: The number of lines of a poem, including section headings, but excluding empty lines (eg. section breaks)
    poemcount: The number of poems to return (cannot be used in combination with random) random: The number of random poems to return (cannot be used in combination with poemcount)

  • <search term> relates to <input field>. When <input field> is:

    author: <field data> is the name, or part of the name, of the author of a poem
    title: <field data> is the title, or part of the title, of a poem
    lines: <field data> is part of a line or lines of a poem
    linecount: <field data> is the number of lines of a poem. Number of lines includes section headings, but excludes empty lines (eg. section breaks)
    poemcount: <field data> is the number of poems to return
    random: <field data> is the number of random poems to return

  • [:<search type>] is optional. It can be:

    :abs: Match <search term> exactly when searching <input field>
    Default (empty): match <search term> with any part of <input field> when searching

  • [/<output field>][,<output field>][..] are optional. They are a comma delimited set that can be any combination of:

    author: Return only the author of each of the matching poems
    title: Return only the title of each of the matching poems
    lines: Return only the lines of each of the matching poems
    linecount: Return only the number of lines of each of the matching poems
    author,title,...: Return each output field in the comma delimited list of each of the matching poems
    Default (empty): Return all data of each of the matching poems

    or:

    all: Return all data of the matching poems (same as Default (empty))

  • [.<format>] is optional. It can be:

    .json: Return data in json format
    .text: Return data in text format
    Default (empty): Return data in json format

  • [..] means that by using the same syntax, more instances of the preceding type can be expressed

Author

General Format:

/author[/<author>][:abs][/<output field>][,<output field>][..][.<format>]

Format:

/author

Example:

/author

Result:

{
  "authors": [
    "Adam Lindsay Gordon",
    "Alan Seeger",
    "Alexander Pope",
    "Algernon Charles Swinburne",
    .
    .
    "William Shakespeare",
    "William Topaz McGonagall",
    "William Vaughn Moody",
    "William Wordsworth"
  ]
}

Format:

/author/<author>

Example:

/author/Ernest Dowson

Result:

[
  {
    "title": "The Moon Maiden's Song",
    "author": "Ernest Dowson",
    "lines": [
      "Sleep! Cast thy canopy",
      "   Over this sleeper's brain,",
      "Dim grow his memory,",
      "   When he wake again.",
      "",
      "Love stays a summer night,",
      "   Till lights of morning come;",
      "Then takes her winged flight",
      "   Back to her starry home.",
      "",
      "Sleep! Yet thy days are mine;",
      "   Love's seal is over thee:",
      "Far though my ways from thine,",
      "   Dim though thy memory.",
      "",
      "Love stays a summer night,",
      "   Till lights of morning come;",
      "Then takes her winged flight",
      "   Back to her starry home."
    ],
    "linecount": 16
  }
]

Format:

/author/<author>/author

Example:

/author/owson/author

Result:

[
  {
    "author": "Ernest Dowson"
  }
]

Format:

/author/<author>:abs/author

Example:

/author/Ernest Dowson:abs/author

Result:

[
  {
    "author": "Ernest Dowson"
  }
]

Format:

/author/<author>/<output field>,<output field>,<output field>

Example:

/author/Ernest Dowson/author,title,linecount

Result:

[
  {
    "title": "The Moon Maiden's Song",
    "author": "Ernest Dowson",
    "linecount": 16
  }
]

Format:

/author/<author>/<output field>,<output field>,<output field>.<format>

Example:

/author/Ernest Dowson/author,title,linecount.text

Result:

title
The Moon Maiden's Song
author
Ernest Dowson
linecount
16

Title

General Format:

/title[/<title>][:abs][/<output field>][,<output field>][..][.<format>]

Format:

/title

Example:

/title

Result:

{
  "titles": [
    "A Baby's Death",
    "A Ballad Of The Trees And The Master",
    "A Ballad of Burdens",
    "A Ballad of Death",
    .
    .
    "You know that Portrait in the Moon --",
    "You see I cannot see -- your lifetime",
    "Young Munro the Sailor",
    "Youth And Age"
  ]
}

Format:

/title/<title>

Example:

/title/Ozymandias

Result:

[
  {
    "title": "Ozymandias",
    "author": "Percy Bysshe Shelley",
    "lines": [
      "I met a traveller from an antique land",
      "Who said: \"Two vast and trunkless legs of stone",
      "Stand in the desert. Near them on the sand,",
      "Half sunk, a shattered visage lies, whose frown",
      "And wrinkled lip and sneer of cold command",
      "Tell that its sculptor well those passions read",
      "Which yet survive, stamped on these lifeless things,",
      "The hand that mocked them and the heart that fed.",
      "And on the pedestal these words appear:",
      "'My name is Ozymandias, King of Kings:",
      "Look on my works, ye mighty, and despair!'",
      "Nothing beside remains. Round the decay",
      "Of that colossal wreck, boundless and bare,",
      "The lone and level sands stretch far away\"."
    ],
    "linecount": 14
  }
]

Format:

/title/<title>/title

Example:

/title/spring/title

Result:

[
  {
    "title": "I have a Bird in spring"
  },
  {
    "title": "A spring poem from bion"
  },
  {
    "title": "Nay, Lord, not thus! white lilies in the spring,"
  },
  {
    "title": "In spring and summer winds may blow"
  },
  {
    "title": "Sonnet 98: From you have I been absent in the spring"
  }
]

Format:

/title/<title>:abs/title

Example:

/title/In spring and summer winds may blow:abs/title

Result:

[
  {
    "title": "In spring and summer winds may blow"
  }
]

Format:

/title/<title>/<output field>,<output field>,<output field>

Example:

/title/Ozymandias/author,title,linecount

Result:

[
  {
    "title": "Ozymandias",
    "author": "Percy Bysshe Shelley",
    "linecount": 14
  }
]

Format:

/title/<title>/<output field>,<output field>,<output field>.<format>

Example:

/title/Ozymandias/title,lines.text

Result:

title
Ozymandias
lines
I met a traveller from an antique land
Who said: "Two vast and trunkless legs of stone
Stand in the desert. Near them on the sand,
Half sunk, a shattered visage lies, whose frown
And wrinkled lip and sneer of cold command
Tell that its sculptor well those passions read
Which yet survive, stamped on these lifeless things,
The hand that mocked them and the heart that fed.
And on the pedestal these words appear:
'My name is Ozymandias, King of Kings:
Look on my works, ye mighty, and despair!'
Nothing beside remains. Round the decay
Of that colossal wreck, boundless and bare,
The lone and level sands stretch far away".

Lines

General Format:

/lines/<lines>[:abs][/<output field>][,<output field>][..][.<format>]

Format:

/lines/<lines>

Example:

/lines/Latitudeless Place

Result:

[
  {
    "title": "Now I knew I lost her --",
    "author": "Emily Dickinson",
    "lines": [
      "Now I knew I lost her --",
      "Not that she was gone --",
      "But Remoteness travelled",
      "On her Face and Tongue.",
      "",
      "Alien, though adjoining",
      "As a Foreign Race --",
      "Traversed she though pausing",
      "Latitudeless Place.",
      "",
      "Elements Unaltered --",
      "Universe the same",
      "But Love's transmigration --",
      "Somehow this had come --",
      "",
      "Henceforth to remember",
      "Nature took the Day",
      "I had paid so much for --",
      "His is Penury",
      "Not who toils for Freedom",
      "Or for Family",
      "But the Restitution",
      "Of Idolatry."
    ],
    "linecount": 20
  }
]

Format:

/lines/<lines>/<output field>

Example:

/lines/Latitudeless Place/author

Result:

[
  {
    "author": "Emily Dickinson"
  }
]

Format:

/lines/<lines>/<output field>,<output field>,<output field>

Example:

/lines/Latitudeless Place/author,title,linecount

Result:

[
  {
    "title": "Now I knew I lost her --",
    "author": "Emily Dickinson",
    "linecount": 20
  }
]

Format:

/lines/<lines>/<output field>,<output field>,<output field>.<format>

Example:

/lines/Latitudeless Place/author,title,linecount.text

Result:

title
Now I knew I lost her --
author
Emily Dickinson
linecount
20

Linecount

General Format:

/linecount/<linecount>[/<output field>][,<output field>][..][.<format>]

Note: linecount is always exact, and therefore the match type :abs has no effect.

Format:

/linecount/<linecount>

Example:

/linecount/3

Result:

[
  {
    "title": "Of Life to own --",
    "author": "Emily Dickinson",
    "lines": [
      "Of Life to own --",
      "From Life to draw --",
      "But never tough the reservoir --"
    ],
    "linecount": 3
  },
  {
    "title": "A Flower will not trouble her, it has so small a Foot,",
    "author": "Emily Dickinson",
    "lines": [
      "A Flower will not trouble her, it has so small a Foot,",
      "And yet if you compare the Lasts,",
      "Hers is the smallest Boot --"
    ],
    "linecount": 3
  },
  {
    "title": "To see the Summer Sky",
    "author": "Emily Dickinson",
    "lines": [
      "To see the Summer Sky",
      "Is Poetry, though never in a Book it lie --",
      "True Poems flee --"
    ],
    "linecount": 3
  }
]

Format:

/linecount/<linecount>/<output field>

Example:

/linecount/3/title

Result:

[
  {
    "title": "Of Life to own --"
  },
  {
    "title": "A Flower will not trouble her, it has so small a Foot,"
  },
  {
    "title": "To see the Summer Sky"
  }
]

Format:

/linecount/<linecount>/<output field>,<output field>,<output field>

Example:

/linecount/51/author,title,linecount

Result:

[
  {
    "title": "On the Death of the Rev. Dr. Sewell",
    "author": "Phillis Wheatley",
    "linecount": 51
  },
  {
    "title": "A Letter to a Live Poet",
    "author": "Rupert Brooke",
    "linecount": 51
  }
]

Format:

/linecount/<linecount>/<output field>,<output field>.<format>

Example:

/linecount/39/author,title.text

Result:

title
In Winter in my Room
author
Emily Dickinson

title
Celestial Music
author
John Donne

title
Life
author
Robinson

title
29. Song—The Rigs o’ Barley
author
Robert Burns

title
Edinburgh
author
William Topaz McGonagall

Poemcount

General Format:

/<input field>[,<input field>][..],poemcount/<search term>[;<search term][..];<poemcount>[/<output field>][,<output field>][..][.<format>]

Notes:

  • although poemcount can be provided on its own, it makes sense mainly when combined with other input fields
  • poemcount is always exact, and therefore the match type :abs has no effect
  • poemcount and random cannot be used together, as both specify the number of poems to return

Format:

/<input field>,poemcount/<search term>;<poemcount>

Example:

/author,poemcount/Dickinson;2

Result:

[
  {
    "title": "Not at Home to Callers",
    "author": "Emily Dickinson",
    "lines": [
      "Not at Home to Callers",
      "Says the Naked Tree --",
      "Bonnet due in April --",
      "Wishing you Good Day --"
    ],
    "linecount": "4"
  },
  {
    "title": "Defrauded I a Butterfly --",
    "author": "Emily Dickinson",
    "lines": [
      "Defrauded I a Butterfly --",
      "The lawful Heir -- for Thee --"
    ],
    "linecount": "2"
  }
]

Format:

/<input field>,poemcount/<search term>;<poemcount>/<output field>

Example:

/author,poemcount/Dickinson;2/title

Result:

[
  {
    "title": "Not at Home to Callers"
  },
  {
    "title": "Defrauded I a Butterfly --"
  }
]

Format:

/<input field>,poemcount/<search term>;<poemcount>/<output field>,<output field>,<output field>

Example:

/author,poemcount/Dickinson;2/author,title,linecount

Result:

[
  {
    "title": "Not at Home to Callers",
    "author": "Emily Dickinson",
    "linecount": "4"
  },
  {
    "title": "Defrauded I a Butterfly --",
    "author": "Emily Dickinson",
    "linecount": "2"
  }
]

Format:

/<input field>,poemcount/<search term>;<poemcount>/<output field>,<output field>.<format>

Example:

/author,poemcount/Dickinson;2/author,title.text

Result:

title
Not at Home to Callers
author
Emily Dickinson

title
Defrauded I a Butterfly --
author
Emily Dickinson

Random

General Format:

/random[/<random count>][/<output field>][,<output field>][..][.<format>]

Note:

  • the random count search field is always exact, and therefore the match type :abs has no effect
  • random and poemcount cannot be used together, as both specify the number of poems to return

Format:

/random

Example:

/random

Result:

[
  {
    "title": "Sonnet XLIV: Press'd by the Moon",
    "author": "Charlotte Smith",
    "lines": [
      "Press'd by the Moon, mute arbitress of tides,",
      "While the loud equinox its power combines,",
      "The sea no more its swelling surge confines,",
      "But o'er the shrinking land sublimely rides.",
      "The wild blast, rising from the Western cave,",
      "Drives the huge billows from their heaving bed;",
      "Tears from their grassy tombs the village dead,",
      "And breaks the silent sabbath of the grave!",
      "With shells and sea-weed mingled, on the shore",
      "Lo! their bones whiten in the frequent wave;",
      "But vain to them the winds and waters rave;",
      "They hear the warring elements no more:",
      "While I am doom'd—by life's long storm opprest,",
      "To gaze with envy on their gloomy rest."
    ],
    "linecount": "14"
  }
]

Format:

/random/<random count>

Example:

/random/3

Result:

[
  {
    "title": "421. Epitaph on a Lap-dog",
    "author": "Robert Burns",
    "lines": [
      "IN wood and wild, ye warbling throng,",
      "  Your heavy loss deplore;",
      "Now, half extinct your powers of song,",
      "  Sweet Echo is no more.",
.
.
.
    ],
    "linecount": "8"
  },
  {
    "title": "The Canterbury Tales. The Manciple's Tale.",
    "author": "Geoffrey Chaucer",
    "lines": [
      "THE PROLOGUE.",
      "",
      "WEET ye not where there stands a little town,",
      "Which that y-called is Bob-up-and-down,",
      "Under the Blee, in Canterbury way?",
      "There gan our Hoste for to jape and play,",
.
.
.
    ],
    "linecount": "364"
  },
  {
    "title": "Love",
    "author": "Percy Bysshe Shelley",
    "lines": [
      "Why is it said thou canst not live",
      "In a youthful breast and fair,",
      "Since thou eternal life canst give,",
      "Canst bloom for ever there?",
.
.
.
  ],
    "linecount": "24"
  }
]

Format:

/random/<random count>/<output field>

Example:

/random/3/title

Result:

[
  {
    "title": "130. Nature’s Law: A Poem"
  },
  {
    "title": "Longings for Home."
  },
  {
    "title": "Buried Life, The"
  }
]

Format:

/random/<random count>/<output field>,<output field>,<output field>

Example:

/random/3/author,title,linecount

Result:

[
  {
    "title": "The Baby's Dance",
    "author": "Ann Taylor",
    "linecount": "8"
  },
  {
    "title": "478. Epigram on a Suicide",
    "author": "Robert Burns",
    "linecount": "4"
  },
  {
    "title": "Reply to Some Verses of J. M. B. Pigot, Esq., on the Cruelty of His Mistress",
    "author": "George Gordon, Lord Byron",
    "linecount": "48"
  }
]

Format:

/random/<random count>/<output field>,<output field>.<format>

Example:

/random/3/author,title.text

Result:

title
Pain In Pleasure
author
Elizabeth Barrett Browning

title
The Heaven vests for Each
author
Emily Dickinson

title
Sonnet XXXIX: Prepare Your Wreaths
author
Robinson

Combinations

General Format:

/<input field>,<input field>[,<input field>][..]/<search term>;<search term>[;<search term][..][:abs][/<output field>][,<output field>][..][.<format>]

Notes:

  1. The number of input fields should always be matched by the number of search terms
  2. The search terms are separated by the semicolon to allow commas to be used in search terms. However, semicolons are a feature of many texts, and unfortunately cannot be part of the search term currently.

Format:

/<input field>,<input field>/<search term>;<search term>

Example:

/title,random/Sonnet;3

Result:

[
  {
    "title": "Sonnet 63: Against my love shall be as I am now",
    "author": "William Shakespeare",
    "lines": [
      "Against my love shall be as I am now,",
      "With Time's injurious hand crush'd and o'erworn;",
      "When hours have drain'd his blood and fill'd his brow",
      "With lines and wrinkles; when his youthful morn",
.
.
.
    ],
    "linecount": "14"
  },
  {
    "title": "Sonnet 69: Those parts of thee that the world's eye doth view",
    "author": "William Shakespeare",
    "lines": [
      "Those parts of thee that the world's eye doth view",
      "Want nothing that the thought of hearts can mend;",
      "All tongues--the voice of souls--give thee that due,",
      "Uttering bare truth, even so as foes commend.",
.
.
.
    ],
    "linecount": "14"
  },
  {
    "title": "Sonnet XVII: His Mother Dear Cupid",
    "author": "Sir Philip Sidney",
    "lines": [
      "His mother dear Cupid offended late,",
      "Because that Mars grown slacker in her love,",
      "With pricking shot he did not throughly more",
      "To keep the pace of their first loving state.",
.
.
.
    ],
    "linecount": "14"
  }
]

@@@@ Format:

/<input field>,<input field>,<input field>/<search term>;<search term>;<search term>

Example:

/title,author,linecount/Winter;Shakespeare;18

Result:

[
  {
    "title": "Spring and Winter ii",
    "author": "William Shakespeare",
    "lines": [
      "WHEN icicles hang by the wall,",
      "   And Dick the shepherd blows his nail,",
      "And Tom bears logs into the hall,",
      "   And milk comes frozen home in pail,",
.
.
.
    ],
    "linecount": 18
  },
  {
    "title": "Spring and Winter i",
    "author": "William Shakespeare",
    "lines": [
      "WHEN daisies pied and violets blue,",
      "   And lady-smocks all silver-white,",
      "And cuckoo-buds of yellow hue",
      "   Do paint the meadows with delight,",
.
.
.
    ],
    "linecount": 18
  },
  {
    "title": "Winter",
    "author": "William Shakespeare",
    "lines": [
      "When icicles hang by the wall",
      "And Dick the shepherd blows his nail",
      "And Tom bears logs into the hall,",
      "And milk comes frozen home in pail,",
.
.
.
    ],
    "linecount": 18
  }
]

Format:

/<input field>,<input field>/<search term>:abs;<search term>

Example:

/title,author/Winter:abs;William%20Shakespeare

Result:

[
  {
    "title": "Winter",
    "author": "William Shakespeare",
    "lines": [
      "When icicles hang by the wall",
      "And Dick the shepherd blows his nail",
      "And Tom bears logs into the hall,",
      "And milk comes frozen home in pail,",
      "When Blood is nipped and ways be foul,",
      "Then nightly sings the staring owl,",
      "Tu-who;",
      "Tu-whit, tu-who: a merry note,",
      "While greasy Joan doth keel the pot.",
      "",
      "When all aloud the wind doth blow,",
      "And coughing drowns the parson's saw,",
      "And birds sit brooding in the snow,",
      "And Marian's nose looks red and raw",
      "When roasted crabs hiss in the bowl,",
      "Then nightly sings the staring owl,",
      "Tu-who;",
      "Tu-whit, tu-who: a merry note,",
      "While greasy Joan doth keel the pot."
    ],
    "linecount": 18
  }
]

Format:

/<input field>,<input field>,<input field>,<input field>/<search term>;<search term>;<search term>;<search term>

Example:

/title,author,linecount,poemcount/Winter;William Shakespeare;14;1

Result:

[
  {
    "title": "Sonnet 2: When forty winters shall besiege thy brow",
    "author": "William Shakespeare",
    "lines": [
      "When forty winters shall besiege thy brow,",
      "And dig deep trenches in thy beauty's field,",
      "Thy youth's proud livery so gazed on now,",
      "Will be a tatter'd weed of small worth held:",
      "Then being asked, where all thy beauty lies,",
      "Where all the treasure of thy lusty days;",
      "To say, within thine own deep sunken eyes,",
      "Were an all-eating shame, and thriftless praise.",
      "How much more praise deserv'd thy beauty's use,",
      "If thou couldst answer 'This fair child of mine",
      "Shall sum my count, and make my old excuse,'",
      "Proving his beauty by succession thine!",
      "  This were to be new made when thou art old,",
      "  And see thy blood warm when thou feel'st it cold."
    ],
    "linecount": "14"
  }
]

Format:

/<input field>,<input field>/<search term>;<search term>/<output field>

Example:

/title,author/Winter;William Shakespeare/title

Result:

[
  {
    "title": "Spring and Winter ii"
  },
  {
    "title": "Spring and Winter i"
  },
  {
    "title": "Blow, Blow, Thou Winter Wind"
  },
  {
    "title": "Winter"
  }
]

Format:

/<input field>,<input field>/<search term>;<search term>/<output field>[.<format>]

Example:

/title,author/Winter;William Shakespeare/title.text

Result:

title
Spring and Winter ii

title
Spring and Winter i

title
Blow, Blow, Thou Winter Wind

title
Winter

Contact

Let me know of any documentation, bugs, or missing features you would like to see, or just come and say hi, on Twitter @po3db

License

To protect the openness of this endeavour the software is released under the terms of the GNU Public License v2. In essence it allows you to reuse and modify this software, as long as the resulting program(s) remain open and licensed in the same way.

poetrydb's People

Contributors

dependabot[bot] avatar klzheng avatar thundercomb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

poetrydb's Issues

Data source

Out of curiosity, where is the data sourced from?

Contributions/posting to DB

Is there any way we can add or contribute to the database? There's a ton of poems I'd love to see in here!

Heroku Application Error

Hi maintainers! This API is really great. There's this issue when getting the random/4 or any number after random. However, random/ works fine but random/4 or any number throws the attached error. It was working fine a couple of weeks ago.

Screenshot from 2020-09-23 22-49-15

Limit the number of results?

Some of my calls return a large amount of information, which is a lot to download and takes more time than is expected by most users. Is there a way to limit the number of results?

API Is Down

Upon querying the API, or visiting poetrydb.org, the following message is displayed:

Application error

An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.
You can do this from the Heroku CLI with the command heroku logs —tail

API AJAX Call

Guys I'm calling the API like this:
$(document).ready(function() { $("#submit").click(function(event) { var poet = $("#poet").val(); var title = $("#title").val(); var reppoet = poet.replace(" ", "%20"); var reptitle = title.replace(" ", "%20"); var url = <es6backtick>http://poetrydb.org/title,author/${reptitle};${reppoet}/author,title,linecount,lines.json</es6backtick>; $.ajax({ type: 'GET', url: url, success: function(data) { console.log(data); }, error: function(url){ console.log('Error!'+url); } }); }); });
It always goes to error and returns
"Error![object Object]"

Please help me out

Linecount comparison is not correct

If I query the following URL

http://poetrydb.org/linecount/5

then the output contains poems with the number of lines where 5 is encountered in linecount at any place.

To clarify,
For the above url, the output will contain poems with linecount as 25, 50, 105, 5, 15, etc.

If you specify it as http://poetrydb.org/linecount/10 it will return poems with linecount as 103, 105, 10, 100, etc.

So, basically there is a string.contains comparison that is taking place instead of a string.equals comparison.

Allow case insensitive search

When searching by title, I noticed that the search seems to be case-sensitive. Could you modify the code to make it case insensitive?

Parentheses in poem title

I'm trying to grab "Song (Go And Catch A Falling Star)" by John Donne via requests in python, but I think the url is not being encoded properly. If I paste "http://poetrydb.org/title/Song (Go And Catch A Falling Star)/lines.json" into the address bar, I get a 404. How do I properly format this request?

No access control allow-origin in header

I am having an issue (image attached). From searching online it looks like there is a line of code you could add on your end so that we would be able overcome this issue. I would greatly appreciate any help on this matter. I am very excited to work with this wonderful looking tool. thank you
screen shot 2016-10-20 at 9 23 37 am

Swagger/OAS

First of all, thanks for the great project 👍

And a question/suggestion here (potentially can help with a PR, if it's not opposed some internalized ideas/plans). Would be a big deal to add a Swagger (OAS) docs here for the API? Or maybe they are already present in some way?

Link to Author Webpage

Gunctionality for including a link to a web page with the author's information. Webpage can be authors personal webpages or the webpage from a larger poetry database

Expand test cases

Expand test cases to be more reflective of the different types of API calls.

It would be useful to expand the test cases to cover the various types of documented end points, particularly the different types of input fields, and a good variety of combination searches.

The existing tests for failure cases appear to be fairly comprehensive already.

Search and return random poems

There is already a simple endpoint to return a single random poem:

/random

It would be useful to combine this with other searches, for example to return 5 random Shakespeare sonnets:

/author,title,random/Shakespeare;Sonnet;5

Given the existing poemcount input and search fields, random and poemcount should be mutually exclusive.

Search for multiple terms not working

First the problem: when trying to search for two terms, authors in this case: this does not appear to give the results I believed I should expect... maybe I am misunderstanding something?

http://poetrydb.org/author/austen;bowles/title

Secondly, thank you so much for this wonderful database! It is invaluable for teaching about how to access apis with kids learning to code.

Thirdly, I know this isn't a support forum! But I promise I have tried to read the docs carefully :-) If I have simply misunderstood the api documentation, when I understand it, I promise I will write a suggested addition to the help files for people like me who are too dumb to work it out!

Best wishes

Getting all authors

Hi,

It seems like /authors only returns the first 128 authors. How do I get the rest?

Including poetry

I was building an api for my poetry. Is it ok to collaborate so I can include my poetry in poetry dB?

README.md formatting error

Hi, the documentation for the project is really good! But there seems to be some formatting errors towards the end of the README.md. If you go down and a little bit after the "Combinations" section, you can see that the code blocks are the titles, and the titles are in the code blocks

Random Poem call in JSON/AJAX

@thundercomb Do you know what parameters should I retrieve and pass in AJAX for getting a random poem? I tried understanding the ruby one but unfortunately I don't know ruby.

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.