ss_tools/tutorials/step_1.rs
1//! # Step 1 - Hello `ss-tools`
2//!
3//! ## Instllation
4//!
5//! To start using `ss-tools`, add the following to your `Cargo.toml`:
6//!
7//! ```toml
8//! [dependencies]
9//! ss-tools = "LATEST_VERSION"
10//! ```
11//! or just use `cargo add`:
12//!
13//! ```bash
14//! cargo add ss-tools
15//! ```
16//!
17//! ### API Key
18//!
19//! If you have an API key, you can set it as an environment variable:
20//!
21//! ```bash
22//! export SEMANTIC_SCHOLAR_API_KEY=XXXXXXXXXX
23//! ```
24//!
25//! ## Hello `ss-tools`
26//!
27//! This is a simple example to get you started with `ss-tools`.
28//! The following code snippet shows how to query a paper by its title:
29//!
30//! ```rust
31//! use anyhow::Result;
32//! use ss_tools::{SemanticScholar, QueryParams};
33//! # #[tokio::main]
34//! # async fn main() -> Result<()> {
35//! let query_text = "Attention Is All You Need";
36//!
37//! // Create a new instance of SemanticScholar
38//! let mut ss = SemanticScholar::new();
39//! let mut query_params = QueryParams::default();
40//! query_params.query_text(query_text);
41//!
42//! let max_retry_count = 5;
43//! let wait_time = 10;
44//! let paper = ss.query_a_paper_by_title(query_params, max_retry_count, wait_time).await.unwrap();
45//!
46//! assert_eq!(
47//! paper.title.clone().unwrap().to_lowercase(),
48//! "attention is all you need".to_string()
49//! );
50//! # Ok(())
51//! # }
52//! ```