garethbjohnson / gutendex

Web API for Project Gutenberg ebook metadata
https://gutendex.com
MIT License
213 stars 43 forks source link

Fetch book contents #24

Closed foobar404 closed 2 years ago

foobar404 commented 2 years ago

Is there an easy way to use the urls in "formats" to fetch a books contents. Im trying to use the url from "text/plain", but I get CORS errors from Gutenberg. Is the only way to fetch the url in my backend then redirect the results back to my frontend?

garethbjohnson commented 2 years ago

That is the approach I would use.

In case it helps, I made a project on Glitch that fetches anything from Gutenberg and returns it with a CORS header to allow any request origin. To use it, replace https://gutenberg.org in any Gutenberg URL with https://gutenberg-proxy.glitch.me, and it should just work. Example: https://gutenberg-proxy.glitch.me/files/1342/1342-h/1342-h.htm

However, I've noticed that requests to Glitch project take a long time if the project hasn't received a request in a while. Glitch might also have other traffic limitations, since it's free. It's probably fine for a hobby or learning project, but if you want something more reliable and responsive, then you might want to use a different web host. Feel free to copy the code from Glitch, though.

Does that help?

foobar404 commented 2 years ago

Requesting this url fails, "https://www.gutenberg.org/ebooks/1111.txt.utf-8", anything under /ebooks fails , but urls under /files and /cache work.

garethbjohnson commented 2 years ago

OK, I think I fixed it. Does it work for you now, and does that solve your initial issue?

foobar404 commented 2 years ago

Yes, /ebooks and /cache works now, thanks man.

foobar404 commented 2 years ago

Also are you still working on the project? Do you have any features you want help with, or have any stretch goals you want implemented?

garethbjohnson commented 2 years ago

I do not have any user features planned or in progress. Recently, someone made a pull request to make development and deployment easier for other developers, and so I have been working on that, but that is just a matter of me understanding and getting comfortable with the changes before I merge.

Feel free to suggest features or make pull requests yourself, though, if you have any ideas. (Simpler is better, or else I might take a long time to merge them.)