pub struct SemanticScholarClient { /* private fields */ }Expand description
Client for Semantic Scholar API
Provides methods to search for academic papers, retrieve citations and references, filter by fields of study, and convert results to SemanticVector format for RuVector analysis.
§Rate Limiting
The client automatically enforces rate limits:
- Without API key: 100 requests per 5 minutes (3 seconds between requests)
- With API key: Higher limits (200ms between requests)
§API Key
Set the SEMANTIC_SCHOLAR_API_KEY environment variable to use authenticated requests.
Implementations§
Source§impl SemanticScholarClient
impl SemanticScholarClient
Sourcepub fn with_embedding_dim(api_key: Option<String>, embedding_dim: usize) -> Self
pub fn with_embedding_dim(api_key: Option<String>, embedding_dim: usize) -> Self
Create a new client with custom embedding dimension
§Arguments
api_key- Optional API keyembedding_dim- Dimension for text embeddings (default: 384)
Sourcepub async fn search_papers(
&self,
query: &str,
limit: usize,
) -> Result<Vec<SemanticVector>>
pub async fn search_papers( &self, query: &str, limit: usize, ) -> Result<Vec<SemanticVector>>
Sourcepub async fn get_citations(
&self,
paper_id: &str,
limit: usize,
) -> Result<Vec<SemanticVector>>
pub async fn get_citations( &self, paper_id: &str, limit: usize, ) -> Result<Vec<SemanticVector>>
Sourcepub async fn get_references(
&self,
paper_id: &str,
limit: usize,
) -> Result<Vec<SemanticVector>>
pub async fn get_references( &self, paper_id: &str, limit: usize, ) -> Result<Vec<SemanticVector>>
Sourcepub async fn search_by_field(
&self,
field_of_study: &str,
limit: usize,
) -> Result<Vec<SemanticVector>>
pub async fn search_by_field( &self, field_of_study: &str, limit: usize, ) -> Result<Vec<SemanticVector>>
Search papers by field of study
§Arguments
field_of_study- Field name (e.g., “Computer Science”, “Medicine”, “Biology”, “Physics”, “Economics”)limit- Maximum number of results to return
§Example
ⓘ
let cs_papers = client.search_by_field("Computer Science", 100).await?;
let medical_papers = client.search_by_field("Medicine", 50).await?;Sourcepub async fn search_recent(
&self,
query: &str,
year_min: i32,
) -> Result<Vec<SemanticVector>>
pub async fn search_recent( &self, query: &str, year_min: i32, ) -> Result<Vec<SemanticVector>>
Sourcepub async fn build_citation_graph(
&self,
paper_id: &str,
max_citations: usize,
max_references: usize,
) -> Result<(Option<SemanticVector>, Vec<SemanticVector>, Vec<SemanticVector>)>
pub async fn build_citation_graph( &self, paper_id: &str, max_citations: usize, max_references: usize, ) -> Result<(Option<SemanticVector>, Vec<SemanticVector>, Vec<SemanticVector>)>
Build citation graph for a paper
Returns a tuple of (paper, citations, references) as SemanticVectors
§Arguments
paper_id- Semantic Scholar paper IDmax_citations- Maximum citations to retrievemax_references- Maximum references to retrieve
§Example
ⓘ
let (paper, citations, references) = client.build_citation_graph(
"649def34f8be52c8b66281af98ae884c09aef38b",
50,
50
).await?;Trait Implementations§
Auto Trait Implementations§
impl Freeze for SemanticScholarClient
impl !RefUnwindSafe for SemanticScholarClient
impl Send for SemanticScholarClient
impl Sync for SemanticScholarClient
impl Unpin for SemanticScholarClient
impl !UnwindSafe for SemanticScholarClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more