Text API?

Hello I am just wondering. What API’s do i use to get small texts or large ones like these from typeracer.

Hi I saw your other “conspiracy” topic.

Can you elaborate on your question?
e.g. are you just trying to fetch a text file over http?
What programming language are you using and/or what kind of platform to serve your website?
Would you prefer to cache the text e.g. in a database, or in a directory or in memcached before serving it?

What is it exactly you’re after?

Can you elaborate on your question?

No? If you look at typeracer some texts are randomly fetched from some kind of database. Now I assume that the website does not own that database themselves so they are probably using some API / service to fetch texts. So the question is what API / services are there for this purpose.

e.g. are you just trying to fetch a text file over http?

Yeah basically. Just a short snippet of text like on the website.

What programming language are you using and/or what kind of platform to serve your website?

Javascript or AJAX through PHP. Though preferably only client side JS.

Would you prefer to cache the text e.g. in a database, or in a directory or in memcached before serving it?

uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuh. I mean yeah that works too. Though in that case I would update the collection of cached texts every day or other day so that the texts are not the same every time. Or that i pull a large amount of text like a few gigabytes so the quantity makes it seem random. But in that case I’d still need some kind of API to fetch that much random snippets / books / text.

If you’re using an AJAX call to get text from a different website you’re going to have a bad time. CORS is going to block that in every modern browser. You’re better off doing that on the server side.

You could just download top 100 books from project Gutenberg, split on sentences, do lots of filtering and voila. It’s probably less than 1GB in size, probably less than 100MB compressed in indexable form e.g. like in an sqlite file (I’m guessing). You could probably just open it for readonly and grab a sentence or a paragraph. With a large enough DB you don’t ever have to regen probably.

1 Like

yeah uh thanks for mentioning project Gutenberg i didn’t know about that. Now I’ll have to figure out some way of downloading the top 100 or more books without having to do it manually.

yeah this should be doable with some javascript i guess. let’s try