Many Open Library actions (like creating Works and Editions) require
authentication, i.e. certain requests must be provided a valid cookie
of a user which has been logged in with their openlibrary account
credentials. The openlibrary-client can be configured to “remember
you” so you don’t have to provide credentials with each request.

First time users may run the following command to enable the “remember
me” feature. This process will ask for a username and password and
save them in ~/.config/ol.ini (or whichever config location the user
has specified). In the next version, the password will not be stored;
instead the account will be authenticated and the username and
resulting cookie (and not the password) will be stored in the config:

One thing to consider in the snippet above is that work.editions is a
@property which makes several http requests to OpenLibrary in order to
populate results. Once a call has been made to work.editions, its
editions are saved/cached as work._editions.

Installing the openlibrary-client library will also install the ol
command line utility. Right now it does exactly nothing.

$ ol

~usage: ol [-h] [-v] [–get-work] [–get-book] [–get-olid] [–olid OLID]

[–isbn ISBN] [–title TITLE]

optional arguments:

-h, --help

show this help message and exit

-v

Displays the currently installed version of ol

--configure

Configure ol client with credentials

--get-work

Get a work by –title, –olid

--get-book

Get a book by –isbn, –olid

--get-olid

Get an olid by –title or –isbn

--olid OLID

Specify an olid as an argument

--isbn ISBN

Specify an isbn as an argument

--create CREATE

Create a new work from json

--title TITLE

Specify a title as an argument

--username USERNAME

An OL username for requests which require
authentication. You will be prompted discretely for a
password

You can create a new work from the command line using the following
syntax. It’s almost identical to the olclient.common.Book object
construction, except instead of providing an Author object, you
instead pass a key for “author” and a corresponding value: