> For the complete documentation index, see [llms.txt](https://docs.redivis.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.redivis.com/api/client-libraries/redivis-r/getting-started.md).

# Getting started

## Installation

The easiest way to get started with the redivis-r library is via a [Redivis notebook](/reference/workflows/notebooks/r-notebooks.md), which comes with the latest version of this library pre-installed. Additionally, authentication is automatically handled within the Redivis notebook environment.

You can also install the latest release of this package in any other R environment from [R-universe](https://redivis.r-universe.dev/):

```r
install.packages("redivis", repos = c(
    "https://redivis.r-universe.dev", 
    "https://cloud.r-project.org"
))
```

If on Linux, we recommended using `pak` to install prebuilt binaries from Posit Package Manager (PPM) and avoid long compilation times:

```r
install.packages("pak")
pak::repo_add(CRAN = "PPM@latest", redivis = "https://redivis.r-universe.dev")
pak::pkg_install("redivis")
```

Or, to install the development version directly [from Github](https://github.com/redivis/redivis-r):

```r
devtools::install_github("redivis/redivis-r", ref="main")
```

Additionally, if you are working with geospatial data and want to use the [to\_sf\_tibble()](/api/client-libraries/redivis-r/reference/table/tableusdto_sf_tibble.md) methods, you'll need to make sure that you have the `sf`  package installed ([instructions](https://r-spatial.github.io/sf/#installing)).&#x20;

## Example usage

```r
library("redivis") 

organization <- redivis$organization("demo")
dataset <- organization$dataset("cms_2014_medicare_data")
table <- dataset$table("home_health_agencies")

df <- table$to_tibble()
```

When referencing datasets, workflows, and tables on Redivis, you should be familiar with the [resource reference syntax](https://apidocs.redivis.com/referencing-resources).

## Authentication

### Within a Redivis notebook (automatic)

If you are using the redivis-r library within a notebook on Redivis, you'll automatically be authenticated and have access to any data within your workflow.

### From another environment (OAuth)

If you are running the redivis-r library on another system (e.g., your laptop, Google Colab, or a shared compute cluster), you will be prompted to authenticate with your Redivis account the first time you run a command. Follow the printed instructions to authorize the R client to communicate with the Redivis API.

### From a long-running service (API Token)

If you are developing a service that regularly interacts with Redivis without human intervention – for example, a recurring job that runs a data ingest pipeline – you can [generate an API token](/api/rest-api/authorization.md#api-token) to allow the service to act on your behalf.

{% hint style="danger" %}
API Tokens must be treated with extreme care, as a leaked token can allow somebody else to act on your behalf. These tokens should be treated like passwords, and never committed to source control or stored as strings in the text of your code.

API Tokens are only required for long-running services that operate without a human actor. If you are engaging with the Redivis API interactively, you should instead use the simpler and more secure OAuth flow mentioned above.
{% endhint %}

This API token must then be set as the `REDIVIS_API_TOKEN` [environment variable](/api/client-libraries/redivis-python/reference.md#environment-variables) before running your R script. You can set the variable for your current session by running the following in your terminal:

```bash
export REDIVIS_API_TOKEN=YOUR_TOKEN
```

## Learn more

{% content-ref url="/pages/-MbEPjMatWDWThjAxSWK" %}
[Reference](/api/client-libraries/redivis-r/reference.md)
{% endcontent-ref %}

{% content-ref url="/pages/-MbEPiqpS6e-u8akx0vL" %}
[Examples](/api/client-libraries/redivis-r/examples.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.redivis.com/api/client-libraries/redivis-r/getting-started.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
