US
Writing Bots | Open Library Docs
Writing Bots | Open Library Docs
Skip to content
Writing Bots
For legacy documentation, please check the
Open Library Archives
. Most Bot code now lives at
Introduction
If you encounter recurring metadata errors on Open Library editions, works, or authors; notice duplicate authors that should be merged; find fake books that should be deleted; or want to import missing books from other sources, these tasks can be handled by bot accounts.
Open Library bot accounts make HTTP POSTs to work, author, edition, and subject pages to correct metadata or create and import new records (books, authors, book covers) in bulk.
Applying for a Bot Account
To apply for a privileged bot account:
Register a new Open Library account
that meets these guidelines:
The bot account must be
separate
from your personal Open Library account.
The username must end with "Bot" (for example,
WorkBot
ImportBot
).
These conventions enable
filtering Recent Changes by bots
to identify changes made by bot accounts. Bots perform repetitive operations at high frequency and would overwhelm the list if shown alongside human edits.
Open a GitHub issue and ask a site admin (for example, @mekarpeles) to grant bot privileges to your account and
add it to the "API" usergroup
Getting Started: Rules
Q: I have written a bot. Am I ready to run it?
If your bot script is ready, fork the
repository, create a new branch, add a directory named according to the action your bot will perform, and submit a PR for review. Do not run bulk modifications until @mekarpeles has reviewed and approved your script, or your bot privileges may be revoked.
Q: My bot reads metadata from a source file and modifies records on Open Library. Should these source data files be saved?
Yes. If your bot adds new or updated metadata from files, commit those files with your script to
openlibrary-client Library
Instead of making POSTs directly to API endpoints using a
bot account
, use the official Python client library
openlibrary-client
, which streamlines metadata updates and bot development. The older
openlibrary/api.py
library has been deprecated in favor of the easier and safer
openlibrary-client
Click here for instructions on installing and using the openlibrary-client
Bot Account Etiquette
Avoid using bot accounts directly for one-off changes from the command line. Instead, code changes into bot scripts and check them into the
openlibrary-bots
repository. This allows the team to review what changes were made, debug issues, and update or re-apply logic as needed.
Example Bots
Here's an example by @hornc of a bot that uses openlibrary-client for merging works and editions and updating records in bulk
The following
legacy examples
used
api.py
(now deprecated) instead of openlibrary-client. They illustrate what Open Library bots do, how they are written, and how they are used. Refer to the
openlibrary-client documentation
for modern examples:
Daniel's IdentifierBot
Ben's Goodreads bot
AMillarBot
oclcBot, by Bruce Washburn
Bot Opportunities
Migrated to
Also see
Ideas for new bots