# Open Library Books Scraper - Search & Work Metadata (`ahmdshrif/openlibrary-books-scraper`) Actor

Queries the official openlibrary.org JSON search and works endpoints and returns flat book records with titles, authors, keys, editions, and availability.

- **URL**: https://apify.com/ahmdshrif/openlibrary-books-scraper.md
- **Developed by:** [Ahmed](https://apify.com/ahmdshrif) (community)
- **Categories:** Other, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

$0.70 / 1,000 per book results

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 Scraper

Runs Open Library search and work queries (by title, author, or any search.json URL) and returns flat, per-book records with titles, authors, publication years, edition counts, ebook access status, and Internet Archive lending identifiers. Built for developers, researchers, and librarians who need structured Open Library data without writing their own API client or parsing HTML.

### Why this scraper

- Reads directly from Open Library's official `search.json` and `works.json` endpoints, not scraped HTML, so author keys and Internet Archive identifiers come through reliably instead of being dropped or malformed.
- Priced at $0.0007 per result, lower than the closest comparable per-result offering, and cheaper overall than flat per-run pricing once you're pulling more than a handful of books.
- No login, no JS rendering, no anti-bot workarounds needed — the target API is public and returns plain JSON, so there's nothing fragile in the middle of the pipeline.

### Output fields

| Field | Type | Description |
|---|---|---|
| workKey | string | Open Library work key, e.g. /works/OL45804W |
| title | string | Book title |
| subtitle | string | Book subtitle if present |
| authorNames | string | Comma-separated author names |
| authorKeys | string | Comma-separated Open Library author keys |
| firstPublishYear | integer | Year of first publication |
| editionCount | integer | Number of known editions |
| ebookAccess | string | Ebook access level: public, borrowable, printdisabled, no\_ebook, etc. |
| hasFulltext | boolean | Whether a full-text scan is available |
| publicScan | boolean | Whether the scan is publicly readable |
| coverId | integer | Cover image ID |
| coverEditionKey | string | Edition key used to build the cover image URL |
| languages | string | Comma-separated language codes |
| subjects | string | Comma-separated subjects (from work detail endpoint) |
| iaIdentifiers | string | Comma-separated Internet Archive identifiers |
| lendingIdentifier | string | Internet Archive identifier used for lending |
| description | string | Work description text if available |

### Input

```json
{
  "startUrls": [
    { "url": "https://openlibrary.org/search.json?q=python&limit=20" }
  ],
  "maxItems": 50
}
```

`startUrls` accepts any Open Library `search.json` or `works/*.json` URL, including author searches like `https://openlibrary.org/search.json?author=tolkien&limit=20`. `maxItems` caps the total number of records returned across all start URLs.

### Output

```json
{
  "workKey": "/works/OL2784125W",
  "title": "Learning Python",
  "subtitle": "",
  "authorNames": "Mark Lutz,David Ascher",
  "authorKeys": "OL411267A,OL2726848A",
  "firstPublishYear": 1999,
  "editionCount": 23,
  "ebookAccess": "borrowable",
  "hasFulltext": true,
  "publicScan": false,
  "coverId": 1312568,
  "coverEditionKey": "OL9497269M",
  "languages": "ger,eng",
  "subjects": "",
  "iaIdentifiers": "einfuhrunginpyth0000lutz,learningpython00lutz,learningpythonth00lutz",
  "lendingIdentifier": "einfuhrunginpyth0000lutz",
  "description": ""
}
```

### Pricing

Pay-per-result: $0.0007 per book record returned. A search returning 200 books costs about $0.14; pulling 1,000 records costs about $0.70.

### Use cases

- Building a reading-list or library-catalog app that needs author keys and edition counts without maintaining an Open Library API integration.
- Academic or bibliometric research tracking edition counts, first-publish years, and language spread across an author's or subject's body of work.
- Checking ebook availability and Internet Archive lending identifiers in bulk before linking out to borrowable copies from a book-discovery site.

# Actor input Schema

## `startUrls` (type: `array`):

Pages to export.

## `maxItems` (type: `integer`):

Stop after this many records.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://openlibrary.org/search.json?q=python&limit=20"
    },
    {
      "url": "https://openlibrary.org/works/OL45804W.json"
    },
    {
      "url": "https://openlibrary.org/search.json?author=tolkien&limit=20"
    }
  ],
  "maxItems": 50
}
```

# Actor output Schema

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

One structured record per input URL.

# 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 = {
    "startUrls": [
        {
            "url": "https://openlibrary.org/search.json?q=python&limit=20"
        },
        {
            "url": "https://openlibrary.org/works/OL45804W.json"
        },
        {
            "url": "https://openlibrary.org/search.json?author=tolkien&limit=20"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ahmdshrif/openlibrary-books-scraper").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 = { "startUrls": [
        { "url": "https://openlibrary.org/search.json?q=python&limit=20" },
        { "url": "https://openlibrary.org/works/OL45804W.json" },
        { "url": "https://openlibrary.org/search.json?author=tolkien&limit=20" },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("ahmdshrif/openlibrary-books-scraper").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 '{
  "startUrls": [
    {
      "url": "https://openlibrary.org/search.json?q=python&limit=20"
    },
    {
      "url": "https://openlibrary.org/works/OL45804W.json"
    },
    {
      "url": "https://openlibrary.org/search.json?author=tolkien&limit=20"
    }
  ]
}' |
apify call ahmdshrif/openlibrary-books-scraper --silent --output-dataset

```

## MCP server setup

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

```

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/x1umuyMKmSZjDlMvZ/builds/H36iRdeos5G2M07MZ/openapi.json
