### Install Crossref API Client Source: https://context7.com/fabiobatalha/crossrefapi/llms.txt Install the library using pip. ```bash pip install crossrefapi ``` -------------------------------- ### Journal Querying and Verification Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Examples of checking for journal existence and querying journal metadata. ```python In [4]: journals.journal_exists('0102-311X') Out[4]: True In [5]: journals.query('Cadernos').url Out[5]: 'https://api.crossref.org/journals?query=Cadernos' In [6]: journals.query('Cadernos').count() Out[6]: 60 In [7]: journals.works('0102-311X').query('zika').url Out[7]: 'https://api.crossref.org/journals/0102-311X/works?query=zika' In [8]: journals.works('0102-311X').query('zika').count() Out[8]: 12 In [9]: journals.works('0102-311X').query('zika').query(author='Diniz').url Out[9]: 'https://api.crossref.org/journals/0102-311X/works?query.author=Diniz&query=zika' In [10]: journals.works('0102-311X').query('zika').query(author='Diniz').count() Out[10]: 1 ``` -------------------------------- ### GET /works/{doi} Source: https://context7.com/fabiobatalha/crossrefapi/llms.txt Retrieve complete metadata for a specific publication using its DOI. ```APIDOC ## GET /works/{doi} ### Description Retrieve complete metadata for a specific publication using its DOI. ### Method GET ### Endpoint /works/{doi} ### Parameters #### Path Parameters - **doi** (string) - Required - The Digital Object Identifier of the publication ### Response #### Success Response (200) - **metadata** (object) - The full metadata record for the specified DOI ``` -------------------------------- ### Lookup Metadata by DOI Source: https://context7.com/fabiobatalha/crossrefapi/llms.txt Retrieve complete metadata for a specific publication using its DOI. Also includes functions to check DOI existence and get its registration agency. ```python from crossref.restful import Works works = Works() # Get metadata for a specific DOI doi = '10.1038/nature12373' metadata = works.doi(doi) if metadata: print(f"Title: {metadata.get('title', ['N/A'])[0]}") print(f"Publisher: {metadata.get('publisher')}") print(f"Type: {metadata.get('type')}") print(f"ISSN: {metadata.get('ISSN', [])}") # Access author information authors = metadata.get('author', []) for author in authors[:3]: name = f"{author.get('given', '')} {author.get('family', '')}" print(f"Author: {name}") ``` ```python # Check if DOI exists exists = works.doi_exists('10.1038/nature12373') print(f"DOI exists: {exists}") # Output: True ``` ```python # Get registration agency for a DOI agency = works.agency('10.1590/0102-311x00133115') print(agency) # Output: {'DOI': '10.1590/0102-311x00133115', 'agency': {'id': 'crossref', 'label': 'Crossref'}} ``` -------------------------------- ### Get Prefix Information and Associated Works Source: https://context7.com/fabiobatalha/crossrefapi/llms.txt Retrieves information about a specific DOI prefix, including the associated member ID. It can also fetch all works associated with that prefix and perform searches within those works. ```python from crossref.restful import Prefixes prefixes = Prefixes() # Get prefix information prefix_data = prefixes.prefix('10.1590') if prefix_data: print(f"Prefix: {prefix_data.get('prefix')}") print(f"Member: {prefix_data.get('member')}") # Get all works with a specific prefix prefix_works = prefixes.works('10.1590') print(f"Total works: {prefix_works.count()}") # Search within prefix works zika_works = prefix_works.query('zika') print(f"Zika articles with this prefix: {zika_works.count()}") ``` -------------------------------- ### Works Facet API Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst This section demonstrates how to use the Works facet API to retrieve counts of works based on different criteria. It shows examples of filtering works and then applying facets like 'issn'. ```APIDOC ## Works Facet API ### Description This API allows you to facet works based on various criteria. You can filter works and then apply facets to get counts of related entities. ### Method GET ### Endpoint /works ### Parameters #### Query Parameters - **filter** (string) - Optional - Filters to apply to the works query (e.g., `has-funder=true`, `has-license=true`). - **sample** (integer) - Optional - Number of random works to sample. - **select** (string) - Optional - Fields to select from the works (e.g., `DOI`, `prefix`). - **facet** (string) - Required - The facet to apply (e.g., `issn`). - **rows** (integer) - Optional - Number of facet values to return. ### Request Example ```python from crossref.restful import Works works = Works() works.facet('issn', 10) ``` ### Response #### Success Response (200) - **facet_name** (object) - Contains the facet results, including `value-count` and `values`. - **value-count** (integer) - Total number of unique values for the facet. - **values** (object) - A mapping of facet values to their counts. #### Response Example ```json { "issn": { "value-count": 10, "values": { "http://id.crossref.org/issn/0009-2975": 306546, "http://id.crossref.org/issn/0028-0836": 395353 } } } ``` ``` -------------------------------- ### Retrieve All Journals Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Fetches all available journals from the Crossref API. This can be used to get a list of journal titles. ```python from crossref.restful import Journals journals = Journals() for item in journals.all(): print(item['title']) ``` -------------------------------- ### GET /works Source: https://context7.com/fabiobatalha/crossrefapi/llms.txt Query and retrieve scholarly publications metadata from the Crossref Works endpoint. ```APIDOC ## GET /works ### Description Search and retrieve metadata for scholarly publications including articles, books, and datasets. ### Method GET ### Endpoint /works ### Parameters #### Query Parameters - **query** (string) - Optional - Search term for publications - **author** (string) - Optional - Filter by author name - **publisher_name** (string) - Optional - Filter by publisher name ### Response #### Success Response (200) - **results** (object) - A collection of publication metadata objects ``` -------------------------------- ### Get Faceted Data for Prefix Works Source: https://context7.com/fabiobatalha/crossrefapi/llms.txt Retrieves faceted data for works associated with a specific DOI prefix, allowing for analysis of common elements like ISSNs. Requires a DOI prefix and a facet field. ```python from crossref.restful import Prefixes prefixes = Prefixes() # Get faceted data for prefix works facets = prefix_works.facet('issn', 10) print(f"Top ISSNs: {facets}") ``` -------------------------------- ### Crossref Metadata Deposit XML Structure Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst An example of the XML structure required for depositing Digital Object Metadata to Crossref using the doMDUpload operation. This includes journal metadata, publication details, and article information. ```xml c5473e12dc8e4f36a40f76f8eae15280 20171009132847 SciELO crossref@scielo.org SciELO Revista Brasileira de Ciência Avícola Rev. Bras. Cienc. Avic. 1516-635X 09 2017 19 3 Climatic Variation: Effects on Stress Levels, Feed Intake, and Bodyweight of Broilers R Osti Huazhong Agricultural University, China D Bhattarai Huazhong Agricultural University, China D Zhou Huazhong Agricultural University, China 09 2017 489 496 S1516-635X2017000300489 10.1590/1806-9061-2017-0494 ``` -------------------------------- ### Initialize Depositor with Etiquette Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Configure the Depositor instance with project metadata and Crossref credentials. ```python etiquette = Etiquette('My Project Name', 'My Project version', 'My Project URL', 'My contact email') Depositor('your prefix', 'your crossref user', 'your crossref password', etiquette) ``` -------------------------------- ### Register and Query DOI Status with Depositor Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Initializes the Depositor with credentials and performs registration and status check operations. ```python In [1]: from crossref.restful import Depositor In [2]: request_xml = open('tests/fixtures/deposit_xml_sample.xml', 'r').read() In [3]: depositor = Depositor('your prefix', 'your crossref user', 'your crossref password') In [4]: response = depositor.register_doi('testing_20171011', request_xml) In [5]: response.status_code Out[5]: 200 In [6]: response.text Out[6]: '\n\n\n\n\nSUCCESS\n\n\n

SUCCESS

\n

Your batch submission was successfully received.

\n\n\n' In [7]: response = depositor.request_doi_status_by_filename('testing_20171011.xml') In [8]: response.text Out[8]: '\n\r\n 1415653976\r\n \r\n' In [9]: response = depositor.request_doi_status_by_filename('testing_20171011.xml') In [10]: response.text Out[10]: '\n\r\n 1415653976\r\n \r\n' In [11]: response = depositor.request_doi_status_by_filename('testing_20171011.xml', data_type='result') In [12]: response.text Out[12]: '\n\r\n 1415653976\r\n \r\n' In [13]: response = depositor.request_doi_status_by_filename('testing_20171011.xml', data_type='contents') In [14]: response.text ``` -------------------------------- ### Fetch Sample Works with Etiquette Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Retrieves a sample of works from the Crossref API, applying the configured etiquette for polite requests. Only the DOI is selected for each work. ```python from crossref.restful import Works works = Works(etiquette=my_etiquette) for i in works.sample(5).select('DOI'): print(i) ``` -------------------------------- ### Sample Works Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Retrieve a random sample of works from the API. ```python In [1]: from crossref.restful import Works In [2]: works = Works() In [3]: for item in works.sample(2): ...: print(item['title']) ...: ['On the Origin of the Color-Magnitude Relation in the Virgo Cluster'] ['Biopsychosocial Wellbeing among Women with Gynaecological Cancer'] ``` -------------------------------- ### Configure Polite Request Etiquette Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Sets up an Etiquette object for making polite requests to the Crossref API. This includes specifying project name, version, URL, and contact email. ```python from crossref.restful import Etiquette my_etiquette = Etiquette('My Project Name', 'My Project version', 'My Project URL', 'My contact email') str(my_etiquette) ``` ```python my_etiquette = Etiquette('My Project Name', '0.2alpha', 'https://myalphaproject.com', 'anonymous@myalphaproject.com') ``` -------------------------------- ### Configure Polite API Requests Source: https://context7.com/fabiobatalha/crossrefapi/llms.txt Identify your application using Etiquette headers to access the polite API pool with higher rate limits. ```python from crossref.restful import Works, Etiquette # Create custom etiquette for your application my_etiquette = Etiquette( application_name='MyResearchApp', application_version='1.0.0', application_url='https://myapp.example.com', contact_email='researcher@example.com' ) # Check the user-agent string print(str(my_etiquette)) # Output: MyResearchApp/1.0.0 (https://myapp.example.com; mailto:researcher@example.com) BasedOn: CrossrefAPI/1.7.0 # Use etiquette with any endpoint works = Works(etiquette=my_etiquette) # All requests will now include proper identification for work in works.query('genomics').sample(3): print(f"DOI: {work.get('DOI')}") ``` -------------------------------- ### Filter and Select Works Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Demonstrates filtering works by funder and license, sampling results, and selecting specific fields. ```python In [4]: for i in works.filter(has_funder='true', has_license='true').sample(5).select(['DOI', 'prefix']): ...: print(i) ``` ```python In [5]: for i in works.filter(has_funder='true', has_license='true').sample(5).select('DOI').select('prefix'): ...: print(i) ``` ```python In [6]: for i in works.filter(has_funder='true', has_license='true').sample(5).select('DOI', 'prefix'): ...: print(i) ``` -------------------------------- ### Register DOIs with Depositor Source: https://context7.com/fabiobatalha/crossrefapi/llms.txt Submit XML metadata to Crossref for DOI registration using publisher credentials. ```python from crossref.restful import Depositor, Etiquette # Create depositor with Crossref credentials etiquette = Etiquette( 'MyPublishingSystem', '2.0', 'https://publisher.example.com', 'tech@publisher.example.com' ) depositor = Depositor( prefix='10.xxxx', api_user='your_crossref_username', api_key='your_crossref_password', etiquette=etiquette, use_test_server=True # Use test server for development ) # XML metadata conforming to Crossref schema metadata_xml = ''' batch_001 20240101120000 Publisher Name deposits@publisher.example.com Publisher Name ''' # Submit DOI registration response = depositor.register_doi('submission_001', metadata_xml) print(f"Status: {response.status_code}") print(f"Response: {response.text}") # Check submission status by filename status_response = depositor.request_doi_status_by_filename( 'submission_001.xml', data_type='result' ) print(status_response.text) # Check submission status by batch ID status_response = depositor.request_doi_status_by_batch_id( 'batch_001', data_type='result' ) print(status_response.text) # Retrieve original submitted XML contents = depositor.request_doi_status_by_filename( 'submission_001.xml', data_type='contents' ) print(contents.text) ``` -------------------------------- ### Manage Rate Limiting and Throttling Source: https://context7.com/fabiobatalha/crossrefapi/llms.txt Configure API throttling, timeouts, and authentication tokens for higher rate limits. ```python from crossref.restful import Works # Throttling is enabled by default works = Works(throttle=True) # Default behavior # Disable throttling (not recommended for production) works_no_throttle = Works(throttle=False) # Check current rate limits print(f"Rate limit: {works.x_rate_limit_limit}") print(f"Rate interval: {works.x_rate_limit_interval}") # With Crossref Plus token for higher limits works_plus = Works( crossref_plus_token='your-crossref-plus-token' ) # Set custom timeout (default is 30 seconds) works_custom = Works(timeout=60) # Disable SSL verification (not recommended) works_no_ssl = Works(verify=False) ``` -------------------------------- ### Query Works Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Perform a bibliographic query using specific parameters. ```python In [1]: from crossref.restful import Works In [2]: works = Works() In [3]: w1 = works.query(bibliographic='zika', author='johannes', publisher_name='Wiley-Blackwell') In [4]: for item in w1: ...: print(item['title']) ...: ...: ['Inactivation and removal of Zika virus during manufacture of plasma-derived medicinal products'] ['Harmonization of nucleic acid testing for Zika virus: development of the 1st World Health Organization International Standard'] ``` -------------------------------- ### Search for Funders by Name and Retrieve Metadata Source: https://context7.com/fabiobatalha/crossrefapi/llms.txt Searches for funding organizations by name and retrieves their metadata, including name, ID, and location. Can also fetch specific funder data by ID and check for existence. ```python from crossref.restful import Funders funders = Funders() # Search for funders by name results = funders.query('National Science Foundation') for funder in results: print(f"Name: {funder.get('name')}") print(f"ID: {funder.get('id')}") print(f"Location: {funder.get('location')}") break # Get specific funder by ID funder_data = funders.funder('100000001') # NSF Funder ID if funder_data: print(f"Funder: {funder_data.get('name')}") print(f"Work count: {funder_data.get('work-count')}") # Check if funder exists exists = funders.funder_exists('100000001') print(f"Funder exists: {exists}") ``` -------------------------------- ### Select Fields Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Limit the returned metadata fields for query results. ```python In [1]: from crossref.restful import Works In [2]: works = Works() In [3]: for i in works.filter(has_funder='true', has_license='true').sample(5).select('DOI, prefix'): ...: print(i) ...: {'DOI': '10.1111/str.12144', 'member': 'http://id.crossref.org/member/311', 'prefix': '10.1111'} {'DOI': '10.1002/admi.201400154', 'member': 'http://id.crossref.org/member/311', 'prefix': '10.1002'} {'DOI': '10.1016/j.surfcoat.2010.10.057', 'member': 'http://id.crossref.org/member/78', 'prefix': '10.1016'} {'DOI': '10.1007/s10528-015-9707-8', 'member': 'http://id.crossref.org/member/297', 'prefix': '10.1007'} ``` -------------------------------- ### Retrieve All Items Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Retrieves all items from an endpoint, using pagination (limit/offset or cursor) as necessary. ```APIDOC ## GET /[endpoint] ### Description This method returns all items of an endpoint. It will use the limit offset parameters to iterate through the endpoints Journals, Types, Members and Prefixes. For the works endpoint, the library will make use of the cursor to paginate through API until it is totally consumed. ### Method GET ### Endpoint /[endpoint] ### Parameters (Pagination parameters like limit, offset, cursor are handled internally) ### Request Example ```python # Example for works endpoint using cursor (conceptual) from crossref.restful import Works works = Works() all_works = works.all() # Example for other endpoints using limit/offset (conceptual) from crossref.restful import Journals journals = Journals() all_journals = journals.all() ``` ### Response Example (Returns a list of items, structure depends on the endpoint) ``` -------------------------------- ### Retrieve API Version Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Returns the current version of the Crossref API. ```python In [1]: from crossref.restful import Journals In [2]: journals = Journals() In [3]: journals.version Out[3]: '1.0.0' ``` -------------------------------- ### Select Specific Fields from Results Source: https://context7.com/fabiobatalha/crossrefapi/llms.txt Use the 'select' method to retrieve only specified fields, reducing response size. Fields can be specified as separate arguments, a list, or a comma-separated string. ```python from crossref.restful import Works works = Works() # Select only DOI and title fields results = works.filter( has_funder='true', has_license='true' ).sample(5).select('DOI', 'title', 'publisher') for work in results: print(work) # Output: {'DOI': '10.1000/xyz123', 'title': ['Example Title'], 'publisher': 'Publisher Name'} ``` ```python # Multiple ways to specify fields results = works.sample(3).select(['DOI', 'prefix', 'author']) results = works.sample(3).select('DOI, prefix, author') results = works.sample(3).select('DOI').select('prefix').select('author') ``` -------------------------------- ### Retrieve Agency Information Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Fetch the registration agency for a specific DOI. ```python In [1]: from crossref.restful import Works In [2]: works = Works() In [3]: works.agency('10.1590/0102-311x00133115') Out[3]: {'DOI': '10.1590/0102-311x00133115', 'agency': {'id': 'crossref', 'label': 'CrossRef'}} ``` -------------------------------- ### Retrieve Work by DOI Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Fetch full metadata for a specific DOI. ```python In [1]: from crossref.restful import Works In [2]: works = Works() In [3]: works.doi('10.1590/0102-311x00133115') Out[3]: {'DOI': '10.1590/0102-311x00133115', 'ISSN': ['0102-311X'], 'URL': 'http://dx.doi.org/10.1590/0102-311x00133115', 'alternative-id': ['S0102-311X2016001107002'], 'author': [{'affiliation': [{'name': 'Surin Rajabhat University, Thailand'}], 'family': 'Wiwanitki', 'given': 'Viroj'}], 'container-title': ['Cadernos de Saúde Pública'], 'content-domain': {'crossmark-restriction': False, 'domain': []}, 'created': {'date-parts': [[2016, 12, 7]], 'date-time': '2016-12-07T21:52:08Z', 'timestamp': 1481147528000}, 'deposited': {'date-parts': [[2017, 5, 24]], 'date-time': '2017-05-24T01:57:26Z', 'timestamp': 1495591046000}, 'indexed': {'date-parts': [[2017, 5, 24]], 'date-time': '2017-05-24T22:39:11Z', 'timestamp': 1495665551858}, 'is-referenced-by-count': 0, 'issn-type': [{'type': 'electronic', 'value': '0102-311X'}], 'issue': '11', 'issued': {'date-parts': [[2016, 11]]}, 'member': '530', 'original-title': [], 'prefix': '10.1590', 'published-print': {'date-parts': [[2016, 11]]}, 'publisher': 'FapUNIFESP (SciELO)', 'reference-count': 3, 'references-count': 3, 'relation': {}, 'score': 1.0, 'short-container-title': ['Cad. Saúde Pública'], 'short-title': [], 'source': 'Crossref', 'subject': ['Medicine(all)'], 'subtitle': [], 'title': ['Congenital Zika virus syndrome'], 'type': 'journal-article', 'volume': '32'} ``` -------------------------------- ### Iterate Through Large Result Sets Source: https://context7.com/fabiobatalha/crossrefapi/llms.txt Handle automatic pagination for both cursor-based and offset-based API endpoints. ```python from crossref.restful import Works, Journals # Works endpoint uses cursor-based pagination (no limit) works = Works() count = 0 for work in works.query('CRISPR').filter(from_pub_date='2023'): print(f"Processing: {work.get('DOI')}") count += 1 if count >= 100: # Process first 100 break # Get all items from endpoints with offset pagination journals = Journals() for journal in journals.all(None): print(f"Journal: {journal.get('title')}") break # Just show first one # Note: Offset-based endpoints have a max of 10,000 results ``` -------------------------------- ### Request DOI Status by Filename Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Retrieve the status of a previously submitted DOI batch file. ```python response = depositor.request_doi_status_by_filename('testing_20171011.xml', data_type='result') ``` -------------------------------- ### Generate API Query URLs Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Constructs the URL that will be used to query the Crossref API based on applied filters and parameters. ```python In [1]: from crossref.restful import Works In [2]: works = Works() In [3]: works.query('zika').url Out[3]: 'https://api.crossref.org/works?query=zika' In [4]: works.query('zika').filter(from_online_pub_date='2017').url Out[4]: 'https://api.crossref.org/works?query=zika&filter=from-online-pub-date%3A2017' In [5]: works.query('zika').filter(from_online_pub_date='2017').query(author='Mari').url Out[5]: 'https://api.crossref.org/works?query.author=Mari&filter=from-online-pub-date%3A2017&query=zika' In [6]: works.query('zika').filter(from_online_pub_date='2017').query(author='Mari').sort('published').url Out[6]: 'https://api.crossref.org/works?query.author=Mari&query=zika&filter=from-online-pub-date%3A2017&sort=published' In [7]: works.query('zika').filter(from_online_pub_date='2017').query(author='Mari').sort('published').order('asc').url Out[7]: 'https://api.crossref.org/works?filter=from-online-pub-date%3A2017&query.author=Mari&order=asc&query=zika&sort=published' In [8]: from crossref.restful import Prefixes In [9]: prefixes = Prefixes() In [10]: prefixes.works('10.1590').query('zike').url Out[10]: 'https://api.crossref.org/prefixes/10.1590/works?query=zike' In [11]: from crossref.restful import Journals In [12]: journals = Journals() In [13]: journals.url Out[13]: 'https://api.crossref.org/journals' In [14]: journals.works('0102-311X').url Out[14]: 'https://api.crossref.org/journals/0102-311X/works' In [15]: journals.works('0102-311X').query('zika').url Out[15]: 'https://api.crossref.org/journals/0102-311X/works?query=zika' In [16]: journals.works('0102-311X').query('zika').count() Out[16]: 12 ``` -------------------------------- ### Retrieve and Filter Document Types Source: https://context7.com/fabiobatalha/crossrefapi/llms.txt Access metadata about document types and filter works based on specific criteria. ```python # Get all available document types for doc_type in types.all(None): print(f"ID: {doc_type.get('id')}, Label: {doc_type.get('label')}") # Get specific type information type_data = types.type('journal-article') if type_data: print(f"Type: {type_data.get('label')}") # Check if type exists exists = types.type_exists('journal-article') print(f"Type exists: {exists}") # Get all works of a specific type articles = types.works('journal-article') recent_articles = articles.filter(from_pub_date='2024').sample(5) for work in recent_articles: print(f"Title: {work.get('title', ['N/A'])[0]}") ``` -------------------------------- ### Search for Members (Publishers) by Name Source: https://context7.com/fabiobatalha/crossrefapi/llms.txt Searches for Crossref member organizations (publishers) by name and retrieves their primary name, ID, and associated prefixes. Can also fetch specific member data by ID and check for existence. ```python from crossref.restful import Members members = Members() # Search for members by name results = members.query('Elsevier') for member in results: print(f"Name: {member.get('primary-name')}") print(f"ID: {member.get('id')}") print(f"Prefixes: {member.get('prefix', [])}") break # Get specific member by ID member_data = members.member('78') # Elsevier's member ID if member_data: print(f"Member: {member_data.get('primary-name')}") print(f"Total DOIs: {member_data.get('counts', {}).get('total-dois')}") # Check if member exists exists = members.member_exists('78') print(f"Member exists: {exists}") ``` -------------------------------- ### Prefix Works Facet API Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst This section demonstrates how to use the Prefixes facet API to retrieve counts of works associated with a specific prefix, and then apply facets like 'issn'. ```APIDOC ## Prefix Works Facet API ### Description This API allows you to retrieve and facet works associated with a specific Crossref prefix. You can also apply search queries before faceting. ### Method GET ### Endpoint /prefixes/{prefix}/works ### Parameters #### Path Parameters - **prefix** (string) - Required - The Crossref prefix to query (e.g., `10.1590`). #### Query Parameters - **query** (string) - Optional - A search query to filter works within the prefix. - **facet** (string) - Required - The facet to apply (e.g., `issn`). - **rows** (integer) - Optional - Number of facet values to return. ### Request Example ```python from crossref.restful import Prefixes prefixes = Prefixes() prefixes.works('10.1590').facet('issn', 10) prefixes.works('10.1590').query('zika').facet('issn', 10) ``` ### Response #### Success Response (200) - **facet_name** (object) - Contains the facet results, including `value-count` and `values`. - **value-count** (integer) - Total number of unique values for the facet. - **values** (object) - A mapping of facet values to their counts. #### Response Example ```json { "issn": { "value-count": 10, "values": { "http://id.crossref.org/issn/0004-282X": 7712, "http://id.crossref.org/issn/0034-8910": 4752 } } } ``` ``` -------------------------------- ### Count Query Results Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Fetches the total number of items for a query without retrieving the full documents. ```python In [1]: from crossref.restful import Works In [2]: works = Works() In [3]: works.query('zika').count() Out[3]: 3597 In [4]: works.query('zika').filter(from_online_pub_date='2017').count() Out[4]: 444 ``` -------------------------------- ### Generate API URL Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Constructs the URL for a Crossref API request, including query parameters and filters. ```APIDOC ## Generate URL ### Description This method returns the URL that will be used to query the Crossref API, incorporating various parameters and filters. ### Method GET ### Endpoint (Constructed dynamically based on query and filters) ### Query Parameters - **query** (string) - Optional - The search query string. - **query.[field]** (string) - Optional - Specific fields for the query (e.g., query.author). - **filter** (object) - Optional - Filters to apply to the query. - **sort** (string) - Optional - Field to sort the results by. - **order** (string) - Optional - Order of sorting (asc/desc). ### Request Example ```python from crossref.restful import Works works = Works() print(works.query('zika').url) print(works.query('zika').filter(from_online_pub_date='2017').url) print(works.query('zika').filter(from_online_pub_date='2017').query(author='Mari').url) print(works.query('zika').filter(from_online_pub_date='2017').query(author='Mari').sort('published').url) print(works.query('zika').filter(from_online_pub_date='2017').query(author='Mari').sort('published').order('asc').url) from crossref.restful import Prefixes prefixes = Prefixes() print(prefixes.works('10.1590').query('zike').url) from crossref.restful import Journals journals = Journals() print(journals.url) print(journals.works('0102-311X').url) print(journals.works('0102-311X').query('zika').url) ``` ### Response Example ``` https://api.crossref.org/works?query=zika https://api.crossref.org/works?query=zika&filter=from-online-pub-date%3A2017 https://api.crossref.org/works?query.author=Mari&filter=from-online-pub-date%3A2017&query=zika https://api.crossref.org/works?query.author=Mari&query=zika&filter=from-online-pub-date%3A2017&sort=published https://api.crossref.org/works?filter=from-online-pub-date%3A2017&query.author=Mari&order=asc&query=zika&sort=published https://api.crossref.org/prefixes/10.1590/works?query=zike https://api.crossref.org/journals https://api.crossref.org/journals/0102-311X/works https://api.crossref.org/journals/0102-311X/works?query=zika ``` ``` -------------------------------- ### Filter Works Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Filter results using specific criteria. Note that parameter syntax requires replacing dots with double underscores and hyphens with underscores. ```python In [1] from cross.restful import Works In [2]: works = Works() In [3]: for i in works.filter(license__url='https://creativecommons.org/licenses/by', from_pub_date='2016').sample(5).select('title'): ...: print(i) ...: {'title': ['Vers une économie circulaire... de proximité ? Une spatialité à géométrie variable']} {'title': ['The stakeholders of the Olympic System']} {'title': ["Un cas de compensation écologique dans le secteur minier : la réserve forestière Dékpa (Côte d'Ivoire) au secours des forêts et des populations locales"]} {'title': ['A simple extension of FFT-based methods to strain gradient loadings - Application to the homogenization of beams and plates with linear and non-linear behaviors']} {'title': ['Gestion des déchets ménagers dans la ville de Kinshasa : Enquête sur la perception des habitants et propositions']} ``` -------------------------------- ### Perform Facet Queries Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Retrieves facet counts for ISSNs using the Works and Prefixes endpoints. ```python In [1]: from crossref.restful import Works, Prefixes In [2]: works = Works() In [3]: works.facet('issn', 10) ``` ```python In [4]: prefixes = Prefixes() In [5]: prefixes.works('10.1590').facet('issn', 10) ``` ```python In [6]: prefixes.works('10.1590').query('zika').facet('issn', 10) ``` -------------------------------- ### Crossref API Version Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Retrieves the current version of the Crossref API. ```APIDOC ## GET /version ### Description This method returns the Crossref API version. ### Method GET ### Endpoint / ### Request Example ```python from crossref.restful import Journals journals = Journals() print(journals.version) ``` ### Response Example ```json { "version": "1.0.0" } ``` ``` -------------------------------- ### Prefixes API Source: https://context7.com/fabiobatalha/crossrefapi/llms.txt Query DOI prefixes and retrieve works associated with specific publishers by their prefix. ```APIDOC ## Prefixes API ### Description Query DOI prefixes and retrieve works associated with specific publishers by their prefix. ### Parameters #### Path Parameters - **prefix** (string) - Required - The DOI prefix. ### Methods - **prefix(prefix)**: Get prefix information. - **works(prefix)**: Get all works with a specific prefix. ``` -------------------------------- ### Filter Funders by Location Source: https://context7.com/fabiobatalha/crossrefapi/llms.txt Filters the list of funders to retrieve only those located in a specified country. Requires the 'location' parameter. ```python from crossref.restful import Funders funders = Funders() # Filter funders by location us_funders = funders.filter(location='United States') for f in us_funders: print(f"{f.get('name')}: {f.get('id')}") break ``` -------------------------------- ### Count Items Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Returns the total number of items matching a query without retrieving the items themselves. ```APIDOC ## GET /[endpoint] ### Description This method returns the total number of items a query result should retrieve. It fetches 0 documents and retrieves the value of the 'total-result' attribute. ### Method GET ### Endpoint /[endpoint] ### Query Parameters - **query** (string) - Required - The search query string. - **filter** (object) - Optional - Filters to apply to the query. ### Request Example ```python from crossref.restful import Works works = Works() print(works.query('zika').count()) print(works.query('zika').filter(from_online_pub_date='2017').count()) ``` ### Response Example ```json { "message": { "total-results": 3597 } } ``` ``` -------------------------------- ### Faceted Search for Aggregated Statistics Source: https://context7.com/fabiobatalha/crossrefapi/llms.txt Use the 'facet' method to retrieve aggregated statistics about search results, such as top ISSNs. ```python from crossref.restful import Works works = Works() # Get top 10 ISSNs with most publications issn_facets = works.facet('issn', 10) print(issn_facets) # Output: {'issn': {'value-count': 10, 'values': {'http://id.crossref.org/issn/...': 306546, ...}}} ``` -------------------------------- ### Retrieve Works Funded by a Specific Funder Source: https://context7.com/fabiobatalha/crossrefapi/llms.txt Fetches all works associated with a specific funder ID, allowing for querying and filtering by publication date. Requires a valid funder ID. ```python from crossref.restful import Funders funders = Funders() # Get all works funded by a specific funder nsf_works = funders.works('100000001') print(f"Total NSF-funded works: {nsf_works.count()}") # Query funded works ml_funded = nsf_works.query('machine learning').filter(from_pub_date='2023') for work in ml_funded.sample(3): print(f"Title: {work.get('title', ['N/A'])[0]}") ``` -------------------------------- ### Query Works for a Journal Source: https://github.com/fabiobatalha/crossrefapi/blob/master/README.rst Searches for works within a specific journal based on a query string and optional filters. ```APIDOC ## GET /journals/{journal_issn}/works ### Description Searches for works within a specific journal, optionally filtering by query terms and authors. ### Method GET ### Endpoint /journals/{journal_issn}/works ### Path Parameters - **journal_issn** (string) - Required - The ISSN of the journal. ### Query Parameters - **query** (string) - Optional - The search term for works. - **query.author** (string) - Optional - Filters works by author name. ### Request Example ```python from crossref.restful import Journals journals = Journals() print(journals.works('0102-311X').query('zika').url) print(journals.works('0102-311X').query('zika').count()) print(journals.works('0102-311X').query('zika').query(author='Diniz').url) print(journals.works('0102-311X').query('zika').query(author='Diniz').count()) ``` ### Response Example (Returns a list of works matching the criteria) ``` -------------------------------- ### Query and Retrieve Journal Metadata Source: https://context7.com/fabiobatalha/crossrefapi/llms.txt Searches for journals by title and retrieves their metadata, including title and ISSN. Can also fetch specific journal data by ISSN and check for existence. ```python from crossref.restful import Journals journals = Journals() # Search for journals by title results = journals.query('Nature') print(f"Found {results.count()} journals matching 'Nature'") for journal in results: print(f"Title: {journal.get('title')}") print(f"ISSN: {journal.get('ISSN')}") break # Get specific journal by ISSN journal_data = journals.journal('0102-311X') if journal_data: print(f"Journal: {journal_data.get('title')}") print(f"Publisher: {journal_data.get('publisher')}") print(f"Total DOIs: {journal_data.get('counts', {}).get('total-dois')}") # Check if journal exists exists = journals.journal_exists('0102-311X') print(f"Journal exists: {exists}") # Output: True ```