Package: habanero
habaneroThis is a low level client for working with Crossref’s search API. It’s been named to be more generic, as other organizations are/will adopt Crossref’s search API, making it possible to interact with all from one client.Crossref API docsOther Crossref API clients:Ruby:serrano,https://github.com/sckott/serranoCrossref’s API issue tracker:https://gitlab.com/crossref/issueshabaneroincludes three modules you can import as needed (or
import all):Crossref- Crossref search API. TheCrossrefmodule includes methods matching Crossref API routes, and a few convenience methods for getting DOI agency and random DOIs:works-/worksroutemembers-/membersrouteprefixes-/prefixesroutefunders-/fundersroutejournals-/journalsroutetypes-/typesroutelicenses-/licensesrouteregistration_agency- get DOI minting agencyrandom_dois- get random set of DOIscounts- citation counts. Includes the singlecitation_countmethodcn- content negotiation. Includes the methods:content_negotiation- get citations in a variety of formatscsl_styles- get CSL styles, used incontent_negotationmethodWorksContainer- A class for handling Crossref works. Pass output of works from methods on theCrossrefclass to more easily extract specific fields of works.Note about searching:You are using the Crossref search API described athttps://api.crossref.org/swagger-ui/index.html. When you search with query terms, on Crossref servers they are not searching full text, or even abstracts of articles, but only what is available in the data that is returned to you. That is, they search article titles, authors, etc. For some discussion on this, seehttps://gitlab.com/crossref/issues/-/issues/101Rate limitsSee the headersX-Rate-Limit-LimitandX-Rate-Limit-Intervalfor current rate limits.The Polite PoolTo get in the polite pool it’s a good idea now to include amailtoemail
address. See docs for more information.InstallationStable versionpip (or pip3) install habaneroIf you need to fix bibtex format citations using content negotiation usepip (or pip3) install habanero[bibtex]Dev versionpip install git+https://github.com/sckott/habanero.git#egg=habaneroOr build it yourself locallygit clone https://github.com/sckott/habanero.git
cd habanero
make installUsageInitialize a clientfromhabaneroimportCrossrefcr=Crossref()Works route# queryx=cr.works(query="ecology")x['message']x['message']['total-results']x['message']['items']# fetch data by DOIcr.works(ids='10.1371/journal.pone.0033693')Members route# ids here is the Crossref Member ID; 98 = Hindawicr.members(ids=98,works=True)Citation countsfromhabaneroimportcountscounts.citation_count(doi="10.1016/j.fbr.2012.01.001")Content negotiation - get citations in many formatsfromhabaneroimportcncn.content_negotiation(ids='10.1126/science.169.3946.635')cn.content_negotiation(ids='10.1126/science.169.3946.635',format="citeproc-json")cn.content_negotiation(ids="10.1126/science.169.3946.635",format="rdf-xml")cn.content_negotiation(ids="10.1126/science.169.3946.635",format="text")cn.content_negotiation(ids="10.1126/science.169.3946.635",format="text",style="apa")cn.content_negotiation(ids="10.1126/science.169.3946.635",format="bibentry")MetaPlease note that this project is released with aContributor Code of Conduct. By participating in this project you agree to abide by its terms.License: MIT; seeLICENSE fileChangelog1.2.6 (2024-02-01)mark two more tests for vcr to create cassettes for (both content_negotation tests) - no user facing changes (#114)habanero now conditionally uses bibtexparser to roundtrip bibtex to attempt to fix any bibtex that’s not formatted correctly (#144) (#153)generalize handling  of field queries likequery.publisher-nameto allow all field queries, and any in the future (#150) (#152)improved error handling (#123)idsnow a required param in the Crossref.prefixes method; improved crossef API error parsing (#116)1.2.3 (2023-02-02)now using typehints, tested on Python back to 3.6; though could work with older Python 3 versions. See the new docs for better information on types (#70)fixed problem with usage ofwarn=True; in a for loop, an internal variablewarning_thrownwasn’t being reset after each loop iteration, with the result that all objects returned after a warning was thrown wereNoneregardless of the actual result. sorry about that!  (#112) (#113)1.2.2 (2022-05-19)Fixed classWorksContainerto work with cursor output of works results (e.g.,cr.works(query, cursor=”*”)) (#106) thanks @IvanSterligov1.2 (2022-03-27)Added classWorksContainerto make handling works data easier (#101)changed master branch to main in github development repository (#103)exclude tests from install (#105)1.0 (2021-11-12)fixes to docs/contributing.rst and package level docs for habanero (#89) (#90) thanks @Daniel-Mietchen !fix limit and offset internal handling forrequestandRequest(#91) thanks @Bubblbu !content_negotationthrows warning now on 4xx/5xx status code to allow for bad DOIs alongside good DOIS (#92)add example to README for queryingworksby DOI (#93)fail better when json is not returned; try json.loads and catch ValueError (JSONDecodeError is a subclass of ValueError) (#97)funders, journals, members, prefixes, types and works gainwarnparameter to optionally throw a warning instead of error if a DOI is not found - not found DOI withwarn=TruereturnsNone(#69)0.7.4 (2020-05-29)query.titlefilter is deprecated, usequery.bibliographicinstead (#85)0.7.2 (2019-12-12)Crossref()class gainsua_stringoption to add an additional string to the user-agent sent with every request (#84)0.7.0 (2019-11-08)filter_names()andfilter_details()altered to get metadata for works, members and funders filters; and added egs to members and funders methods for using filters (#67)many typos fixed (#80) thanks @Radcliffe !use of a progress bar is now possible when fetching works route data, only when doing deep paging, seeprogress_barparameter (#77) (#82)content_negotiationfixes:idsparameter is now required (has no default), and must be a str or list of str (#83)no longer testing under Python 20.6.2 (2018-10-22)changelog was missing from the pypi distribution, fixed now (#71)fixedCrossref.registration_agency()method, borked it up on a previous change (#72)set encoding on response text forcontent_negotiation()method to UTF-8 to fix encoding issues (#73)fixCrossref.filter_names()method; no sort ondict_keys(#76)0.6.0 (2017-10-20)Added verification and docs for additional Crossref search filters (#62)Big improvement to docs on readthedocs (#59)Addedmailtosupport (#68) (#63) and related added docs about polite pool (#66)Added support forselectparameter (#65)Added all new/worksroute filters, and simplified filter option handling within library (#60)0.5.0 (2017-07-20)Now usingvcrpyto mock all unit tests (#54)Can now set your own base URL for content negotation (#37)Some field queries withworks()were failing, but now seem to be working, likely due to fixes in Crossref API (#53)style input tocontent_negotiationwas fixed (#57) (#58) thanks @talbertc-usgsFix tocontent_negotiationwhen inputting a DOI as a unicode string (#56)0.3.0 (2017-05-21)Added more documentation for field queries, describing available fields that support field queries, and how to do field queries (#50)sampleparameter maximum value is 100 - has been for a while, but wasn’t updated in Crossref docs (#44)Updated docs thatfacetparameter can be a string query in addition to a boolean (#49)Documented new 10,000 max value for/worksrequests - that is, for theoffsetparameter - if you need more results than that usecursor(seehttps://github.com/CrossRef/rest-api-doc/blob/master/rest_api.md#deep-paging-with-cursors) (#47)Added to docs a bit about rate limiting, their current values, that they can change, and how to show them in verbose curl responses (#45)Now usinghttps://doi.orgforcn.content_negotation- and function gains new parameterurlto  specify different base URLs for content negotiation (#36)Fixes to kwargs and fix docs for what can be passed to kwargs  (#41)Duplicated names passed tofilterwere not working - fixed now (#48)Raise proper HTTP errors when appropriate forcn.content_negotiationthanks @jmaupetit (#55)0.2.6 (2016-06-24)fixed problem withcr.works()where DOIs passed weren’t making the correct API request to Crossref (#40)added support for field queries to all methods that support/works(<https://github.com/CrossRef/rest-api-doc/blob/master/rest_api.md#field-queries>) (#38)0.2.2 (2016-03-09)fixed some example code that included non-working examples (#34)fixed bug inregistration_agency()method, works now! (#35)removed redundantfilter_namesandfilter_detailsbits in docs0.2.0 (2016-02-10)user-agent strings now passed in every http request to Crossref, including aX-USER-AGENTheader in case theUser-Agentstring is lost (#33)added a disclaimer to docs about what is actually searched when searching the Crossref API - that is, only what is returned in the API, so no full text or abstracts are searched (#32)improved http error parsing - now passes on the hopefully meaningful error messages from the Crossref API (#31)more tests added (#30)habanero now supports cursor for deep paging. note that cursor only works with requests to the/worksroute (#18)0.1.3 (2015-12-02)Fix wheel file to be a universal to install on python2 and python3 (#25)Added methodcsl_stylesto get CSL styles for use in content negotiation (#27)More documentation for content negotiation (#26)Made note in docs thatsampleparam ignored unless/worksused (#24)Made note in docs that funders without IDs don’t show up on the/fundersroute (#23)0.1.1 (2015-11-17)Fix readme0.1.0 (2015-11-17)Now compatible with Python 2x and 3xagency()method changed toregistration_agency()New methodcitation_count()- get citation counts for DOIsNew methodcrosscite()- get a citation for DOIs, only supports simple text formatNew methodrandom_dois()- get a random set of DOIsNow importingxml.domto do small amount of XML parsingChanged library structure, now with module system, separated into modules for the main Crossref search API (i.e.,api.crossref.org) including higher level methods (e.g.,registration_agency), content negotiation, and citation counts.0.0.6 (2015-11-09)First pypi release