# Open Library books - search, editions, authors (public API) (`retrainmap/open-library-books`) Actor

Open Library book search on the public API: one row per work - title, authors, first publish year, edition count, ISBNs, subjects, languages, publishers, cover URL, ratings, page count, URL. Filter by query, title, author, subject, year range, language. No key. $5 per 1,000 rows + $0.10 per run.

- **URL**: https://apify.com/retrainmap/open-library-books.md
- **Developed by:** [RetrainMap Team](https://apify.com/retrainmap) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 records

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Open Library books - search, editions, authors (public API)

**Returns:** one row per Open Library work (book): key, title, subtitle, authors (names + keys + URLs), first publish year, edition count, ISBNs, subjects, languages, publishers, median page count, member ratings and reading counts, full-text / e-book availability, cover URL, Open Library URL.
**Input:** `{ "query": "python programming", "max_records": 100 }` or `{ "author": "tolkien", "subject": "fantasy", "first_publish_year_from": 1930, "first_publish_year_to": 1980, "sort": "rating" }` — at least one of query, title, author, subject.
**Price:** $5.00 per 1,000 rows ($0.005 per work row) plus $0.10 per run. Pay per event; no subscription.

Search Open Library's catalogue of 20+ million works by free text, title, author, subject,
first-publish-year range and language — sorted by relevance, year, rating or edition count —
and get a flat, normalised row per work, ready for CSV or JSON: reading lists, ISBN lookups for
a subject, author bibliographies, "books about X published between Y and Z". No key, no
login: the public `openlibrary.org/search.json` API.

**The default input (query `python programming`, 100 rows) succeeds within 5 minutes and
returns rows** — Apify auto-tests it daily.

### Data source and status

| | |
|---|---|
| Publisher | Open Library, a project of the Internet Archive (https://openlibrary.org) |
| API | `GET /search.json?q=&title=&author=&subject=&language=&sort=&fields=&limit=100&page=` — public, no key. Documentation: https://openlibrary.org/dev/docs/api/search |
| What this Actor reads | Plain GET requests with an explicit `fields` list, at most one per `request_interval_ms` (default 1,000 ms, floor 500 ms); year ranges use the Solr field query `first_publish_year:[FROM TO TO]` |
| Identification | Open Library asks API users to send a descriptive User-Agent with a contact (https://openlibrary.org/developers/api). The Actor sends its product-token User-Agent with the contact e-mail in the comment **and** in the standard `From:` header |
| Refresh cadence | Live on every run; `fetched_at` on each row is the fetch time |
| Licence / attribution | Open Library data are open — the catalogue is released under a public-domain / CC0 style licence for records, but **please credit Open Library / Internet Archive** when you republish. Cover images (`cover_url`) are served by covers.openlibrary.org under their own usage terms (do not hot-link at scale) |
| Known caveats | Rows are *works*, not editions: `isbn` lists ISBNs across all editions (cut to 10; `isbn_count` is the total), `subjects` is cut to 25 (`subject_count` is the total); `rating_average`/`rating_count` and the reading counts come from Open Library members and are empty for most works; `first_publish_year` can be missing or wrong on community-edited records; the search index lags catalogue edits by minutes to hours; deep paging beyond a few thousand rows gets slow on the API side |

Honesty note: the rows are the search API's own work-level fields renamed and flattened —
nothing is inferred, summarised or classified by this Actor, and a run stops with an error
rather than guess when the API's shape changes.

### Input

| Field | Type | Meaning |
|---|---|---|
| `query` | string | Free text (title, author, subject, text). Solr field syntax such as `publisher:penguin` works |
| `title` | string | Title words |
| `author` | string | Author name |
| `subject` | string | Subject, e.g. `fantasy`, `machine learning` |
| `first_publish_year_from` / `first_publish_year_to` | integer | Inclusive year bounds |
| `language` | string | 3-letter MARC code: `eng`, `fre`, `ger`, `spa`, `jpn` |
| `sort` | string | `relevance` (default), `new`, `old`, `rating`, `editions`, `title` |
| `max_records` | integer | Default 100, at most 10,000 |
| `request_interval_ms` | integer | Default 1000 (floor 500) |
| `contact_email` | string | Sent in the User-Agent comment and the `From:` header |

Example — Tolkien's English-language fantasy works first published 1930-1980, best rated first:

```json
{ "author": "tolkien", "subject": "fantasy", "first_publish_year_from": 1930, "first_publish_year_to": 1980, "language": "eng", "sort": "rating", "max_records": 25 }
```

### Output (dataset row)

`key` (`/works/OL27482W`), `work_id`, `title`, `subtitle`, `authors`, `author_keys`,
`author_urls`, `first_publish_year`, `edition_count`, `isbn_count`, `isbn` (first 10),
`subject_count`, `subjects` (first 25), `languages`, `publishers` (first 10), `pages_median`,
`rating_average`, `rating_count`, `want_to_read_count`, `currently_reading_count`,
`already_read_count`, `has_fulltext`, `ebook_access`, `archive_org_ids`, `first_sentence`,
`cover_id`, `cover_url` (medium JPEG), `cover_edition_key`, `url`, `json_url`, `fetched_at`,
`source`.

A run summary (filters, Open Library's own match count, pages, requests, whether the
pay-per-event budget stopped the run) is stored as `RUN_SUMMARY` in the run's key-value store.

### Pricing (pay per event)

| Event | Price |
|---|---|
| `run-start` — once per run | $0.10 |
| `record` — per row written | $0.005 |

The default run (100 rows) costs $0.60; 1,000 work rows cost $5.10. Rows stop when your
run's maximum charge is reached; the run summary says so.

### Operator

Steelyard Ventures LLC (RetrainMap) — info@steelyardclinical.com. Not affiliated with Open
Library or the Internet Archive. The Actor writes only to its own dataset and key-value
store; it stores no credentials and sends nothing else.

# Actor input Schema

## `query` (type: `string`):

Free text matched against title, author, subject and text (Open Library search syntax; Solr field queries such as publisher:penguin work too).

## `title` (type: `string`):

Optional title words (the API's title= parameter).

## `author` (type: `string`):

Optional author name, e.g. tolkien, Ursula K. Le Guin.

## `subject` (type: `string`):

Optional subject, e.g. fantasy, machine learning, history.

## `first_publish_year_from` (type: `integer`):

Optional inclusive lower bound on the work's first publish year.

## `first_publish_year_to` (type: `integer`):

Optional inclusive upper bound.

## `language` (type: `string`):

Optional 3-letter MARC language code: eng, fre, ger, spa, jpn ...

## `sort` (type: `string`):

relevance (default), new / old (first publish year), rating, editions (edition count), title.

## `max_records` (type: `integer`):

Stop after this many work rows have been written.

## `request_interval_ms` (type: `integer`):

Politeness delay towards openlibrary.org (it asks for at most a few requests per second). Each request returns up to 100 works; floor 500 ms.

## `contact_email` (type: `string`):

Open Library asks API users to identify themselves with a contact; it is sent in the User-Agent comment and the standard From: request header (RFC 9110 s10.1.2).

## Actor input object example

```json
{
  "query": "python programming",
  "sort": "relevance",
  "max_records": 100,
  "request_interval_ms": 1000,
  "contact_email": "info@steelyardclinical.com"
}
```

# Actor output Schema

## `results` (type: `string`):

Every matched work as one row: title, authors, first publish year, edition count, ISBNs, subjects, languages, publishers, cover URL, ratings, URL.

## `results_csv` (type: `string`):

The same rows as a CSV file.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "query": "python programming"
};

// Run the Actor and wait for it to finish
const run = await client.actor("retrainmap/open-library-books").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "query": "python programming" }

# Run the Actor and wait for it to finish
run = client.actor("retrainmap/open-library-books").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "query": "python programming"
}' |
apify call retrainmap/open-library-books --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,retrainmap/open-library-books"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/hSUYSatgLWQiimcIc/builds/gdbfhwl3tQWwnkuCP/openapi.json
