You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-19Lines changed: 20 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,19 +36,19 @@ A `Search` specifies a search of arXiv's database.
36
36
arxiv.Search(
37
37
query: str="",
38
38
id_list: List[str] = [],
39
-
max_results: float=float('inf'),
39
+
max_results: int|None=None,
40
40
sort_by: SortCriterion= SortCriterion.Relevance,
41
41
sort_order: SortOrder= SortOrder.Descending
42
42
)
43
43
```
44
44
45
45
+`query`: an arXiv query string. Advanced query formats are documented in the [arXiv API User Manual](https://arxiv.org/help/api/user-manual#query_details).
46
46
+`id_list`: list of arXiv record IDs (typically of the format `"0710.5765v1"`). See [the arXiv API User's Manual](https://arxiv.org/help/api/user-manual#search_query_and_id_list) for documentation of the interaction between `query` and `id_list`.
47
-
+`max_results`: The maximum number of results to be returned in an execution of this search. To fetch every result available, set `max_results=float('inf')` (default); to fetch up to 10 results, set `max_results=10`. The API's limit is 300,000 results.
47
+
+`max_results`: The maximum number of results to be returned in an execution of this search. To fetch every result available, set `max_results=None` (default); to fetch up to 10 results, set `max_results=10`. The API's limit is 300,000 results.
48
48
+`sort_by`: The sort criterion for results: `relevance`, `lastUpdatedDate`, or `submittedDate`.
49
49
+`sort_order`: The sort order for results: `'descending'` or `'ascending'`.
50
50
51
-
To fetch arXiv records matching a `Search`, use `search.results()` or `(Client).results(search)` to get a generator yielding `Result`s.
51
+
To fetch arXiv records matching a `Search`, use `(Client).results(search)` to get a generator yielding `Result`s.
52
52
53
53
#### Example: fetching results
54
54
@@ -63,7 +63,7 @@ search = arxiv.Search(
63
63
sort_by= arxiv.SortCriterion.SubmittedDate
64
64
)
65
65
66
-
for result insearch.results():
66
+
for result inarxiv.Client().results(search):
67
67
print(result.title)
68
68
```
69
69
@@ -72,16 +72,18 @@ Fetch and print the title of the paper with ID "1605.08386v1:"
72
72
```python
73
73
import arxiv
74
74
75
+
client = arxiv.Client()
75
76
search = arxiv.Search(id_list=["1605.08386v1"])
76
-
paper =next(search.results())
77
+
78
+
paper =next(arxiv.Client().results(search))
77
79
print(paper.title)
78
80
```
79
81
80
82
### Result
81
83
82
84
<!-- TODO: improve this section. -->
83
85
84
-
The `Result` objects yielded by `(Search).results()` include metadata about each paper and some helper functions for downloading their content.
86
+
The `Result` objects yielded by `(Client).results()` include metadata about each paper and some helper functions for downloading their content.
85
87
86
88
The meaning of the underlying raw data is documented in the [arXiv API User Manual: Details of Atom Results Returned](https://arxiv.org/help/api/user-manual#_details_of_atom_results_returned).
87
89
@@ -108,7 +110,7 @@ To download a PDF of the paper with ID "1605.08386v1," run a `Search` and then u
108
110
```python
109
111
import arxiv
110
112
111
-
paper =next(arxiv.Search(id_list=["1605.08386v1"]).results())
113
+
paper =next(arxiv.Client().results(arxiv.Search(id_list=["1605.08386v1"])))
112
114
# Download the PDF to the PWD with a default filename.
113
115
paper.download_pdf()
114
116
# Download the PDF to the PWD with a custom filename.
@@ -122,7 +124,7 @@ The same interface is available for downloading .tar.gz files of the paper sourc
122
124
```python
123
125
import arxiv
124
126
125
-
paper =next(arxiv.Search(id_list=["1605.08386v1"]).results())
127
+
paper =next(arxiv.Client().results(arxiv.Search(id_list=["1605.08386v1"])))
126
128
# Download the archive to the PWD with a default filename.
127
129
paper.download_source()
128
130
# Download the archive to the PWD with a custom filename.
A `Client` specifies a strategy for fetching results from arXiv's API; it obscures pagination and retry logic.
137
-
138
-
For most use cases the default client should suffice. You can construct it explicitly with `arxiv.Client()`, or use it via the `(Search).results()` method.
138
+
A `Client` specifies a strategy for fetching results from arXiv's API; it obscures pagination and retry logic. For most use cases the default client should suffice.
139
139
140
140
```python
141
+
# Default client properties.
141
142
arxiv.Client(
142
143
page_size: int=100,
143
-
delay_seconds: int=3,
144
+
delay_seconds: float=3.0,
144
145
num_retries: int=3
145
146
)
146
147
```
@@ -151,14 +152,12 @@ arxiv.Client(
151
152
152
153
#### Example: fetching results with a custom client
153
154
154
-
`(Search).results()` uses the default client settings. If you want to use a client you've defined instead of the defaults, use `(Client).results(...)`:
155
-
156
155
```python
157
156
import arxiv
158
157
159
158
big_slow_client = arxiv.Client(
160
159
page_size=1000,
161
-
delay_seconds=10,
160
+
delay_seconds=10.0,
162
161
num_retries=5
163
162
)
164
163
@@ -173,9 +172,11 @@ To inspect this package's network behavior and API logic, configure an `INFO`-le
173
172
174
173
```pycon
175
174
>>> import logging, arxiv
176
-
>>> logging.basicConfig(level=logging.INFO)
177
-
>>> paper =next(arxiv.Search(id_list=["1605.08386v1"]).results())
175
+
>>> logging.basicConfig(level=logging.DEBUG)
176
+
>>> client = arxiv.Client()
177
+
>>> paper =next(client.results(arxiv.Search(id_list=["1605.08386v1"])))
178
178
INFO:arxiv.arxiv:Requesting 100 results at offset 0
179
-
INFO:arxiv.arxiv:Requesting page of results
180
-
INFO:arxiv.arxiv:Got first page; 1 of inf results available
0 commit comments