Skip to content

Commit

Permalink
feat: get details about a author's papers
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnsilva committed Jan 23, 2023
1 parent bd9e19a commit f186cea
Show file tree
Hide file tree
Showing 3 changed files with 28,771 additions and 1 deletion.
47 changes: 46 additions & 1 deletion semanticscholar/SemanticScholar.py
Expand Up @@ -155,7 +155,7 @@ def get_papers(
papers = [Paper(item) for item in data]

return papers

def get_paper_authors(
self,
paper_id: str,
Expand Down Expand Up @@ -404,6 +404,51 @@ def get_authors(

return authors

def get_author_papers(
self,
author_id: str,
fields: list = None,
limit: int = 1000
) -> PaginatedResults:
'''Get details about a author's papers
:calls: `POST /paper/{author_id}/papers \
<https://api.semanticscholar.org/api-docs/graph#tag/Paper-Data\
/operation/get_graph_get_author_papers>`_
: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 = Paper.SEARCH_FIELDS

url = f'{self.api_url}/author/{author_id}/papers'

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

return results

def search_author(
self,
query: str,
Expand Down

0 comments on commit f186cea

Please sign in to comment.