thundercomb / poetrydb

The Internet's first Poetry API
http://poetrydb.org
GNU General Public License v2.0
523 stars 35 forks source link

Set maximum linecount #40

Open NicoleJaneway opened 3 years ago

NicoleJaneway commented 3 years ago

Is there a way to set a maximum linecount when returning random poems? Thanks!

jamogriff commented 3 years ago

@NicoleJaneway In a way, yes. poetrydb.org/linecount/x where x is an integer of your choosing returns poems with exactly that line count. For example, for x = 10, the endpoint will only return poems that have a line count of ten. I made a helper method for my use case to generate a random number up to my desired max line-count to hit the API to kind of simulate max line-count.

NicoleJaneway commented 3 years ago

Thanks, @jamogriff

Right now, the workaround I'm using is to requery the API if the random poem returned has a line length > the desired maximum.

mystictide commented 2 years ago

Please reconsider adding a maximum linecount.

sebastian-j-ibanez commented 10 months ago

I would absolutely love this functionality!

It would also reduce traffic, since users would not need to requery the API when the poem length is larger than what they need.