sxolar.api.arxiv
¶
Arxiv API wrappers for sxolar, low-level functions for querying the Arxiv API.
For more user-friendly functions, see the sxolar.api.query
module.
References
[1] API Basics: https://info.arxiv.org/help/api/basics.html [2] Rate Limits: https://info.arxiv.org/help/api/tou.html [3] Search Query Language: https://info.arxiv.org/help/api/user-manual.html #query_details [4] Entry output format: https://info.arxiv.org/help/api/user-manual.html #_entry_metadata [5] ArXiv identifier format: https://info.arxiv.org/help/arxiv_identifier.html
Author
dataclass
¶
A dataclass for an author of an Arxiv entry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
str, the name of the author. |
required |
affiliation
|
str
|
str, the affiliation of the author. |
required |
Source code in sxolar/api/arxiv.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|
__str__()
¶
Return the author as a string.
Source code in sxolar/api/arxiv.py
113 114 115 |
|
Entry
dataclass
¶
A dataclass for an entry from the Arxiv API [4]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title
|
str
|
str, the title of the entry |
required |
id
|
Identifier
|
str, the Arxiv ID of the entry |
required |
published
|
datetime
|
datetime.datetime, the published date of the entry |
required |
updated
|
datetime
|
datetime.datetime, the updated date of the entry |
required |
summary
|
str
|
str, the summary of the entry |
required |
author
|
List[Author]
|
List[Author], the authors of the entry |
required |
category
|
List[Category]
|
List[Category], the categories of the entry |
required |
Source code in sxolar/api/arxiv.py
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 240 241 242 243 244 245 246 247 248 |
|
filter_authors(authors)
¶
Check if the entry has any of the given authors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
authors
|
List[str]
|
List[str], the list of authors to check for. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the entry has any of the authors, False otherwise. |
Source code in sxolar/api/arxiv.py
237 238 239 240 241 242 243 244 245 246 247 248 |
|
from_dict(data)
staticmethod
¶
Create an entry from a dictionary.
Source code in sxolar/api/arxiv.py
224 225 226 227 228 229 230 231 232 233 234 235 |
|
link()
¶
Formatted arxiv link for the entry
Source code in sxolar/api/arxiv.py
208 209 210 |
|
to_dict()
¶
Return the entry as a dictionary.
Source code in sxolar/api/arxiv.py
212 213 214 215 216 217 218 219 220 221 222 |
|
Identifier
dataclass
¶
A dataclass for an Arxiv identifier.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
number
|
str
|
str, the number of the identifier. |
required |
version
|
str
|
str, the version of the identifier. |
required |
is_new
|
bool
|
bool, whether the identifier is in the new format. |
required |
Source code in sxolar/api/arxiv.py
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 |
|
__str__()
¶
Return the identifier as a string.
Source code in sxolar/api/arxiv.py
135 136 137 138 139 |
|
link()
¶
Formatted arxiv link for the identifier
Source code in sxolar/api/arxiv.py
141 142 143 |
|
LogicalOperator
¶
Enumeration of logical operators for the Arxiv API [3]
Source code in sxolar/api/arxiv.py
280 281 282 283 284 285 |
|
SearchField
¶
Enumeration of search fields for the Arxiv API [3]
Source code in sxolar/api/arxiv.py
266 267 268 269 270 271 272 273 274 275 276 277 |
|
SortBy
¶
Bases: str
, Enum
Enumeration of sort fields for the Arxiv API [3]
Source code in sxolar/api/arxiv.py
251 252 253 254 255 256 |
|
SortOrder
¶
Bases: str
, Enum
Enumeration of sort orders for the Arxiv API [3]
Source code in sxolar/api/arxiv.py
259 260 261 262 263 |
|
execute(search_query=None, id_list=None, start=0, max_results=10, sort_by=SortBy.Relevance, sort_order=SortOrder.Descending, min_date=None, max_date=None, date_filter_field=FIELD_ENTRY_UPDATED)
¶
Query the Arxiv API with the given parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
search_query
|
str
|
str, optional, The query string to search for. Defaults to None. |
None
|
id_list
|
List[str]
|
List[str], optional, A list of Arxiv IDs to search for. Defaults to None. |
None
|
start
|
int
|
int, optional, The index to start the search from. Defaults to 0. |
0
|
max_results
|
int
|
int, optional, The maximum number of results to return. Defaults to 10. |
10
|
sort_by
|
SortBy
|
SortBy, optional, The field to sort by. Defaults to SortBy.Relevance. |
Relevance
|
sort_order
|
SortOrder
|
SortOrder, optional, The order to sort by. Defaults to SortOrder.Descending. |
Descending
|
Returns:
Type | Description |
---|---|
List[Entry]
|
List[Entry]: The list of entries returned by the query. |
Source code in sxolar/api/arxiv.py
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 |
|
find(entry, tag, find_all=False)
¶
Find the tag in the entry and return the text.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entry
|
Element
|
The entry to search. |
required |
tag
|
str
|
The tag to search for. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
Union[str, List[str]]
|
The text of the tag. |
Source code in sxolar/api/arxiv.py
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
|
format_search_query(title=None, author=None, abstract=None, comment=None, journal_reference=None, category=None, report_number=None, id_list=None, all_=None, how=LogicalOperator.AND, how_list=LogicalOperator.OR)
¶
Format the search query for the Arxiv API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title
|
Union[str, List[str]]
|
Union[str, List[str]], optional, The title to search for. Defaults to None. |
None
|
author
|
Union[str, List[str]]
|
Union[str, List[str]], optional, The author to search for. Defaults to None. |
None
|
abstract
|
Union[str, List[str]]
|
Union[str, List[str]], optional, The abstract to search for. Defaults to None. |
None
|
comment
|
Union[str, List[str]]
|
Union[str, List[str]], optional, The comment to search for. Defaults to None. |
None
|
journal_reference
|
Union[str, List[str]]
|
Union[str, List[str]], optional, The journal reference to search for. Defaults to None. |
None
|
category
|
Union[str, List[str]]
|
Union[str, List[str]], optional, The category to search for. Defaults to None. |
None
|
report_number
|
Union[str, List[str]]
|
Union[str, List[str]], optional, The report number to search for. Defaults to None. |
None
|
id_list
|
List[str]
|
List[str], optional, The list of Arxiv IDs to search for. Defaults to None. |
None
|
all_
|
Union[str, List[str]]
|
Union[str, List[str]], optional, The all field to search for. Defaults to None. |
None
|
how
|
LogicalOperator
|
LogicalOperator, optional, The logical operator to use when adding the field. Defaults to LogicalOperator.AND. |
AND
|
how_list
|
LogicalOperator
|
LogicalOperator, optional, The logical operator to use when adding a list of values. Defaults to LogicalOperator.OR. |
OR
|
Returns:
Type | Description |
---|---|
Union[str, None]
|
str or None: The formatted query string, or None if no fields are provided. |
Source code in sxolar/api/arxiv.py
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 |
|
get_and_parse(url, params)
¶
Get and parse the response from the Arxiv API, the payloads are encoded using the Atom 1 XML format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
The endpoint to query |
required |
params
|
dict
|
The parameters to pass to the query |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
List[Entry]
|
The parsed response |
Source code in sxolar/api/arxiv.py
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
|
parse_entry(entry)
¶
Parse an entry from the Arxiv API response.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entry
|
Element
|
The entry to parse. |
required |
Returns:
Name | Type | Description |
---|---|---|
Entry |
Entry
|
The parsed entry. |
Source code in sxolar/api/arxiv.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
|
parse_identifier(id_text)
¶
Parse an Arxiv identifier into its components.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_text
|
str
|
str, the Arxiv identifier to parse. |
required |
Source code in sxolar/api/arxiv.py
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 |
|
query(title=None, author=None, abstract=None, comment=None, journal_reference=None, category=None, report_number=None, id_list=None, all_=None, how=LogicalOperator.AND, how_list=LogicalOperator.OR, start=0, max_results=10, sort_by=SortBy.Relevance, sort_order=SortOrder.Descending, min_date=None, max_date=None, date_filter_field=FIELD_ENTRY_UPDATED)
¶
Query the Arxiv API with the given parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title
|
Union[str, List[str]]
|
Union[str, List[str]], optional, The title to search for. Defaults to None. |
None
|
author
|
Union[str, List[str]]
|
Union[str, List[str]], optional, The author to search for. Defaults to None. |
None
|
abstract
|
Union[str, List[str]]
|
Union[str, List[str]], optional, The abstract to search for. Defaults to None. |
None
|
comment
|
Union[str, List[str]]
|
Union[str, List[str]], optional, The comment to search for. Defaults to None. |
None
|
journal_reference
|
Union[str, List[str]]
|
Union[str, List[str]], optional, The journal reference to search for. Defaults to None. |
None
|
category
|
Union[str, List[str]]
|
Union[str, List[str]], optional, The category to search for. Defaults to None. |
None
|
report_number
|
Union[str, List[str]]
|
Union[str, List[str]], optional, The report number to search for. Defaults to None. |
None
|
id_list
|
List[str]
|
List[str], optional, The list of Arxiv IDs to search for. Defaults to None. |
None
|
all_
|
Union[str, List[str]]
|
Union[str, List[str]], optional, The all field to search for. Defaults to None. |
None
|
how
|
LogicalOperator
|
LogicalOperator, optional, The logical operator to use when adding the field. Defaults to LogicalOperator.AND. |
AND
|
how_list
|
LogicalOperator
|
LogicalOperator, optional, The logical operator to use when adding a list of values. Defaults to LogicalOperator.OR. |
OR
|
start
|
int
|
int, optional, The index to start the search from. Defaults to 0. |
0
|
max_results
|
int
|
int, optional, The maximum number of results to return. Defaults to 10. |
10
|
sort_by
|
SortBy
|
SortBy, optional, The field to sort by. Defaults to SortBy.Relevance. |
Relevance
|
sort_order
|
SortOrder
|
SortOrder, optional, The order to sort by. Defaults to SortOrder.Descending. |
Descending
|
Source code in sxolar/api/arxiv.py
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 |
|