Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

arxiv.py

PyPI PyPI - Python Version GitHub Workflow Status (branch) Full package documentation

Python wrapper for the arXiv API.

arXiv is a project by the Cornell University Library that provides open access to 1,000,000+ articles in Physics, Mathematics, Computer Science, Quantitative Biology, Quantitative Finance, and Statistics.

Usage

Installation

$ pip install arxiv

For Modern Python Development (with UV)

$ uv add arxiv

Or for a one-off script:

$ uvx --from arxiv python -c "import arxiv; print('Working!')"

Usage

In your Python script, include the line:

import arxiv

Examples

Fetching results

import arxiv

# Construct the default API client.
client = arxiv.Client()

# Search for the 10 most recent articles matching the keyword "quantum."
search = arxiv.Search(
  query = "quantum",
  max_results = 10,
  sort_by = arxiv.SortCriterion.SubmittedDate
)

results = client.results(search)

# `results` is a generator; you can iterate over its elements one by one...
for r in client.results(search):
  print(r.title)
# ...or exhaust it into a list. Careful: this is slow for large results sets.
all_results = list(results)
print([r.title for r in all_results])

# For advanced query syntax documentation, see the arXiv API User Manual:
# https://arxiv.org/help/api/user-manual#query_details
search = arxiv.Search(query = "au:del_maestro AND ti:checkerboard")
first_result = next(client.results(search))
print(first_result)

# Search for the paper with ID "1605.08386v1"
search_by_id = arxiv.Search(id_list=["1605.08386v1"])
# Reuse client to fetch the paper, then print its title.
first_result = next(client.results(search_by_id))
print(first_result.title)

Fetching results with a custom client

import arxiv

big_slow_client = arxiv.Client(
  page_size = 1000,
  delay_seconds = 10.0,
  num_retries = 5
)

# Prints 1000 titles before needing to make another request.
for result in big_slow_client.results(arxiv.Search(query="quantum")):
  print(result.title)

Logging

To inspect this package's network behavior and API logic, configure a DEBUG-level logger.

>>> import logging, arxiv
>>> logging.basicConfig(level=logging.DEBUG)
>>> client = arxiv.Client()
>>> paper = next(client.results(arxiv.Search(id_list=["1605.08386v1"])))
INFO:arxiv.arxiv:Requesting 100 results at offset 0
INFO:arxiv.arxiv:Requesting page (first: False, try: 0): https://export.arxiv.org/api/query?search_query=&id_list=1605.08386v1&sortBy=relevance&sortOrder=descending&start=0&max_results=100
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): export.arxiv.org:443
DEBUG:urllib3.connectionpool:https://export.arxiv.org:443 "GET /api/query?search_query=&id_list=1605.08386v1&sortBy=relevance&sortOrder=descending&start=0&max_results=100&user-agent=arxiv.py%2F1.4.8 HTTP/1.1" 200 979

Types

Client

A Client specifies a reusable strategy for fetching results from arXiv's API. For most use cases the default client should suffice.

Clients configurations specify pagination and retry logic. Reusing a client allows successive API calls to use the same connection pool and ensures they abide by the rate limit you set.

A Search specifies a search of arXiv's database. Use Client.results to get a generator yielding Results.

Result

The Result objects yielded by Client.results include metadata about each paper and helper methods for downloading their content.

The meaning of the underlying raw data is documented in the arXiv API User Manual: Details of Atom Results Returned.

Result also exposes helper methods for downloading papers: Result.download_pdf and Result.download_source.

Development

This project uses UV for development, while maintaining compatibility with traditional pip installation for end users.

Development Setup

  1. Install UV (if you haven't already):

    curl -LsSf https://astral.sh/uv/install.sh | sh
    
  2. Clone and setup:

    git clone https://github.com/lukasschwab/arxiv.py
    cd arxiv.py
    make dev-setup
    
  3. Available commands:

    make test      # Run tests
    make lint      # Run linting  
    make format    # Format code
    make docs      # Generate docs
    make check     # Run lint + test
    make audit     # Security audit
    

For End Users

Even though development uses UV, end users can continue using pip as always:

pip install arxiv  # Still works perfectly!

Both installation methods provide the same functionality - UV just offers a faster development experience.

Modern Python Packaging

This project uses current Python packaging standards:

  • pyproject.toml for all configuration (no setup.py)
  • uv.lock for reproducible development environments
  • Hatchling build backend for fast, reliable builds
  • UV for lightning-fast dependency management

Metadata

Release files for arxiv 2.3.2.dev15

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 2.3.2.dev15
File Size Uploaded Provenance Actions
arxiv-2.3.2.dev15.tar.gz 75.0 kB Without provenance Details for arxiv-2.3.2.dev15.tar.gz

Built distribution (wheel)

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

Total release size: 87.4 kB

Release files / arxiv-2.3.2.dev15.tar.gz

Download URL arxiv-2.3.2.dev15.tar.gz
Size 75.0 kB
Tags Source
SHA-256 checksum
How to use checksums
77ee00b1dd9628feb6da8f2b6812eb13126cd425734cec5960b840b7569252a5
BLAKE2b-256 checksum
How to use checksums
2fda4f07142f585c0d180e28eb7fc336bec1b593050585798eeadb34f972a374
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.4

Release files / arxiv-2.3.2.dev15-py3-none-any.whl

Download URL arxiv-2.3.2.dev15-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a0e99ec3c5aa603a66e10029e71373fcb2c15438541bd3472965f19e680a3392
BLAKE2b-256 checksum
How to use checksums
814c1883f353476adf2ed66979278fdc248c69717d6c030d5cda31a09f98fc1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.4

Security for arxiv 2.3.2.dev15

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.

Release history Release notifications | RSS feed

This release
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