Rust Semantic Scholar API Tools
Tools for Semantic Scholar API.
Quick Start
Installation
To start using ss-tools, just add it to your project's dependencies in the Cargo.toml.
> cargo
API Key
If you have an API key, set it as an environmental value in a .env file
SEMANTIC_SCHOLAR_API_KEY = xxxxxxxxxxxxxxxxxxxxxxxx
Then, import it in your program;
use SemanticScholar;
Usage
Search by paper title
Pass any keywords or title of a paper.
The original API returns multiple papers that could be related to the query_text.
For now, ss-tools returns the first paper from the response.
In the future, we plan to improve the library to output the paper most relevant to the query_text based on similarity metrics.
let query_text = "attention is all you need";
let mut ss = new;
let paper_id = ss.query_paper_id.await; // paperId, max_retry_count, wait_time(sec)
assert_eq!;
Get details about a paper
Pass the paper_id that you want to know its details, and a list of SsField.
The returned SsResponse object has all the available fields.
let paper_id = "204e3073870fae3d05bcbc2f6a8e263d9b72e776";
let mut ss = new;
let fields = vec!;
let paper_details: SsResponse = ss.query_paper_details.await; // paper_id ,fields, max_retry_count, wait_time(sec)
assert_eq!;
For detials about SsResponse, see the document Struct SsResponse.
Get references of a paper
let paper_id = "204e3073870fae3d05bcbc2f6a8e263d9b72e776";
let mut ss = new;
let fields = vec!;
let paper_citations: SsResponsePapers = ss
.query_paper_citations // paper_id, fields, max_retry_count, wait_time(sec)
.await
.unwrap;
// SsResponsePapers.data: Vec<SsResponse>
assert!;
Get citations of a paper
let paper_id = "204e3073870fae3d05bcbc2f6a8e263d9b72e776";
let mut ss = new;
let fields = vec!;
let paper_citations: SsResponsePapers = ss
.query_paper_references // paperId, fields, max_retry_count, wait_time(sec)
.await
.unwrap;
// SsResponsePapers.data: Vec<SsResponse>
assert!;
Get details about a author
COMMING SOON!
Updates
- Fixed README.md
- added the Semantic Scholar instruction about API key.
- Fixed README.md
- apply the Levenshtein algorithm to extract the correct title.
- added retry loop when the Semantic Scholar API fails.
- added new API to get citations of a paper
- added new API to get references of a paper