> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omophub.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OMOPHub R SDK - installation and quickstart

> Get started with the OMOPHub R SDK - install, authenticate, and run your first concept search, mapping, and FHIR resolve for OHDSI analytics in minutes.

## Prerequisites

* R 4.1+
* [OMOPHub API key](https://dashboard.omophub.com/api-keys)

## Installation

<CodeGroup>
  ```r CRAN theme={null}
  # Install from CRAN (recommended)
  install.packages("omophub")
  ```

  ```r GitHub theme={null}
  # Install from GitHub 
  devtools::install_github("omophub/omophub-R")
  ```
</CodeGroup>

## Quick Start

```r theme={null}
library(omophub)

client <- OMOPHubClient$new(api_key = "oh_xxxxxxxxx")

# Get a concept
concept <- client$concepts$get(201826)
print(concept$concept_name)  # "Type 2 diabetes mellitus"

# Search concepts
results <- client$search$basic("diabetes", page_size = 5)
for (concept in results$data) {
  cat(sprintf("%s: %s\n", concept$concept_id, concept$concept_name))
}
```

## Configuration

```r theme={null}
client <- OMOPHubClient$new(
  api_key = "oh_xxx",
  timeout = 30,
  max_retries = 3,
  vocab_version = "2025.1"
)
```

You can also set your API key via environment variable:

```bash theme={null}
export OMOPHUB_API_KEY=oh_xxxxxxxxx
```

```r theme={null}
# API key is read from environment
client <- OMOPHubClient$new()
```

## Features

* **R6 Class Design** - Familiar object-oriented interface for R users
* **Automatic Rate Limiting** - Built-in request throttling to respect API limits
* **Automatic Retries** - Transient errors are automatically retried with exponential backoff
* **Pagination Helpers** - Easy iteration through large result sets
* **Tibble Integration** - Results can be converted to tibbles for tidyverse workflows

## Next Steps

<CardGroup cols={2}>
  <Card title="Concepts" icon="lightbulb" href="/sdks/r/concepts">
    Get, batch, and explore concepts
  </Card>

  <Card title="Search" icon="magnifying-glass" href="/sdks/r/search">
    Search and autocomplete
  </Card>

  <Card title="Mappings" icon="diagram-project" href="/sdks/r/mappings">
    Map between vocabularies
  </Card>

  <Card title="Error Handling" icon="shield-exclamation" href="/sdks/r/error-handling">
    Handle API errors gracefully
  </Card>
</CardGroup>
