# CRAN API
> The R package ecosystem — CRAN, the Comprehensive R Archive Network — as an API. Look up any R package for its title, description, version, license, maintainer and author, homepage and bug-tracker links, and its full dependency tree (depends, imports, suggests, linkingTo); read a package's complete release history with publication dates; search the entire CRAN registry by keyword; and get download statistics (last day, week or month, with an optional daily series) straight from the official CRAN download logs. Covers the ~22,000 packages on CRAN, from ggplot2, dplyr and data.table to jsonlite, shiny and the wider tidyverse. Live from the official R-community services (crandb, search.r-pkg.org, cranlogs). Ideal for package dashboards, dependency and supply-chain tooling, data-science developer portals and R ecosystem analytics. Open data from CRAN.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/cran-api/..."
```

## Pricing
- **Free** (Free) — 3,550 calls/Mo, 2 req/s
- **Starter** ($4/Mo) — 48,500 calls/Mo, 8 req/s
- **Pro** ($13/Mo) — 241,000 calls/Mo, 20 req/s
- **Mega** ($34/Mo) — 1,205,000 calls/Mo, 50 req/s

## Endpoints

### CRAN

#### `GET /v1/downloads` — Download statistics

**Parameters:**
- `name` (query, required, string) — R package name, e.g. ggplot2 Example: `ggplot2`
- `period` (query, optional, string) — last-day | last-week | last-month (default last-month)
- `daily` (query, optional, string) — true to include a daily series

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/cran-api/v1/downloads?name=ggplot2"
```

**Response:**
```json
{
    "data": {
        "end": "2026-05-29",
        "start": "2026-04-30",
        "period": "last-month",
        "package": "ggplot2",
        "downloads": 2227921
    },
    "meta": {
        "timestamp": "2026-05-31T12:34:39.015Z",
        "request_id": "46ea87c9-a533-4e0b-919d-77399b244d0a"
    },
    "status": "ok",
    "message": "Downloads retrieved",
    "success": true
}
```

#### `GET /v1/package` — Package metadata + dependencies + downloads

**Parameters:**
- `name` (query, required, string) — R package name (case-sensitive), e.g. ggplot2 Example: `ggplot2`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/cran-api/v1/package?name=ggplot2"
```

**Response:**
```json
{
    "data": {
        "package": {
            "url": "https://ggplot2.tidyverse.org, https://github.com/tidyverse/ggplot2",
            "name": "ggplot2",
            "title": "Create Elegant Data Visualisations Using the Grammar of Graphics",
            "author": "Hadley Wickham [aut] (ORCID: <https://orcid.org/0000-0003-4757-117X>), Winston Chang [aut] (ORCID: <https://orcid.org/0000-0002-1576-2126>), Lionel Henry [aut], Thomas Lin Pedersen [aut, cre] (ORCID: <https://orcid.org/0000-0002-5147-4711>), Kohske Takahashi [aut], Claus Wilke [aut] (ORCID: <https://orcid.org/0000-0002-7470-9261>), Kara Woo [aut] (ORCID: <https://orcid.org/0000-0002-5125-4188>), Hiroaki Yutani [aut] (ORCID: <https://orcid.org/0000-0002-3385-7233>), Dewey Dunnington [aut] (ORCID: <https://orcid.org/0000-0002-9415-4582>), Teun van den Brand [aut] (ORCID: <https://orcid.org/0000-0002-9335-7468>), Posit, PBC [cph, fnd] (ROR: <https://ror.org/03wc8by49>)",
            "depends": [
                {
                    "name": "R",
                    "constraint": ">= 4.1"
                }
            ],
            "imports": [
                {
                    "name": "cli",
                    "constraint": null
                },
                {
                    "name": "grDevices",
                    "constraint": null
                },
                {
                    "name": "grid",
                    "constraint": null
                },
                {
                  
…(truncated, see openapi.json for full schema)
```

#### `GET /v1/search` — Search the CRAN registry

**Parameters:**
- `q` (query, required, string) — Search term Example: `visualization`
- `limit` (query, optional, string) — Results (1-100, default 20)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/cran-api/v1/search?q=visualization"
```

**Response:**
```json
{
    "data": {
        "count": 20,
        "query": "visualization",
        "total": 2506,
        "results": [
            {
                "name": "visualize",
                "score": 9.917457,
                "title": "Graph Probability Distributions with User Supplied Parameters and Statistics",
                "version": "4.5.0",
                "cran_url": "https://cran.r-project.org/package=visualize"
            },
            {
                "name": "bpmnVisualizationR",
                "score": 8.463383,
                "title": "Visualize Process Execution Data on 'BPMN' Diagrams",
                "version": "0.5.0",
                "cran_url": "https://cran.r-project.org/package=bpmnVisualizationR"
            },
            {
                "name": "ggcorrplot",
                "score": 6.373395,
                "title": "Visualization of a Correlation Matrix using 'ggplot2'",
                "version": "0.1.4.1",
                "cran_url": "https://cran.r-project.org/package=ggcorrplot"
            },
            {
                "name": "TDbook",
                "score": 6.373395,
                "title": "Companion Package for the Book \"Data Integration, Manipulation and Visualization of Phylogenetic Trees\" by Guangchuang Yu (2022, ISBN:9781032233574)",
                "version": "0.0.6",
                "cran_url": "https://cran.r-project.org/package=TDbook"
            },
            {
                "name": "klaR",
                "score": 4.93
…(truncated, see openapi.json for full schema)
```

#### `GET /v1/versions` — Full release history

**Parameters:**
- `name` (query, required, string) — R package name, e.g. jsonlite Example: `jsonlite`
- `limit` (query, optional, string) — Max versions (1-500, default 50)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/cran-api/v1/versions?name=jsonlite"
```

**Response:**
```json
{
    "data": {
        "count": 46,
        "total": 46,
        "latest": "2.0.0",
        "package": "jsonlite",
        "versions": [
            {
                "date": "2025-03-27 06:40:02 UTC",
                "version": "2.0.0"
            },
            {
                "date": "2025-03-03 22:10:02 UTC",
                "version": "1.9.1"
            },
            {
                "date": "2025-02-19 15:50:06 UTC",
                "version": "1.9.0"
            },
            {
                "date": "2024-09-20 08:40:14 UTC",
                "version": "1.8.9"
            },
            {
                "date": "2023-12-04 15:20:02 UTC",
                "version": "1.8.8"
            },
            {
                "date": "2023-06-29 22:10:02 UTC",
                "version": "1.8.7"
            },
            {
                "date": "2023-06-05 12:20:02 UTC",
                "version": "1.8.5"
            },
            {
                "date": "2022-12-06 08:10:02 UTC",
                "version": "1.8.4"
            },
            {
                "date": "2022-10-21 08:15:07 UTC",
                "version": "1.8.3"
            },
            {
                "date": "2022-10-02 16:20:02 UTC",
                "version": "1.8.2"
            },
            {
                "date": "2022-10-01 14:00:02 UTC",
                "version": "1.8.1"
            },
            {
                "date": "2022-02-22 11:20:02 UTC",
                "version": "1.8.
…(truncated, see openapi.json for full schema)
```

### Meta

#### `GET /v1/meta` — Source & options

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/cran-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "note": "Live CRAN registry data. /v1/package = metadata (title, description, license, maintainer, dependencies, last-month downloads); /v1/versions = full release history with dates; /v1/search = search the registry; /v1/downloads = download counts (add daily=true for a daily series). Package names are case-sensitive (e.g. ggplot2, jsonlite, Matrix).",
        "source": "CRAN — the Comprehensive R Archive Network (the R package registry)",
        "endpoints": [
            "/v1/package",
            "/v1/versions",
            "/v1/search",
            "/v1/downloads",
            "/v1/meta"
        ],
        "upstreams": {
            "search": "search.r-pkg.org",
            "metadata": "crandb.r-pkg.org",
            "downloads": "cranlogs.r-pkg.org"
        },
        "download_periods": [
            "last-day",
            "last-week",
            "last-month"
        ]
    },
    "meta": {
        "timestamp": "2026-05-31T12:34:40.332Z",
        "request_id": "e88b3e5d-2f1a-4201-9b55-2389c1dc2db3"
    },
    "status": "ok",
    "message": "Meta retrieved",
    "success": true
}
```


---
Marketplace page: https://www.oanor.com/api/cran-api
OpenAPI spec: https://www.oanor.com/api/cran-api/openapi.json
