connected-papers

Crates.ioconnected-papers
lib.rsconnected-papers
version0.1.1
created_at2025-12-29 02:39:00.317345+00
updated_at2026-01-04 07:17:52.886057+00
descriptionA Rust client for Connected Papers integrated with Semantic Scholar utilities.
homepage
repositoryhttps://github.com/tangxiangong/connected-papers
max_upload_size
id2009867
size189,400
小雨 (tangxiangong)

documentation

README

Connected Papers

A Rust client for Connected Papers integrated with Semantic Scholar utilities, inspired by the Official Python Client.

Quick Start

Basic Usage

use connected_papers::ConnectedPapers;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = ConnectedPapers::with_api_key("your_api_key_here");
    
    let response = client
        .get_graph("9397e7acd062245d37350f5c05faf56e9cfae0d6", false)
        .await?;
    
    println!("{response:#?}");
    Ok(())
}

Streaming

use connected_papers::ConnectedPapers;
use futures::StreamExt;
use std::io::{self, Write};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = ConnectedPapers::with_api_key("TEST_TOKEN");

    let mut stream =
        client.get_graph_stream("9397e7acd062245d37350f5c05faf56e9cfae0d6", false, true);

    let mut stdout = io::stdout();
    while let Some(result) = stream.next().await {
        match result {
            Ok(response) => {
                writeln!(stdout, "{response:#?}")?;
                stdout.flush()?;
            }
            Err(e) => {
                writeln!(stdout, "Error: {e}")?;
                stdout.flush()?;
                return Err(e.into());
            }
        }
    }

    Ok(())
}

Remaining Usages

let remaining = client.get_remaining_usages().await?;
println!("Remaining API calls: {}", remaining);

Free Access Papers

let papers = client.get_free_access_papers().await?;
println!("{papers:#?}");

License

Licensed under either of:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 0

cargo fmt