Go SDK for the arXiv API. Provides an ergonomic, type-safe client for searching and retrieving arXiv articles while honoring the platform's usage guidelines.
- Idiomatic
Clientwith functional options, request/response hooks, and context support - Declarative query builder with full category taxonomy validation
- Built-in 3-second rate limiter (required by arXiv ToU)
- Pagination helpers (
SearchAll,StreamResults,Iterate) capped at 30,000 results - Export helpers (BibTeX, JSON, CSV) for downstream workflows
- Rate-limit-friendly PDF downloader with progress callbacks
go get github.com/mtreilly/goarxivpackage main
import (
"context"
"fmt"
"log"
"github.com/mtreilly/goarxiv"
)
func main() {
client, err := goarxiv.New()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
results, err := client.Search(ctx, "all:quantum computing", nil)
if err != nil {
log.Fatal(err)
}
for _, article := range results.Articles {
fmt.Printf("%s - %s\n", article.ID, article.Title)
}
}// Iterate through results one at a time
iter := client.Iterate("cat:cs.LG", 50, nil)
for iter.Next(ctx) {
article := iter.Article()
fmt.Printf("%s - %s\n", article.ID, article.Title)
}
if err := iter.Err(); err != nil {
log.Fatal(err)
}// Export to BibTeX
bibtex := article.ToBibTeX()
// Export to JSON
jsonData, _ := article.ToJSON()
// Export to CSV row
csvRow := article.ToCSV()err := client.DownloadPDF(ctx, article, &goarxiv.DownloadOptions{
OutputDir: "./papers",
OnProgress: func(downloaded, total int64) {
fmt.Printf("%.1f%%\n", float64(downloaded)/float64(total)*100)
},
})The arXiv API requires a minimum 3-second delay between requests. This client enforces rate limiting automatically. For local testing against mock servers, you can use WithDebugMode(), but never use this against the real API.
This project uses the arXiv API. Thank you to arXiv for use of its open access interoperability.
arXiv API Terms of Use: https://arxiv.org/help/api/tou
# Run unit tests
go test ./...
# Run integration tests (hits real arXiv API)
ARXIV_INTEGRATION_TESTS=1 go test ./...MIT License - see LICENSE for details.