Referencing resources

Overview

In many parts of this API, we will be referencing tables on Redivis, as well as their related dataset or project. The API uses a consistent structure to uniquely identify tables, as specified below.
In the simplest case, tables are referenced by their name, alongside the name of the table's project or dataset, as well as the name the dataset or project owner.
Additionally, names may be escaped to handle whitespace and non-standard characters. You can also provide an optional reference id to ensure that your references don't break when a table, dataset, or project gets renamed.

General structure

All tables on Redivis belong to either a dataset or a project. All datasets belong to either a user or organization, and all projects belong to a user.
A table reference reflects this hierarchy, taking the following form:
1
ownerName.projectIdentifier|datasetIdentifier.tableIdentifer
Copied!
The ownerName will represent the user or organization that owns the dataset / project.
The projectIdentifier consists of the project name, followed by an optional referenceId prefaced by a colon. The name of the project may be escaped.
1
projectIdentifier = projectName[:projectReferenceId]
Copied!
The datasetIdentifier consists of the dataset name, followed by an optional referenceId prefaced by a colon. The name of the dataset may be escaped. Additionally, the dataset identifier may contain a sample flag :sample as well as a version identifier. The version identifier will identify a particular version of the dataset (of the form, v1_0, the current version current, or the next (unreleased) version next . If no version is specified the current version will be used by default.
1
datasetIdentifier = datasetName[:datasetReferenceId][:sample][:versionIdentifier]
2
3
versionIdentifier = v1_0|current|next
Copied!
Make sure to specify a versionIdentifier to avoid errors or inconsistent results when new versions get released, unless you explicitly want to always reference the latest version of the dataset.
The tableIdentifier consists of the table name, followed by an optional referenceId prefaced by a colon. The name of the table may be escaped.
1
tableIdentifier = tableName[:tableReferenceId]
Copied!

Escaping names

The user_name will never need to be escaped, as these names can only contain word characters ([A-Za-z0-9_]). These names are case-insensitive.
Dataset, project, and table names can contain a wide array of characters. To facilitate programmatic references, these names can be escaped with the following rules:
  1. 1.
    All non alpha-numeric and underscore characters in names and version tags are replaced by an underscore (_) character.
  2. 2.
    Multiple underscore characters are collapsed into one.
  3. 3.
    Leading and trailing underscores are removed.
  4. 4.
    All names are case-insensitive.
For example:
  • Census dataset: 1940-1980 -> census_dataset_1940_1980
  • ~~Leading and trailing characters. -> leading_and_trailing_characters
Uniqueness is enforced for all escaped names within the relevant scope. For example, all tables in a project and all datasets in an organization will have a unique escaped name.
If a name contains colons (:), periods (.), or backticks (`), they must be escaped.

Reference Ids

While it is obviously convenient to reference tables, datasets, and projects by their name, this presents a challenge if these resources get renamed over time. In order to avoid code breakage due to renames, each resource has a 4-character (lowercase, alphanumeric) referenceId associated with it. This identifier will always be unique to the relevant scope — that is, a table's referenceId is unique across all tables in its dataset / project, and the referenceId of a dataset or project is unique to all datasets and projects for that user.
If you're writing code within Redivis (table queries, transforms, notebooks), the referenceId will generally be pre-populated for you. This section is generally only applicable if you're using the Redivis API from an external environment (e.g., a Jupyter notebook running on your computer).
For tables that belong to a dataset, the referenceId will be consistent across all versions of the dataset, as well as for sample tables. This allows for you to easily change the version / sampling without needing to update any reference ids.

Locating the reference id

In the URL bar

One of the easiest ways to find the referenceId is to look at your URL bar. For example, if we navigate to the daily observations table in the GHCN dataset, our URL will be: https://redivis.com/datasets/7br5-41440fjzk/tables/6fff-2djw7v7mw. Here you can see that the dataset's full identifier is 7br5-41440fjzk. The referenceId is the first part of this identifier: 7br5. Similarly, the referenceId for the table is 6fff.

In the table export modal

You can also find this information by navigating to the export modal for a table, and clicking on the tab for programmatic export information. Make sure the "exact references" box is checked, and you'll see the referenceId included in the template.
Use the export interface to view referenceIds and example code

On the dataset page

You can also find dataset-specific information by clicking on API Information link on the dataset overview page:

Via the API

Finally, the referenceId is returned as a property on dataset and table resource via the API. Table's also have a qualifiedReference property, which represents the full reference to the table (owner.dataset|project.table), including all reference ids and version specifiers.

Examples

We can reference the "Daily observations" table from the GHCN Climatology dataset as:
SQL
Python
R
JS
HTTP
1
SELECT * FROM
2
`demo.ghcn_daily_weather_data.daily_observations`
3
LIMIT 100
Copied!
1
import redivis
2
3
user = redivis.user("demo")
4
dataset = user.dataset("ghcn_daily_weather_data")
5
table = dataset.table("daily_observations")
6
7
df = table.to_dataframe(max_results=100)
Copied!
1
library(redivis)
2
3
user <- redivis::user("demo")
4
dataset <- user$dataset("ghcn_daily_weather_data")
5
table <- dataset$table("daily_observations")
6
7
data <- table$to_tibble(max_results=100)
Copied!
1
import * as redivis from 'redivis'
2
3
const table = redivis.user('demo')
4
.dataset('ghcn_daily_weather_data')
5
.table('daily_observations')
6
7
const rows = table.list_rows({ maxResults: 100} )
Copied!
1
https://redivis.com/api/v1
2
/tables/demo.ghcn_daily_weather_data.daily_observations
Copied!
By default this uses the latest version of the dataset. If we want to work with version 1.0:
SQL
Python
R
JS
HTTP
1
SELECT * FROM
2
`demo.ghcn_daily_weather_data:v1_0.daily_observations`
3
LIMIT 100
Copied!
1
import redivis
2
3
user = redivis.user("demo")
4
dataset = user.dataset("ghcn_daily_weather_data", version="1.0")
5
# Alternatively, dataset = user.dataset("ghcn_daily_weather_data:v1_0")
6
table = dataset.table("daily_observations")
7
8
df = table.to_dataframe(max_results=100)
Copied!
1
library(redivis)
2
3
user <- redivis::user("demo")
4
dataset <- user$dataset("ghcn_daily_weather_data", version="1.0")
5
# Alternatively, dataset <- user$dataset("ghcn_daily_weather_data:v1_0")
6
table <- dataset$table("daily_observations")
7
8
data <- table$to_tibble(max_results=100)
Copied!
1
import * as redivis from 'redivis'
2
3
const table = redivis.user('demo')
4
.dataset('ghcn_daily_weather_data', { version: '1.0' })
5
// Alternatively, dataset("ghcn_daily_weather_data:v1_0")
6
.table('daily_observations')
7
8
const rows = table.list_rows({ maxResults: 100} )
Copied!
1
https://redivis.com/api/v1
2
/tables/demo.ghcn_daily_weather_data:v1_0.daily_observations
Copied!
If we want to work with the 1% sample:
SQL
Python
R
JS
HTTP
1
SELECT * FROM
2
`demo.ghcn_daily_weather_data:sample.daily_observations`
3
LIMIT 100
Copied!
1
import redivis
2
3
user = redivis.user("demo")
4
dataset = user.dataset("ghcn_daily_weather_data", sample=True)
5
# Alternatively, dataset = user.dataset("ghcn_daily_weather_data:sample")
6
table = dataset.table("daily_observations")
7
8
df = table.to_dataframe(max_results=100)
Copied!
1
library(redivis)
2
3
user <- redivis::user("demo")
4
dataset <- user$dataset("ghcn_daily_weather_data", sample=TRUE)
5
# Alternatively, dataset <- user$dataset("ghcn_daily_weather_data:sample")
6
table <- dataset$table("daily_observations")
7
8
data <- table$to_tibble(max_results=100)
Copied!
1
import * as redivis from 'redivis'
2
3
const table = redivis.user('demo')
4
.dataset('ghcn_daily_weather_data', { sample: true })
5
// Alternatively, dataset("ghcn_daily_weather_data:sample")
6
.table('daily_observations')
7
8
const rows = table.list_rows({ maxResults: 100} )
Copied!
1
https://redivis.com/api/v1
2
/tables/demo.ghcn_daily_weather_data:sample.daily_observations
Copied!
Finally, we can provide referenceIds to prevent things from breaking if a dataset or table is renamed. Make sure also to specify a specific dataset version to avoid changes when a new version is released:
SQL
Python
R
JS
HTTP
1
SELECT * FROM
2
`demo.ghcn_daily_weather_data:7br5:v1_1:.daily_observations:6fff`
3
LIMIT 100
Copied!
1
import redivis
2
3
user = redivis.user("demo")
4
dataset = user.dataset("ghcn_daily_weather_data:7br5:v1_1")
5
table = dataset.table("daily_observations:6fff")
6
7
df = table.to_dataframe(max_results=100)
Copied!
1
library(redivis)
2
3
user <- redivis::user("demo")
4
dataset <- user$dataset("ghcn_daily_weather_data:7br5:v1_1")
5
table <- dataset$table("daily_observations:6fff")
6
7
data <- table$to_tibble(max_results=100)
Copied!
1
import * as redivis from 'redivis'
2
3
const table = redivis.user('demo')
4
.dataset('ghcn_daily_weather_data:7br5:v1_1')
5
.table('daily_observations:6fff')
6
7
const rows = table.list_rows({ maxResults: 100} )
Copied!
1
https://redivis.com/api/v1
2
/tables/demo.ghcn_daily_weather_data:7br5:v1_1:.daily_observations:6fff
Copied!
Referencing tables in a project is quite similar, though projects don’t have versions or samples:
SQL
Python
R
JS
HTTP
1
SELECT * FROM
2
imathews.demo_project:t066.annual_precipitation:vdwn
3
LIMIT 100
Copied!
1
import redivis
2
3
user = redivis.user("imathews")
4
project = user.project("demo_project:t066")
5
table = project.table("annual_precipitation:vdwn")
6
7
df = table.to_dataframe(max_results=100)
Copied!
1
library(redivis)
2
3
user <- redivis::user("imathews")
4
project <- user$project("demo_project:t066")
5
table <- project$table("annual_precipitation:vdwn")
6
7
data <- table$to_tibble(max_results=100)
Copied!
1
import * as redivis from 'redivis'
2
3
const table = redivis.user('imathews')
4
.dataset('demo_project:t066')
5
.table('annual_precipitation:vdwn')
6
7
const rows = table.list_rows({ maxResults: 100} )
Copied!
1
https://redivis.com/api/v1
2
/tables/imathews.demo_project:t066.annual_precipitation:vdwn
Copied!