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:
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.
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.
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.
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:
All non alpha-numeric and underscore characters in names and version tags are replaced by an underscore (
_
) character.Multiple underscore characters are collapsed into one.
Leading and trailing underscores are removed.
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 / sample 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.
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:
By default this uses the latest version of the dataset. If we want to work with version 1.0:
If we want to work with the 1% sample:
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:
Referencing tables in a project is quite similar, though projects don’t have versions or samples:
Last updated