Skip to main content

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 category taxonomy
  • Fully type annotated

Usage

Daily RSS Feed

import arxiv_client as arx


client = arx.Client()
articles = client.rss_by_subject(arx.Subject.COMPUTER_SCIENCE)

Search

import arxiv_client as arx


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=10))
for article in articles:
    print(article)

Structured Search 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 fields
  • title_keywords: terms in the article title
  • author_names: names in the author list
  • categories: arXiv subject categories
  • abstract_keywords: terms in the article abstract
  • comment_keywords: terms in the author provided comment
  • article_ids: arXiv article IDs
  • custom_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'>],
#     abstract_keywords=[],
#     comment_keywords=[],
#     article_ids=[],
#     custom_params=None,
#     sort_criterion=SortCriterion(sort_by=<SortBy.LAST_UPDATED_DATE: 'lastUpdatedDate'>, sort_order=<SortOrder.DESC: 'descending'>),
#     start=0,
#     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 Search 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=[],
#     abstract_keywords=[],
#     comment_keywords=[],
#     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=0,
#     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)

Known Issues

The arXiv search API is unreliable, especially for large queries.

The API will sometimes return incomplete results or return no entries, although the response is valid. See this GitHub issue for discussion on the topic.

If you are encountering this problem, some things that may help include:

  • Reduce the page size; 100 seems to have a relatively high success rate
  • Increase paging retry and delay parameters
  • Break up large queries into smaller queries

Retries often help with the issue, but are sometimes insufficient. If you need more reliable access to large query results, consider looking into the arXiv Bulk Data Access options.

Development

This uses hatch for project management.

Metadata

Release files for arxiv-client 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for arxiv-client 0.3.2
File Size Uploaded Provenance Actions
arxiv_client-0.3.2.tar.gz 14.5 kB Without provenance Details for arxiv_client-0.3.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for arxiv-client 0.3.2
File Interpreter ABI Platform Actions
arxiv_client-0.3.2-py3-none-any.whl Python 3 none any Details for arxiv_client-0.3.2-py3-none-any.whl

Total release size: 30.6 kB

Release files / arxiv_client-0.3.2.tar.gz

Download URL arxiv_client-0.3.2.tar.gz
Size 14.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1e66c985b4c19a428013cb75c41b6665be22859ab8f81e3e449794aa4ad39827
BLAKE2b-256 checksum
How to use checksums
f42294e5354c5bf31080412da78623db6679f6f89856a6111b36b1928cb2c438
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / arxiv_client-0.3.2-py3-none-any.whl

Download URL arxiv_client-0.3.2-py3-none-any.whl
Size 16.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c936e33f9bdfebbfa0b08ffebcd543acdfb3705ed59bf3893656c5f0fce42a93
BLAKE2b-256 checksum
How to use checksums
11f3fc343f85bb2f60529cf7c24fbac5f4716e9ed17f9b1a40d4316970375e4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Security for arxiv-client 0.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page