# redivis

## *package* <mark style="color:purple;">Redivis</mark>

The redivis package, available via `library("redivis")`. Through its various methods, you can create, update, query, and read from resources on Redivis.

{% hint style="info" %}
To avoid conflicts with other packages and base R function names, redivis's top level functions are hosted in the **`redivis`** namespace, and accessible via the **`redivis$`** prefix. This means that code written for Redivis in Python, R, and Javascript is quite similar.

\
Previous versions of redivis-r recommended accessing top-level methods via the `redivis::` syntax (e.g., `redivis::user()`). This syntax is deprecated, and we recommend migrating existing code to use the `$` syntax.
{% endhint %}

## Methods

<table data-header-hidden><thead><tr><th width="441"></th><th></th></tr></thead><tbody><tr><td><a href="/pages/56xgPLdo8qhF4ouWhIic"><strong><code>redivis$connect_dbi</code></strong></a>()</td><td>Construct a globally scoped DBI connection across Redivis.</td></tr><tr><td><a href="/pages/gzRCK7YfzqZ6W5LMmKMg"><strong><code>redivis$current_notebook</code></strong></a>()</td><td>Construct a reference to the current notebook. Can only be called within a Redivis notebook.</td></tr><tr><td><a href="/pages/aYA3TPZIisvJWdpZrLXd"><strong><code>redivis$current_user</code></strong></a>()</td><td>Construct a reference to the currently authenticated user.</td></tr><tr><td><a href="/pages/Jipu0f3WVW0WHeyegm5H"><strong><code>redivis$current_workflow</code></strong></a>()</td><td>Construct a reference to the current workflow. Can only be called within a Redivis notebook, or if a <a href="/pages/-Ma_x8sDD20E-u1Y_WVz#environment-variables">default workflow is set</a>.</td></tr><tr><td><a href="/pages/V31tduTep3xkI9v9jlpe"><strong><code>redivis$datasource</code></strong></a>(source)</td><td>Construct a new <a href="/pages/GpxLdAJFeNjxm7XtMFBK">Datasource</a> instance. Can only be called if a <a href="/pages/-Ma_x8sDD20E-u1Y_WVz#environment-variables">default workflow is set</a>. Otherwise, use the <a href="/pages/NWW0qFiZzgt8vmG6mAVb">workflow$datasource()</a> constructor.</td></tr><tr><td><a href="/pages/RUZ19P1jqZNr6fi9fJjG"><strong><code>redivis$make_api_request</code></strong></a>([method, path, query, ...])</td><td>Call the Redivis API directly, for advanced use cases.</td></tr><tr><td><a href="/pages/YkDgYD2VzK84W0I6gdMU"><strong><code>redivis$notebook</code></strong></a>(name)</td><td>Construct a new <a href="/pages/DZE57YLu6XalrXHzTmtX">Notebook</a> instance.</td></tr><tr><td><a href="/pages/gKE8a3G4XmW8uIH3cJPv"><strong><code>redivis$parameter</code></strong></a>(name)</td><td>Construct a new <a href="/pages/F8vtOqtQL6tCTmWDojNZ">Parameter</a> instance.</td></tr><tr><td><a href="/pages/695rfhsyRy8RlOEwNd7y"><strong><code>redivis$organization</code></strong></a>(name)</td><td>Construct a new <a href="/pages/mcuSoRXD7Ekvk9BZPv54">Organization</a> instance.</td></tr><tr><td><a href="/pages/iLSdxO9DhduqHilqPWyw"><strong><code>redivis$query</code></strong></a>(query)</td><td>Execute a SQL query, returning a <a href="/pages/u7LD1MH34aU5vY61ZTcO">Query</a> instance.</td></tr><tr><td><a href="/pages/47nLIEzZXk9JRwnHBr1Q"><strong><code>redivis$table</code></strong></a>(name)</td><td>Construct a new <a href="/pages/XUXYajPrVdeZmo4teDlS">Table</a> instance. <br><br>This method can only be called if <a href="/pages/-MbEPjMatWDWThjAxSWK#environment-variables">default workflow / dataset is set</a>  (this is automatically set within a Redivis notebook to that notebook's workflow).</td></tr><tr><td><a href="/pages/QdElk7zksZY9lQS44m5l"><strong><code>redivis$transform</code></strong></a>(name)</td><td>Construct a new <a href="/pages/yoVAtCo4kIy4OFJMcXt2">Transform</a> instance.</td></tr><tr><td><a href="/pages/MtVBodeH2mxPjdBP3X2Y"><strong><code>redivis$user</code></strong></a>(name)</td><td>Construct a new <a href="/pages/8GyXE5t6IgFGA8xcCVfn">User</a> instance.</td></tr></tbody></table>

## Examples

```r
devtools::install_github("redivis/redivis-r")
library("redivis")

organization <- redivis$organization("Demo")
# organization$list_datasets(), organization$dataset("Iris species"), etc...

dataset <- organization$dataset("iris_species")
table <- dataset$table("iris")  
# table$to_tibble(), etc...
# In a notebook, can do redivis$table("_source_") to reference the source table

query <- redivis$query("
    SELECT * 
    FROM demo.iris_species.iris 
    WHERE SepalLengthCm > 5
")
# query$to_tibble(), etc...
```


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.redivis.com/api/client-libraries/redivis-r/reference/redivis.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
