Python3 client for the arXiv API
Project description
arxiv-client
Python3 client for the arXiv API.
Install package arxiv_client
from PyPI.
This differs from the pre-existing arxiv.py project in that it further abstracts away the arXiv API so you do not need to learn to construct query strings. The overall goal is to enable users to skip reading the API docs entirely.
Basic Features
- Simple structured queries
- Comprehensive entity models, with documentation
- For example, see the Category enum for arXiv's subject taxonomy
- Fully type annotated
Usage
In a nutshell:
import arxiv_client as arx
import pprint
categories = [arx.Category.CS_AI, arx.Category.CS_CL, arx.Category.CS_IR]
client = arx.Client()
articles = client.search(arx.Query(keywords=["llm"], categories=categories, max_results=2))
for article in articles:
pprint.pprint(article) # Formatted pretty print is supported
Structured Query Logic
When using the structured Query
fields, multiple values within a single field are combined using OR
,
and multiple fields are combined using AND
.
Searchable Fields
The Query
object accepts the following field filters:
keywords
: terms across all fieldstitle_keywords
: terms in the article titleauthor_names
: names in the author listcategories
: arXiv subject categoriesabstract_keywords
: terms in the article abstractcomment_keywords
: terms in the author provided commentarticle_ids
: arXiv article IDscustom_params
: custom query string
Example
Query(keywords=["llm"], categories=[Category.CS_AI, Category.CS_IR], max_results=5)
# Query(keywords=['llm'],
# title_keywords=[],
# author_names=[],
# categories=[<Category.CS_AI: 'cs.AI'>, <Category.CS_IR: 'cs.IR'>],
# article_ids=[],
# custom_params=None,
# sort_criterion=SortCriterion(sort_by=<SortBy.LAST_UPDATED_DATE: 'lastUpdatedDate'>,
# sort_order=<SortOrder.DESC: 'descending'>),
# start=None,
# max_results=5)
Results in the following query logic:
("llm") in any field AND (cs.AI OR cs.IR) in the categories
See the Query class for more information.
Custom Queries
If the provided simple query logic is insufficient, the Query
object takes a self-built query string through the custom_params
attribute. You do not need to URL encode this value.
See arXiv Query Construction for more information on building your own queries.
Example
custom = f"cat:{Category.CS_AI.value} ANDNOT cat:{Category.CS_RO.value}"
Query(keywords=["paged attention", "attention window"], custom_params=custom)
# Query(keywords=['paged attention', 'attention window'],
# title_keywords=[],
# author_names=[],
# categories=[],
# article_ids=[],
# custom_params='cat:cs.AI ANDNOT cat:cs.RO',
# sort_criterion=SortCriterion(sort_by=<SortBy.LAST_UPDATED_DATE: 'lastUpdatedDate'>,
# sort_order=<SortOrder.DESC: 'descending'>),
# start=None,
# max_results=10)
Results in the following query logic:
("paged attention" OR "attention window") in any field AND (cs.AI AND NOT cs.RO) in the categories
Equivalent query string:
(all:"paged attention" OR all:"attention window") AND (cat:cs.AI ANDNOT cat:cs.RO)
Development
This uses hatch for project management.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file arxiv_client-0.2.3.tar.gz
.
File metadata
- Download URL: arxiv_client-0.2.3.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b930f3b5bf46d6586cf582591d854cbeb7516531436dbf20b77bca8bd267a7de |
|
MD5 | b78f7e93bda577c5ebd780f161ffa8c0 |
|
BLAKE2b-256 | cd5511faa95e72946fe97d5b64f98b5f25729ac80e83d355877d785ccc1f9d34 |
File details
Details for the file arxiv_client-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: arxiv_client-0.2.3-py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9eccb9cb4b4497377b2fc15e9211034028afa8e3a547de4c322fce8c6893c964 |
|
MD5 | 5dd9fe161244871cf5d18630c19d3827 |
|
BLAKE2b-256 | 61d08cd115bed6447c968c88bfe61e04506e1ca458484d5a1408089d20ee2903 |