Skip to content

utils.semanticscholar

Utils - semanticscholar¤

get_paper_info(paper_id, API_BASE=None) ¤

Get paper info from Semantic Scholar API

Parameters:

Name Type Description Default
paper_id list

list of paper ids

required
API_BASE

base url for the API, default is semanticscholar

None
Source code in kirsche/utils/semanticscholar.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def get_paper_info(paper_id: list, API_BASE=None) -> list:
    """
    Get paper info from Semantic Scholar API

    :param paper_id: list of paper ids
    :param API_BASE: base url for the API, default is semanticscholar
    """
    if API_BASE is None:
        API_BASE = "https://api.semanticscholar.org/v1/paper/"

    logger.debug(f"Getting paper info using base URL {paper_id}")

    # Get paper info from Semantic Scholar API
    url = API_BASE + paper_id

    test_content = get_page_content(url)

    if test_content["status"] != 200:
        raise Exception(
            f"Error: Semantic Scholar API returned status code {test_content['status']}"
        )
    else:
        paper_info = json.loads(test_content["content"].text)
        return paper_info