Package: bookops-worldcat
bookops-worldcatEarly ALPHA versionBookOps-Worldcat provides a Python interface for the WorldCat Metadata API.
This wrapper simplifies requests to OCLC web services making them ideally more accessible to OCLC member libraries.Due to major changes introduced by OCLC in May 2020, the version 0.3.0 of the wrapper dropped functionality related to WorldCat Search API. New search endopoints of the Metadata API supported in the 0.3.0 version should fill that gap. While WorldCat Metadata API is our primary focus, we plan in the future to expand wrapper's functionality to other related OCLC web services, including the now dropped Search API.InstallationUse pip:$ pip install bookops-worldcatDocumentationFor full documentation please seehttps://bookops-cat.github.io/bookops-worldcat/FeaturesThis package takes advantage of the functionality of the popularRequests library. Interactions withOCLC's services are built around 'Requests' sessions. Authorizing a web service session simply requires passing an access token toMetadataSession. Opening a session allows the user to call specific methods to facilitate communication between the user's script/client and particular endpoint of OCLC API service. Many of the hurdles related to making valid requests are hidden under the hood of this package, making it as simple as possible.
Please note, not all endpoints of the Metadata API are implemented at the moment.  This tool was primarily built for the specific needs of BookOps but we are open to collaboration to expand and improve this package.At the moment, BookOps-Worldcat supports requests to following OCLC's web services:Authentication via Client Credential GrantWorldcat Metadata APIMetadata API Search Functionalitymember shared print holdingsmember general holdingssearching bibliographic resources:search brief bibsretrieve specific brief bibretrieve other editions related to a specific bibliographic resourceMetadata APIbibliographic recordsretrieve full bibfind current OCLC numberholdingsset institution holding for a single resourceunset institution holding for a single resourceretrieve holding status of a single resourceset institution holdings for a batch of resourcesunset institution holdings for a batch of resoucesset holdings for a single resource for multiple institutionsunset holdings for a single resource for multiple institutionsBasic usage:Obtaining access token>>>frombookops_worldcatimportWorldcatAccessToken>>>token=WorldcatAccessToken(key="my_WSkey",secret="my_WSsecret",scopes="selected_scope",principal_id="my_principalID",principal_idns="my_principalIDNS",agent="my_client")>>>print(token.token_str)"tk_Yebz4BpEp9dAsghA7KpWx6dYD1OZKWBlHjqW"Metadata API>>>frombookops_worldcatimportMetadataSession>>>session=MetadataSession(authorization=token)>>>result=session.get_brief_bib(oclcNumber=1143317889)>>>print(result)<Response[200]>>>>print(result.json()){"oclcNumber":"1143317889","title":"Blueprint : the evolutionary origins of a good society","creator":"Nicholas A. Christakis","date":"2020","language":"eng","generalFormat":"Book","specificFormat":"PrintBook","edition":"First Little, Brown Spark trade paperback edition.","publisher":"Little, Brown Spark","catalogingInfo":{"catalogingAgency":"NYP","transcribingAgency":"NYP"}}Using a context manager:withMetadataSession(authorization=token)assession:results=session.get_full_bib(1143317889)print(results.text)<?xml version="1.0" encoding="UTF-8"?><entryxmlns="http://www.w3.org/2005/Atom"><contenttype="application/xml"><responsexmlns="http://worldcat.org/rb"mimeType="application/vnd.oclc.marc21+xml"><recordxmlns="http://www.loc.gov/MARC21/slim"><leader>00000cama2200000i4500</leader><controlfieldtag="001">on1143317889</controlfield><controlfieldtag="003">OCoLC</controlfield><controlfieldtag="005">20200328101446.1</controlfield><controlfieldtag="008">200305t20202019nyuabfb0010engc</controlfield><datafieldtag="010"ind1=" "ind2=" "><subfieldcode="a">2018957420</subfield></datafield><datafieldtag="040"ind1=" "ind2=" "><subfieldcode="a">NYP</subfield><subfieldcode="b">eng</subfield><subfieldcode="e">rda</subfield><subfieldcode="c">NYP</subfield><!--...--><datafieldtag="020"ind1=" "ind2=" "><subfieldcode="a">9780316230049</subfield><subfieldcode="q">(pbk.)</subfield><!--...--><datafieldtag="100"ind1="1"ind2=" "><subfieldcode="a">Christakis,NicholasA.,</subfield><subfieldcode="e">author.</subfield></datafield><datafieldtag="245"ind1="1"ind2="0"><subfieldcode="a">Blueprint:</subfield><subfieldcode="b">theevolutionaryoriginsofagoodsociety/</subfield><subfieldcode="c">NicholasA.Christakis.</subfield></datafield><datafieldtag="250"ind1=" "ind2=" "><subfieldcode="a">FirstLittle,BrownSparktradepaperbackedition.</subfield></datafield><datafieldtag="264"ind1=" "ind2="1"><subfieldcode="a">NewYork,NY:</subfield><subfieldcode="b">Little,BrownSpark,</subfield><subfieldcode="c">2020</subfield></datafield><!--...--></record></response></content><id>http://worldcat.org/oclc/1143317889</id><linkhref="http://worldcat.org/oclc/1143317889"></link></entry>ChangelogConsult theChangelog pagefor fixes and enhancements of each version.Bugs/RequestsPlease useGithub issue trackerto submit bugs or request features.TodoMetadata API:support for local holdings resources endpoints of the search functionality of the Metadata APIsupport for local bibliographic data endpointsrecord validation endpointsmethods to create and update bibliographic records