Skip to main content

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


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 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 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)

Development

This uses hatch for project management.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

arxiv_client-0.2.6.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

arxiv_client-0.2.6-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file arxiv_client-0.2.6.tar.gz.

File metadata

  • Download URL: arxiv_client-0.2.6.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for arxiv_client-0.2.6.tar.gz
Algorithm Hash digest
SHA256 394537b04107a6f9171f64d65893735184abf777d4b2c5876c6d74475b12407c
MD5 9df49bcfea654ae46dfc52f976e11ee7
BLAKE2b-256 0a4612dbb656cd85bfc5cfe603972c565ce1ce53503641013f1b642c5f92b883

See more details on using hashes here.

File details

Details for the file arxiv_client-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: arxiv_client-0.2.6-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.3

File hashes

Hashes for arxiv_client-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1ada508f0bb2f71478f4a70d37548f4f6c1fd8b70822c704f5f29d70bc7e7767
MD5 de5ac119d8bd3765da535d38249385be
BLAKE2b-256 d0d0ee08dfb2113fcdcc0252f01d3ee58836bfddc00c8c62ca0b1d8f3b5b32cb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page