Skip to content

Commit

Permalink
feat: get details about a paper's authors
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnsilva committed Jan 23, 2023
1 parent 0397761 commit bd9e19a
Show file tree
Hide file tree
Showing 3 changed files with 11,561 additions and 0 deletions.
46 changes: 46 additions & 0 deletions semanticscholar/SemanticScholar.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,52 @@ def get_papers(
papers = [Paper(item) for item in data]

return papers

def get_paper_authors(
self,
paper_id: str,
fields: list = None,
limit: int = 1000
) -> PaginatedResults:
'''Get details about a paper's authors
:calls: `POST /paper/{paper_id}/authors \
<https://api.semanticscholar.org/api-docs/graph#tag/Paper-Data\
/operation/get_graph_get_paper_authors>`_
:param str paper_id: S2PaperId, CorpusId, DOI, ArXivId, MAG, ACL,\
PMID, PMCID, or URL from:
- semanticscholar.org
- arxiv.org
- aclweb.org
- acm.org
- biorxiv.org
:param list fields: (optional) list of the fields to be returned.
:param int limit: (optional) maximum number of results to return\
(must be <= 1000).
'''

if limit < 1 or limit > 1000:
raise ValueError(
'The limit parameter must be between 1 and 1000 inclusive.')

if not fields:
fields = [item for item in Author.SEARCH_FIELDS
if not item.startswith('papers')]

url = f'{self.api_url}/paper/{paper_id}/authors'

results = PaginatedResults(
requester=self._requester,
data_type=Author,
url=url,
fields=fields,
limit=limit
)

return results

def get_paper_citations(
self,
Expand Down

0 comments on commit bd9e19a

Please sign in to comment.