openlibrary
openlibrary copied to clipboard
CORS errors on Partner API Single-request and Multi-request endpoints
Calling the /volumes/brief
endpoints using native Node.js fetch()
results in CORS errors.
Evidence / Screenshot (if possible)
Relevant url?
Single GET - http://openlibrary.org/api/volumes/brief/isbn/0596156715.json Multi GET - http://openlibrary.org/api/volumes/brief/json/isbn:0596156715
Steps to Reproduce
The following snippet recreates the issue;
const OpenLibTest = async () => {
(await fetch('http://openlibrary.org/api/volumes/brief/isbn/0596156715.json'))
.json()
.then((data) => {
console.log(data);
});
};
OpenLibTest();
- Actual:
- CORS error returned from API
- Expected:
- Data to be returned due to using specified JSON endpoints
Details
- Logged in (Y/N)? N/A
- Browser type/version? Chrome rendering Vue/Angular apps
- Operating system? Windows 11 / macOS Ventura
- Environment (prod/dev/local)? prod
Proposal & Constraints
I believe the endpoints may just need amending to follow the same logic as in https://github.com/internetarchive/openlibrary/issues/329 and https://github.com/internetarchive/openlibrary/issues/220
I think you probably want to be using the openlibrary.org/search.json?q= API!
@mekarpeles Ahh yup - multiple ISBNs working nicely with random example after some digging (Plus returns a much nicer range of data!): https://openlibrary.org/search.json?q=isbn:9780241575536+OR+isbn:0596156715&fields=title,isbn,author_name Happy to close this one then, though maybe worth a clarifying note on the documentation for the Partner API to clarify those aren't CORS friendly!
is this issue still Relevant?
@BrentOates Depending on what your goal is, this query might be a little more useful:
https://openlibrary.org/search.json?q=isbn:9780241575536+OR+isbn:0596156715&fields=key,title,author_name,editions,editions.title,editions.isbn
This fetches the edition-specific info about the ISBN as well :+1: