TL;DR
Open Library Subjects lets you browse books by any topic — "love", "science fiction", "history", "python" — and returns a curated list of works with covers, authors, and publication data. It is the thematic browsing layer of Open Library, perfect for building "books about X" features. Subjects include topical tags, genre classifications, places, people, and time periods. The API supports pagination, details mode, and returning publisher info and edition counts.
Quick start: https://openlibrary.org/subjects/love.json
No API key needed — just make a request!
How to Use This API
1. Browse a Subject
https://openlibrary.org/subjects/love.json
2. With Details Mode
https://openlibrary.org/subjects/space_exploration.json?details=true
Details mode adds publisher info, ISBNs, and full author objects to each work entry.
3. Pagination and Limiting
https://openlibrary.org/subjects/philosophy.json?limit=20&offset=40
Use limit (default 50, max 1000) and offset for pagination. The response includes work_count for total results.
4. Multi-word and Nested Subjects
https://openlibrary.org/subjects/computer_science.json
https://openlibrary.org/subjects/science_history.json
Use underscores for spaces. Subjects can be hierarchical — /subjects/science.json gives broad science, /subjects/science_fiction.json gives a sub-genre.
5. Response Format
{
"key": "/subjects/love",
"name": "love",
"work_count": 1234,
"works": [
{
"key": "/works/OL123W",
"title": "Romeo and Juliet",
"first_publish_year": 1597,
"edition_count": 500,
"cover_id": 12345,
"cover_edition_key": "OL123M",
"authors": [{"name": "William Shakespeare", "key": "/authors/OL1A"}],
"subjects": ["love", "tragedy", "drama"]
}
]
}
6. JavaScript — Books by Subject
fetch('https://openlibrary.org/subjects/science_fiction.json?limit=5')
.then(r => r.json())
.then(d => {
console.log(`Found ${d.work_count} works on "${d.name}"`);
d.works.forEach(w => {
const authors = w.authors?.map(a => a.name).join(', ') || 'Unknown';
console.log(`${w.title} (${w.first_publish_year}) — ${authors}`);
});
});
7. Python — Top Books on a Topic
import requests
resp = requests.get('https://openlibrary.org/subjects/philosophy.json', params={
'limit': 10, 'details': True
})
data = resp.json()
for work in data['works']:
authors = ', '.join(a['name'] for a in work.get('authors', []))
print(f"{work['title']} ({work['first_publish_year']}) — {authors}")
print(f" Editions: {work['edition_count']}")
if 'publishers' in work:
print(f" Publishers: {', '.join(work['publishers'][:3])}")
8. Python — Paginate Through All Results
import requests
subject = 'artificial_intelligence'
all_works = []
page = 0
page_size = 100
while True:
resp = requests.get(
f'https://openlibrary.org/subjects/{subject}.json',
params={'limit': page_size, 'offset': page * page_size}
)
data = resp.json()
works = data.get('works', [])
if not works:
break
all_works.extend(works)
page += 1
print(f"Total works found: {len(all_works)}")
https://openlibrary.org/subjects/love.json?limit=3
Frequently Asked Questions
- What subjects are available?
- Thousands of subjects from the Open Library classification system. Use any topic as the URL path — lowercase, underscores for spaces. Subjects include topical (love, science), genre (fiction, mystery), place-related (paris), and people-related (shakespeare).
- How do I paginate through results?
- Use
limit(default 50, max 1000) andoffset(0-based) parameters. The response includeswork_countfor total books in the subject. Iterate usingoffsetincrements of yourlimitvalue. - What data does each work include?
- Title, author(s), first publish year, edition count, cover IDs, subject/keyword lists, and a key for the full work endpoint. With
details=trueyou also get publisher info, ISBNs, and full author objects. - Can I get subcategories or nested subjects?
- Yes, subjects can be hierarchical. Try
/subjects/science.jsonfor broad subjects. Nested subjects likescience_fictionandscience_historyshow specific sub-topics. Thesubjectsfield in each work lists all related topics. - How do I get cover images for the books?
- Use
cover_idfrom the work object:https://covers.openlibrary.org/b/id/{cover_id}-L.jpgfor large,-M.jpgfor medium,-S.jpgfor small. Ifcover_edition_keyis present, usehttps://covers.openlibrary.org/b/olid/{key}-L.jpg. - What's the rate limit?
- Open Library has no documented rate limit for the subjects API, but please keep requests moderate. Caching results is recommended for production apps.
- Can I use this API in a commercial app?
- Yes, Open Library data is public domain. The API is free for any use including commercial applications. Attribution to Open Library is appreciated.
What You Can Build
- "Books about X" feature — show a curated book list for any topic a user searches
- Subject-based book discovery app with cover thumbnails and author info
- Reading list generator — get top books on philosophy, science, or self-improvement
- Academic research tool — find key works in any field sorted by edition count
- Bookstore/widget display showing trending subjects with cover art