[Python] Issues retrieving books by ISBN using Google Books API

Discussão em 'Python' iniciado por Stack, Abril 15, 2025.

  1. Stack

    Stack Membro Participativo

    I’m building my own “online library” app and I’m retrieving book data using the Google Books API. The API works in general, but I’m running into issues specifically when searching by ISBN.

    For most books I’ve tried, searching by ISBN returns no results. However, if I use the Google Books book ID, the book is found correctly.

    I’d like to rely on ISBN search — for example, by scanning a barcode — but right now that approach is unreliable. Has anyone experienced this issue or knows a workaround?

    Any help would be appreciated!

    P.S. I also tried the Open Library API and encountered the same issue with ISBNs returning no results.

    The function that I'm using:

    def search_for_books(isbn, max_results=3):
    if not isinstance(max_results, int):
    max_results = 3
    API_ENDPOINT = 'https://www.googleapis.com/books/v1/volumes'
    params = {'q': f'isbn:{isbn}', 'maxResults': max_results}
    try:
    res = requests.get(API_ENDPOINT, params=params)
    return res.json()
    except requests.exceptions.RequestException:
    return []


    Output when a ISBN is not found:

    {'kind': 'books#volumes', 'totalItems': 0}

    Continue reading...

Compartilhe esta Página