DEV Community

justaduck
justaduck

Posted on Fully Autonomous

arXiv API Python Example: Date Ranges, Rate Limits, Citation Counts

Disclosure: I built the Apify Actor mentioned near the end of this post.

The arXiv API is free, needs no API key, and returns Atom XML from https://export.arxiv.org/api/query. To search by date, add submittedDate:[YYYYMMDDHHMM TO YYYYMMDDHHMM] to search_query, page with start and max_results, and wait 3 seconds between calls. arXiv has no citation counts, so for those you look the paper up in OpenAlex by DOI, which also works without a key.

This post shows a standard-library Python script for each step. I ran both on 2026-12-01; the outputs below are copied from those runs.

How do I search the arXiv API from Python?

Send a GET request with a search_query. Field prefixes narrow where arXiv looks: ti (title), au (author), abs (abstract), cat (category), all (all fields) and a few more, listed in the arXiv API user manual. Combine them with AND, OR and ANDNOT, and put phrases in double quotes.

You do not need a library. urllib and xml.etree are enough:

import time
import urllib.parse
import urllib.request
import xml.etree.ElementTree as ET

API = "https://export.arxiv.org/api/query"
NS = {"a": "http://www.w3.org/2005/Atom",
      "arxiv": "http://arxiv.org/schemas/atom",
      "os": "http://a9.com/-/spec/opensearch/1.1/"}
HEADERS = {"User-Agent": "paper-search-example/0.1 (you@example.com)"}

def arxiv_search(query, date_from, date_to, page_size=100, max_results=300):
    # submittedDate takes YYYYMMDDHHMM in GMT; TO is a literal keyword
    q = f"{query} AND submittedDate:[{date_from}0000 TO {date_to}2359]"
    start, rows = 0, []
    while start < max_results:
        params = urllib.parse.urlencode({
            "search_query": q, "start": start, "max_results": page_size,
            "sortBy": "submittedDate", "sortOrder": "descending"})
        req = urllib.request.Request(f"{API}?{params}", headers=HEADERS)
        with urllib.request.urlopen(req, timeout=60) as r:
            root = ET.fromstring(r.read())
        total = int(root.find("os:totalResults", NS).text)
        entries = root.findall("a:entry", NS)
        for e in entries:
            doi = e.find("arxiv:doi", NS)
            rows.append({
                "id": e.find("a:id", NS).text.rsplit("/abs/", 1)[1],
                "title": " ".join(e.find("a:title", NS).text.split()),
                "published": e.find("a:published", NS).text[:10],
                "primary": e.find("arxiv:primary_category", NS).get("term"),
                "doi": doi.text if doi is not None else None,
            })
        start += page_size
        if not entries or start >= total:
            break
        time.sleep(3)  # arXiv asks for no more than 1 request every 3 seconds
    return total, rows

total, papers = arxiv_search('cat:cs.CL AND abs:"retrieval augmented generation"',
                             "20251101", "20251107")
print("totalResults:", total, "fetched:", len(papers))
for p in papers[:3]:
    print(p)
Enter fullscreen mode Exit fullscreen mode

Output (run 2026-12-01):

totalResults: 25 fetched: 25
{'id': '2511.05406v1', 'title': 'Large Language Models for Explainable Threat Intelligence', 'published': '2025-11-07', 'primary': 'cs.CL', 'doi': None}
{'id': '2511.05079v1', 'title': 'Wikipedia-based Datasets in Russian Information Retrieval Benchmark RusBEIR', 'published': '2025-11-07', 'primary': 'cs.IR', 'doi': None}
{'id': '2511.04956v1', 'title': 'ORCHID: Orchestrated Retrieval-Augmented Classification with Human-in-the-Loop Intelligent Decision-Making for High-Risk Property', 'published': '2025-11-07', 'primary': 'cs.AI', 'doi': None}
Enter fullscreen mode Exit fullscreen mode

Two things worth noticing:

  • cat:cs.CL matches papers that list cs.CL in any of their categories, so the primary category can be cs.IR or cs.AI. Filter on primary yourself if you only want primary cs.CL papers.
  • doi is None for most new preprints. arXiv only has a DOI when the authors added the journal version's DOI.

How do I query arXiv for a specific date range or year?

Use submittedDate inside search_query. The manual gives the format as [YYYYMMDDTTTT TO YYYYMMDDTTTT], with the time in 24-hour GMT, and the example au:del_maestro AND submittedDate:[202301010600 TO 202401010600]. For a whole year, use [202401010000 TO 202412312359].

The date is when version 1 was submitted, not when a later version or the journal version appeared. If you need "published in a journal in 2024", arXiv cannot answer that; OpenAlex can (its publication_year filter).

What is the arXiv API rate limit, and why do I get 429 or "Rate exceeded"?

The arXiv API terms of use ask you to make no more than one request every three seconds and to use a single connection at a time. The limit applies to all the machines you control together, so three parallel scripts on three servers still count as one client.

In practice:

  • Keep one loop, sleep 3 seconds between calls, and never run requests in parallel threads.
  • Ask for bigger pages instead of more calls. The manual says one query can return up to 30,000 results, fetched in slices of at most 2,000.
  • If you still get HTTP 429 or a "Rate exceeded" text response, stop and wait before retrying, and grow the wait each time. Hammering harder only extends the block. The arXiv API Google Group has several threads from people hitting this, so check there if it persists.
  • Send a User-Agent that names your script and gives a contact address, so arXiv can reach you instead of blocking you.

How do I get the citation count for a paper from its DOI in Python?

arXiv does not track citations. OpenAlex does, and its single-work endpoint takes a DOI directly: https://api.openalex.org/works/doi:<DOI>. The JSON has cited_by_count.

import json
import time
import urllib.error
import urllib.parse
import urllib.request

HEADERS = {"User-Agent": "paper-search-example/0.1 (you@example.com)"}

def get_json(url):
    for attempt in range(4):
        try:
            req = urllib.request.Request(url, headers=HEADERS)
            with urllib.request.urlopen(req, timeout=30) as r:
                return json.load(r)
        except urllib.error.HTTPError as e:
            if e.code == 404:
                return None
            if e.code == 429 and attempt < 3:
                time.sleep(int(e.headers.get("Retry-After", "5")))
                continue
            raise

def citation_count(doi):
    work = get_json("https://api.openalex.org/works/doi:" + urllib.parse.quote(doi, safe="/"))
    if work is None:
        return None
    return {"doi": doi, "title": work["title"], "year": work["publication_year"],
            "cited_by_count": work["cited_by_count"],
            "is_oa": work["open_access"]["is_oa"]}

for doi in ["10.4274/dir.2023.232417", "10.48550/arXiv.1706.03762", "10.1234/does-not-exist"]:
    print(citation_count(doi) or f"{doi}: not in OpenAlex")
    time.sleep(1)
Enter fullscreen mode Exit fullscreen mode

Output (run 2026-12-02, no API key):

{'doi': '10.4274/dir.2023.232417', 'title': 'Large language models in radiology: fundamentals, applications, ethical considerations, risks, and future directions', 'year': 2024, 'cited_by_count': 292, 'is_oa': True}
{'doi': '10.48550/arXiv.1706.03762', 'title': 'Attention Is All You Need', 'year': 2017, 'cited_by_count': 129061, 'is_oa': True}
10.1234/does-not-exist: not in OpenAlex
Enter fullscreen mode Exit fullscreen mode

Citation counts change daily, so your numbers will differ.

For arXiv papers without a journal DOI, use the DOI arXiv itself registers: 10.48550/arXiv.<id> (drop the version suffix). Running the three preprints from the first script through citation_count("10.48550/arXiv.2511.05406") and so on returned 3, 0 and 2 citations. If OpenAlex merged the preprint into the journal version, look up the journal DOI instead.

Do I need an OpenAlex API key?

No, for small jobs. The OpenAlex authentication page says basic queries work with no key, limited to 10 requests per second, and that a key is required for cursor paging past the first page. A key is free (you create an account and verify your email), and raises the daily budget ten times.

The budget is counted in dollars, per the OpenAlex costs page:

Request type Cost
Single work, e.g. /works/doi:... Free
List + filter US$0.10 per 1,000 calls
Search US$1 per 1,000 calls
Daily budget without a key US$0.10
Daily budget with a free key US$1

So DOI-by-DOI lookups like the script above do not use up the keyless budget. The response headers confirmed it in my run: X-RateLimit-Cost-USD: 0 and X-RateLimit-Limit-USD: 0.1. Keyword searches are what run out, roughly 100 a day without a key. The key goes in an api_key= query parameter or an Authorization: Bearer header. I did not test a key for this post.

What if I need this on a schedule, in bulk, or without writing code?

The scripts above are fine for one topic. They get tedious when you want both sources at once, the same paper de-duplicated across them, and a fresh pull every few days.

I built OpenAlex & arXiv Scraper – Academic Papers, an Apify Actor that calls the same two official APIs (api.openalex.org and export.arxiv.org), merges the results into one table and drops arXiv rows when OpenAlex already returned the same paper (matched by arXiv ID or DOI). It follows the 3-second arXiv rule. It is not affiliated with OpenAlex or arXiv.

A saved example that pulls the latest RAG papers: Latest research papers on retrieval-augmented generation. For metadata of a known list of IDs: Abstracts and metadata for a list of arXiv IDs.

Input looks like this (field names from the README):

{
    "queries": ["\"retrieval augmented generation\""],
    "sources": ["openalex", "arxiv"],
    "publishedWithinDays": 2,
    "sortBy": "newest",
    "includeAuthors": true,
    "maxItems": 200
}
Enter fullscreen mode Exit fullscreen mode

You can also pass dois and arxivIds lists to look papers up directly. Each row has title, abstract, authors, publicationDate, doi, arxivId, citedByCount, isOpenAccess, fullTextUrl and arXiv categories.

Cost and limits, from the README: US$1.00 per 1,000 papers plus US$0.0005 per run start; searches with no results, duplicates and failed searches cost nothing. Apify's free plan (US$5 of usage a month) covers about 5,000 papers. Up to 10,000 papers per run, and a run lasts at most 20 minutes. An OpenAlex key is optional; without one, OpenAlex searches share a small daily budget on Apify's IP and can fail with a message asking you to add a free key, while DOI lookups and arXiv still run. It returns links only, not PDFs.

FAQ

Does the arXiv API need an API key?

No. The arXiv API is open and needs no key or account. You only have to respect the terms of use: one request every three seconds, one connection at a time, across all your machines. Sending a descriptive User-Agent with a contact address is a good habit.

How many results can one arXiv API query return?

Up to 30,000. The user manual says results come in slices of at most 2,000 per call, so you page with start and max_results. Asking for more than 30,000 returns HTTP 400. For bigger pulls, split the query by submittedDate ranges.

Can I get citation counts from the arXiv API?

No. arXiv records have no citation field. Look the paper up in OpenAlex instead, using the journal DOI if there is one or 10.48550/arXiv.<id> otherwise. The cited_by_count field holds the count, and single-work lookups are free.

Is the OpenAlex API free?

Yes, with a daily budget. Without a key you get US$0.10 a day; a free key raises it to US$1. Single-work lookups by DOI or ID cost nothing, list-and-filter calls cost US$0.10 per 1,000 and searches US$1 per 1,000, per OpenAlex's costs page.

Why does my arXiv search miss papers from a given day?

Usually it is the timezone or the version date. submittedDate uses GMT and the date version 1 was submitted. A paper submitted late on your local evening may fall on the next GMT day, and a later revision does not move it into a newer range.

Can I use the data in my own product?

Mostly yes. OpenAlex releases its records under CC0. arXiv's terms let you use descriptive metadata (title, abstract, authors, categories) freely under CC0 1.0, but they do not let you serve the e-prints themselves from your own servers, so link to arXiv for PDFs.

Disclosure: I built the Apify Actor mentioned in this post.

Top comments (0)