The Bookshare website has a new look!Learn what’s new and what’s coming
Donate
Bookshare home

API V1.0 to API V2.0 Migration Guide

Notice: The Bookshare API V1 will be sunset on June 30, 2024 and will no longer be available. Partners will need to migrate to API V2 to continue accessing the Bookshare collection after that date. Learn about API V2.

Introduction

Moving an application from the Bookshare API v1 to v2 will involve some straightforward changes to endpoint URIs and some changes to the general usage of the API, such as paging technique and user authentication. There isn’t a defined order in which changes need to be made, and they can be done in phases if you wish. Once you have implemented an OAuth2 based authentication flow, your app could even go through a hybrid phase of using both API versions since both sets of endpoints will accept an OAuth2 token (more about that below).

The notes below highlight some of the differences to be aware of when transitioning to the new API. Refer to the full reference documentation for detailed information and examples of each endpoint and resource.

Authentication and Authorization

The API v2 uses OAuth2 to define the process for authentication and authorization, which may be the most significant change to how your app operates. The v2 documentation explains the scenarios for user and system interaction that you can choose to support.

In particular, you will need to do two important things:

  1. Define an endpoint in your app that can be called by Bookshare at the end of the authentication process.
  2. Register the URI of that endpoint with Benetech before the OAuth2 process will work, since it is used to verify that authentication callbacks from Bookshare are coming from your API key only to avoid someone trying to spoof your app. You can do that by sending an email to partner-support@bookshare.org

Once you have an app endpoint defined and registered you should be able to test out authenticated calls with any of your test accounts. To aid in the transition, the OAuth2 token that you receive from this process can be used with the API v1 as well. Simply send an authorization header with the token as a bearer token (“Authorization: Bearer <token value>”) rather than sending the custom header of v1 (“X-Password:<password hash>”).

Media Types

Note in the Media Types section that all responses come back as JSON and that UTF-8 is the default encoding.

Pagination

The API v2 replaces the “offset” parameter on listings endpoints with a “next” parameter so that paging is one-directional as far as the API is concerned. Any endpoint with more results than the “limit” amount will also have a “next” link item in the JSON that is a full URL that can be used.

User Roles

In the API v1 a user might be an individual member, an organization member or an organizational sponsor. In v2 these same roles are supported but their capabilities are hinted at through a more general mechanism of links and [capabilities] that are in JSON responses. For example, you might infer that a user is an organizational sponsor if they have a “members” link in the JSON resource that is returned from the /myaccount endpoint, and you can use the URL in that members link to get a list of the organization members. Further, the “allows” values in JSON responses are hints for the capabilities that could be offered to this user to make modifications to a resource.

Error Responses

The API v2 does not have custom error codes for error responses. Instead the HTTP status code will convey the general result and the JSON response will have descriptive text about the problem. Note that this is meant for diagnostic use and is not necessarily text meant to be shown directly to users.

Endpoint Mappings

API V1.0 URIDetailsAPI V2.0 URIAPI V2.0 Documentation
api.bookshare.org/book/isbn/TextISBN Lookupapi.bookshare.org/v2/titles?isbn={isbn}Title Search
api.bookshare.org/book/id/NumberBook Id Lookupapi.bookshare.org/v2/titles/{bookshareId}}Title Metadata
api.bookshare.org/book/searchFTS/TextFull Text Searchapi.bookshare.org/v2/titles?keyword={text}Title Search
api.bookshare.org/book/search/title/TextTitle Searchapi.bookshare.org/v2/titles?title={title}Title Search
api.bookshare.org/book/search/author/TextAuthor Searchapi.bookshare.org/v2/titles?author={author}Title Search
api.bookshare.org/book/search/TextTitle/Author Searchapi.bookshare.org/v2/titles?keyword={text}Title Search
api.bookshare.org/book/search/since/DateDate Published Searchapi.bookshare.org/v2/titles?sortOrder=copyrightDate&direction=descTitle Search
api.bookshare.org/book/latestLatest books added to Bookshareapi.bookshare.org/v2/titles?sortOrder=dateAdded&direction=descTitle Search
api.bookshare.org/book/popularPopular books on BookshareThe automated popular list is no longer supported.
For curated lists:

api.bookshare.org/v2/popularLists
For automated recommendations:
api.bookshare.org/v2/myRecommendations
Popular Lists
Recommendations
api.bookshare.org/reference/category/listCategory Listapi.bookshare.org/v2/categoriesCategories
api.bookshare.org/book/search/category/TextCategory Searchapi.bookshare.org/v2/titles?categories={categories}Title Search
api.bookshare.org/reference/grade/listGrade ListNot Available
api.bookshare.org/book/search/grade/TextGrade Searchapi.bookshare.org/v2/titles?readingAge={readingAge}Title Search
api.bookshare.org/periodical/id/NumberPeriodical Edition Searchapi.bookshare.org/v2/periodicals/{seriesId}/editionsPeriodical Editions
api.bookshare.org/periodical/id/Number/edition/Date/revision/NumberPeriodical Edition LookupNot Available
api.bookshare.org/periodical/listPeriodical List Searchapi.bookshare.org/v2/periodicalsPeriodical Search
api.bookshare.org/download/content/Number/version/NumberGenerally Available Download Requestapi.bookshare.org/v2/titles/{bookshareId}/{format}Title Download
api.bookshare.org/download/content/Number/version/Number/for/TextUser Authenticated Download RequestFor Books:
api.bookshare.org/v2/titles/{bookshareId}/{format}
For Periodicals:
api.bookshare.org/v2/periodicals/{seriesId}/editions/{editionId}/{format}
Title Download
Periodical Download
api.bookshare.org/download/member/Text/content/Number/version/Number/for/TextOrganizational Download Requestapi.bookshare.org/v2/titles/{bookshareId}/{format}?forUser={user}Title Download
api.bookshare.org/user/preferences/list/for/TextUser Preference Listapi.bookshare.org/v2/myaccount/preferencesAccount Preferences
api.bookshare.org/user/preference/Number/set/Text/for/TextUser Preference Modificationapi.bookshare.org/v2/myaccount/preferencesUpdate Account Preferences
api.bookshare.org/user/info/display/for/TextUser Infoapi.bookshare.org/v2/myaccountAccount Summary
api.bookshare.org/user/history/for/TextUser Historyapi.bookshare.org/v2/myaccount/historyAccount Downloads
api.bookshare.org/user/members/list/for/TextOrganizational Member Listapi.bookshare.org/v2/myOrganization/members