1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
//! # Step 4 - Available Endpoints
//!
//! This tutorial covers all available API endpoints in `ss-tools`.
//!
//! ## Paper Data APIs
//!
//! ### Query a Paper by Title
//!
//! Search for a single paper by title using [`SemanticScholar::query_a_paper_by_title`](crate::SemanticScholar::query_a_paper_by_title).
//!
//! ```rust
//! # use anyhow::Result;
//! # use ss_tools::{SemanticScholar, QueryParams};
//! # #[tokio::main]
//! # async fn main() -> Result<()> {
//! let mut ss = SemanticScholar::new();
//! let mut query_params = QueryParams::default();
//! query_params.query_text("Attention Is All You Need");
//!
//! let paper = ss.query_a_paper_by_title(query_params, 5, 10).await?;
//! println!("Paper: {:?}", paper.title);
//! # Ok(())
//! # }
//! ```
//!
//! ### Query Multiple Papers by Title
//!
//! Search for multiple papers by title using [`SemanticScholar::query_papers_by_title`](crate::SemanticScholar::query_papers_by_title).
//!
//! ```rust,no_run
//! # use anyhow::Result;
//! # use ss_tools::{SemanticScholar, QueryParams};
//! # #[tokio::main]
//! # async fn main() -> Result<()> {
//! let mut ss = SemanticScholar::new();
//! let mut query_params = QueryParams::default();
//! query_params.query_text("deep learning");
//!
//! let papers = ss.query_papers_by_title(query_params, 5, 10).await?;
//! println!("Found {} papers", papers.len());
//! # Ok(())
//! # }
//! ```
//!
//! ### Query Paper Details
//!
//! Get detailed information about a paper using [`SemanticScholar::query_paper_details`](crate::SemanticScholar::query_paper_details).
//!
//! ```rust
//! # use anyhow::Result;
//! # use ss_tools::{SemanticScholar, QueryParams};
//! # use ss_tools::structs::PaperField;
//! # #[tokio::main]
//! # async fn main() -> Result<()> {
//! let mut ss = SemanticScholar::new();
//! let mut query_params = QueryParams::default();
//! query_params.paper_id("204e3073870fae3d05bcbc2f6a8e263d9b72e776");
//! query_params.fields(vec![
//! PaperField::Title,
//! PaperField::Abstract,
//! PaperField::CitationCount,
//! ]);
//!
//! let paper = ss.query_paper_details(query_params, 5, 10).await?;
//! println!("Title: {:?}", paper.title);
//! # Ok(())
//! # }
//! ```
//!
//! ### Query Paper Citations
//!
//! Get papers that cite a specific paper using [`SemanticScholar::query_paper_citations`](crate::SemanticScholar::query_paper_citations).
//!
//! ```rust
//! # use anyhow::Result;
//! # use ss_tools::{SemanticScholar, QueryParams};
//! # use ss_tools::structs::PaperField;
//! # #[tokio::main]
//! # async fn main() -> Result<()> {
//! let mut ss = SemanticScholar::new();
//! let mut query_params = QueryParams::default();
//! query_params.paper_id("204e3073870fae3d05bcbc2f6a8e263d9b72e776");
//! query_params.fields(vec![PaperField::Title, PaperField::Year]);
//!
//! let citations = ss.query_paper_citations(query_params, 5, 10).await?;
//! println!("Found {} citations", citations.data.len());
//! # Ok(())
//! # }
//! ```
//!
//! ### Query Paper References
//!
//! Get papers referenced by a specific paper using [`SemanticScholar::query_paper_references`](crate::SemanticScholar::query_paper_references).
//!
//! ```rust
//! # use anyhow::Result;
//! # use ss_tools::{SemanticScholar, QueryParams};
//! # use ss_tools::structs::PaperField;
//! # #[tokio::main]
//! # async fn main() -> Result<()> {
//! let mut ss = SemanticScholar::new();
//! let mut query_params = QueryParams::default();
//! query_params.paper_id("204e3073870fae3d05bcbc2f6a8e263d9b72e776");
//! query_params.fields(vec![PaperField::Title, PaperField::Year]);
//!
//! let references = ss.query_paper_references(query_params, 5, 10).await?;
//! println!("Found {} references", references.data.len());
//! # Ok(())
//! # }
//! ```
//!
//! ### Query Paper Authors
//!
//! Get authors of a specific paper using [`SemanticScholar::query_paper_authors`](crate::SemanticScholar::query_paper_authors).
//!
//! ```rust
//! # use anyhow::Result;
//! # use ss_tools::{SemanticScholar, QueryParams};
//! # use ss_tools::structs::AuthorField;
//! # #[tokio::main]
//! # async fn main() -> Result<()> {
//! let mut ss = SemanticScholar::new();
//! let mut query_params = QueryParams::default();
//! query_params.paper_id("204e3073870fae3d05bcbc2f6a8e263d9b72e776");
//! query_params.author_fields(vec![
//! AuthorField::Name,
//! AuthorField::PaperCount,
//! AuthorField::CitationCount,
//! ]);
//!
//! let response = ss.query_paper_authors(query_params, 5, 10).await?;
//! println!("Found {} authors", response.data.len());
//! # Ok(())
//! # }
//! ```
//!
//! ## Author Data APIs
//!
//! ### Query Author Details
//!
//! Get detailed information about an author using [`SemanticScholar::query_author_details`](crate::SemanticScholar::query_author_details).
//!
//! ```rust
//! # use anyhow::Result;
//! # use ss_tools::{SemanticScholar, QueryParams};
//! # use ss_tools::structs::AuthorField;
//! # #[tokio::main]
//! # async fn main() -> Result<()> {
//! let mut ss = SemanticScholar::new();
//! let mut query_params = QueryParams::default();
//! query_params.paper_id("1741101"); // author_id is passed via paper_id field
//! query_params.author_fields(vec![
//! AuthorField::Name,
//! AuthorField::PaperCount,
//! AuthorField::CitationCount,
//! AuthorField::HIndex,
//! ]);
//!
//! let author = ss.query_author_details(query_params, 5, 10).await?;
//! println!("Author: {:?}", author.name);
//! # Ok(())
//! # }
//! ```
//!
//! ### Search Authors
//!
//! Search for authors by name using [`SemanticScholar::search_authors`](crate::SemanticScholar::search_authors).
//!
//! ```rust
//! # use anyhow::Result;
//! # use ss_tools::{SemanticScholar, QueryParams};
//! # use ss_tools::structs::AuthorField;
//! # #[tokio::main]
//! # async fn main() -> Result<()> {
//! let mut ss = SemanticScholar::new();
//! let mut query_params = QueryParams::default();
//! query_params.query_text("Geoffrey Hinton");
//! query_params.author_fields(vec![
//! AuthorField::Name,
//! AuthorField::PaperCount,
//! AuthorField::CitationCount,
//! ]);
//!
//! let response = ss.search_authors(query_params, 5, 10).await?;
//! println!("Found {} authors", response.data.len());
//! # Ok(())
//! # }
//! ```
//!
//! ### Query Author Papers
//!
//! Get papers written by a specific author using [`SemanticScholar::query_author_papers`](crate::SemanticScholar::query_author_papers).
//!
//! ```rust
//! # use anyhow::Result;
//! # use ss_tools::{SemanticScholar, QueryParams};
//! # use ss_tools::structs::PaperField;
//! # #[tokio::main]
//! # async fn main() -> Result<()> {
//! let mut ss = SemanticScholar::new();
//! let mut query_params = QueryParams::default();
//! query_params.paper_id("1741101"); // author_id
//! query_params.fields(vec![
//! PaperField::Title,
//! PaperField::Year,
//! PaperField::CitationCount,
//! ]);
//! query_params.limit(10);
//!
//! let response = ss.query_author_papers(query_params, 5, 10).await?;
//! println!("Found {} papers", response.data.len());
//! # Ok(())
//! # }
//! ```
//!
//! ## Bulk Operations
//!
//! ### Bulk Query by IDs
//!
//! Get multiple papers at once using [`SemanticScholar::bulk_query_by_ids`](crate::SemanticScholar::bulk_query_by_ids).
//!
//! ```rust
//! # use anyhow::Result;
//! # use ss_tools::SemanticScholar;
//! # use ss_tools::structs::PaperField;
//! # #[tokio::main]
//! # async fn main() -> Result<()> {
//! let paper_ids = vec![
//! "649def34f8be52c8b66281af98ae884c09aef38b",
//! "ARXIV:2106.15928",
//! ];
//! let fields = vec![PaperField::Title, PaperField::CitationCount];
//!
//! let mut ss = SemanticScholar::new();
//! let papers = ss.bulk_query_by_ids(paper_ids, fields, 5, 10).await?;
//! println!("Retrieved {} papers", papers.len());
//! # Ok(())
//! # }
//! ```