Skip to main content

arXivFlow 🚀

License: MIT Python 3.13+ Static Badge Ollama Gemini arXiv

arXivFlow is a powerful Python-based automation tool designed to streamline the research paper discovery and tracking process. It autonomously fetches metadata from arXiv, performs AI-driven analysis using Ollama or the Gemini API, and synchronizes the results with Google Sheets and local databases.


✨ Features

  • Asynchronous API: Fully rewritten with asyncio for high-performance paper retrieval and PDF processing.
  • Automated Retrieval: Fetch the latest papers from specific arXiv categories (e.g., cs.AI, cs.LG, hep-ph) within any date range.
  • AI Analysis Options: Uses Ollama models for local/private extraction or Gemini models for cloud-backed extraction of keywords and contact information (emails/affiliations).
  • Intelligent PDF Handling: Automatically downloads PDFs and extracts text for deep analysis. Supports custom storage paths and atomic PDF writes.
  • Robust arXiv Requests: Built-in compliance with arXiv's API guidelines (3-second request intervals), paged metadata retrieval, 429 cooldown handling, retry backoff, and duplicate-result cleanup.
  • Multi-Format Export: Save your research data to CSV, JSON, Excel, or SQLite for flexible offline analysis.
  • Google Sheets Sync: Seamlessly push compiled research data to a shared Google Sheet for team collaboration.
  • Type-Safe & Modular: Clean, documented Python code with full type hinting and a class-based architecture.

🛠️ Prerequisites

  1. Python 3.13+: Ensure you have a modern Python environment.
  2. Choose an AI backend:
    • For Ollama, install Ollama and download the required model (e.g., Llama 3.2):
      ollama pull llama3.2
      
    • For Gemini, create a Gemini API key and either pass it as gemini_api_key or set it as GOOGLE_AI_API.
  3. Google Cloud Credentials for Google Sheets sync:
    • Enable the Google Sheets and Google Drive APIs.
    • Create a Service Account and download the JSON key as credentials.json.
    • Ensure the service account has 'Editor' permissions on the sheet.

🚀 Installation

pip install arxivflow

From Source (For Development)

  1. Clone the repository:

    git clone https://github.com/zjzhao/arXivFlow.git
    cd arXivFlow
    
  2. Set up virtual environment:

    python -m venv .
    source bin/activate  # On Windows: Scripts\activate
    
  3. Install dependencies:

    pip install -e .
    

📖 Usage

Quick Start (Async)

import asyncio
import datetime
from arxivflow import arXivFlow

async def main():
    # 1. Initialize the flow with Ollama
    flow = arXivFlow(
        categories=["cs.AI", "cs.CV"], 
        ollama_model="llama3.2",
        max_results=20,
        start_date=datetime.datetime.now() - datetime.timedelta(days=7),
        request_timeout=60.0
    )

    # 2. Fetch data & Extract info (Keywords/Contacts)
    df = await flow.get_arxiv_data(download_pdfs=True)

    # 3. Save to your preferred formats
    flow.save_to_csv("my_research.csv")
    flow.save_to_sqlite("research.db")

    # 4. Sync with Google Sheets
    flow.save_to_google_sheet(
        sheet_id="YOUR_SHEET_ID", 
        credentials_file="credentials.json"
    )
    
    # 5. Close the client
    await flow.close()

if __name__ == "__main__":
    asyncio.run(main())

Gemini Backend

import asyncio
import datetime
import os
from arxivflow import arXivFlow

async def main():
    flow = arXivFlow(
        categories=["cs.AI", "cs.CV"],
        gemini_model="gemini-2.5-flash",
        gemini_api_key=os.getenv("GOOGLE_AI_API"),
        max_results=20,
        start_date=datetime.datetime.now() - datetime.timedelta(days=7),
    )

    df = await flow.get_arxiv_data(download_pdfs=True)
    flow.save_to_csv("my_research.csv")
    await flow.close()

if __name__ == "__main__":
    asyncio.run(main())

If both ollama_model and gemini_model are provided, Ollama takes precedence. When gemini_model is set, a Gemini API key is required; pass gemini_api_key directly or set the GOOGLE_AI_API environment variable.


🧱 Request Stability

arXiv can occasionally return slow responses, rate limits, or temporary service errors. arXivFlow now makes the request path more stable by:

  • Fetching arXiv metadata in smaller pages instead of relying on one large request.
  • Fetching metadata for all requested categories before starting PDF downloads, which avoids PDF download bursts interfering with the next category query.
  • Serializing arXiv requests and preserving the recommended 3-second interval.
  • Retrying transient failures (429, 500, 502, 503, 504, timeouts, and network errors) with exponential backoff and jitter.
  • Applying a longer cooldown after 429 rate-limit responses before making the next arXiv request.
  • Respecting Retry-After headers when arXiv provides them.
  • Using a default 60-second request timeout, configurable with request_timeout.
  • Writing PDFs to temporary .part files first, then atomically replacing the final file only after validating PDF-like content.
  • Deduplicating merged output by arXiv ID.

For especially large date ranges, prefer smaller max_results values or narrower date windows. arXivFlow will page requests internally, but smaller slices are still easier for arXiv and more reliable in practice.


🏗️ Architecture

The project follows a modular structure for easy extension:

  • src/arxivflow/arxivflow.py: The main orchestrator class (arXivFlow).
  • src/arxivflow/ollama_functions.py: Local LLM interface using the Ollama API.
  • src/arxivflow/gemini_functions.py: Gemini API interface for cloud-backed keyword and contact extraction.
  • src/arxivflow/arxiv_functions.py: Asynchronous arXiv API interaction layer, including paging, rate limiting, retries, and PDF downloads.
  • src/arxivflow/categories.py: arXiv category definitions.

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

🤝 Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Metadata

Release files for arxivflow 0.3.0

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

Source distribution (sdist)

Source distribution for arxivflow 0.3.0
File Size Uploaded Provenance Actions
arxivflow-0.3.0.tar.gz 24.5 kB With provenance Details for arxivflow-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 43.3 kB

Release files / arxivflow-0.3.0.tar.gz

Download URL arxivflow-0.3.0.tar.gz
Size 24.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5a49fdab966ad2a5b563eac7e6f62c1f3fd7e307d62c02aa30418cc02a5dc9d4
BLAKE2b-256 checksum
How to use checksums
56a7c4db1b28d111321af878f7486f3d5438f44480e4672eea59d33cdee0f2ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 27, 2026.

Transparency log

Release files / arxivflow-0.3.0-py3-none-any.whl

Download URL arxivflow-0.3.0-py3-none-any.whl
Size 18.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2320f829c1053fb06341834b8f703e2e23e4fe23cd8b81a1ecebf3b2e04dd36e
BLAKE2b-256 checksum
How to use checksums
9d86d0cf63da8aac03a2aec9ec22f71c8a30e06d4560053b1cdedb65912cfbe7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 27, 2026.

Transparency log

Security for arxivflow 0.3.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for arxivflow-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 27, 2026.

Transparency log

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