Skip to content

Instantly share code, notes, and snippets.

@e-io
Created September 21, 2023 10:32
Show Gist options
  • Save e-io/61fdb686fe10d36d39d2d163625e5691 to your computer and use it in GitHub Desktop.
Save e-io/61fdb686fe10d36d39d2d163625e5691 to your computer and use it in GitHub Desktop.
Show authors of a book by ISBN with Google Books API (Python).
# How to run:
# python3 request-authors-by-isbn-with-gbooks-api.py
# just write required isbn in the "isbn = ..." line below
import json
import requests
# example of isbn. It can be 10 digits or 13 digits. It can be with hyphens or without them.
isbn = "978-1-119-70711-0"
url = "https://www.googleapis.com/books/v1/volumes?q=isbn:" + isbn
response = requests.get(url)
print (response)
data = response.json()
# all information
# print(json.dumps(data, indent=2))
authors = data['items'][0]['volumeInfo']['authors']
print("authors:")
for author in authors:
print('\t', author)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment