Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/main/datasets-server_doc/en/quick_start.ipynb
Views: 2542
Quickstart
In this quickstart, you'll learn how to use the Datasets Server's REST API to:
Check whether a dataset on the Hub is functional.
Return the configuration and splits of a dataset.
Preview the first 100 rows of a dataset.
Download slices of rows of a dataset.
Search a word in a dataset.
Filter rows based on a query string.
Access the dataset as parquet files.
Get the dataset size (in number of rows or bytes).
Get statistics about the dataset.
API endpoints
Each feature is served through an endpoint summarized in the table below:
Endpoint | Method | Description | Query parameters |
---|---|---|---|
/is-valid | GET | Check whether a specific dataset is valid. | dataset : name of the dataset |
/splits | GET | Get the list of configurations and splits of a dataset. | dataset : name of the dataset |
/first-rows | GET | Get the first rows of a dataset split. | - dataset : name of the dataset- config : name of the config- split : name of the split |
/rows | GET | Get a slice of rows of a dataset split. | - dataset : name of the dataset- config : name of the config- split : name of the split- offset : offset of the slice- length : length of the slice (maximum 100) |
/search | GET | Search text in a dataset split. | - dataset : name of the dataset- config : name of the config- split : name of the split- query : text to search for |
/filter | GET | Filter rows in a dataset split. | - dataset : name of the dataset- config : name of the config- split : name of the split- where : filter query- offset : offset of the slice- length : length of the slice (maximum 100) |
/parquet | GET | Get the list of parquet files of a dataset. | dataset : name of the dataset |
/size | GET | Get the size of a dataset. | dataset : name of the dataset |
/statistics | GET | Get statistics about a dataset split. | - dataset : name of the dataset- config : name of the config- split : name of the split |
There is no installation or setup required to use Datasets Server.
Feel free to try out the API in Postman, ReDoc or RapidAPI. This quickstart will show you how to query the endpoints programmatically.
The base URL of the REST API is:
Gated datasets
For gated datasets, you'll need to provide your user token in headers
of your query. Otherwise, you'll get an error message to retry with authentication.
You'll see the following error if you're trying to access a gated dataset without providing your user token:
Check dataset validity
To check whether a specific dataset is valid, for example, Rotten Tomatoes, use the /is-valid
endpoint:
This returns whether the dataset provides a preview (see /first-rows), the viewer (see /rows), the search (see /search) and the filter (see /filter):
List configurations and splits
The /splits
endpoint returns a JSON list of the splits in a dataset:
This returns the available configuration and splits in the dataset:
Preview a dataset
The /first-rows
endpoint returns a JSON list of the first 100 rows of a dataset. It also returns the types of data features ("columns" data types). You should specify the dataset name, configuration name (you can find out the configuration name from the /splits
endpoint), and split name of the dataset you'd like to preview:
This returns the first 100 rows of the dataset:
Download slices of a dataset
The /rows
endpoint returns a JSON list of a slice of rows of a dataset at any given location (offset). It also returns the types of data features ("columns" data types). You should specify the dataset name, configuration name (you can find out the configuration name from the /splits
endpoint), the split name and the offset and length of the slice you'd like to download:
You can download slices of 100 rows maximum at a time.
The response looks like:
Search text in a dataset
The /search
endpoint returns a JSON list of a slice of rows of a dataset that match a text query. The text is searched in the columns of type string
, even if the values are nested in a dictionary. It also returns the types of data features ("columns" data types). The response format is the same as the /rows endpoint. You should specify the dataset name, configuration name (you can find out the configuration name from the /splits
endpoint), the split name and the search query you'd like to find in the text columns:
You can get slices of 100 rows maximum at a time, and you can ask for other slices using the offset
and length
parameters, as for the /rows
endpoint.
The response looks like:
Access Parquet files
Datasets Server converts every dataset on the Hub to the Parquet format. The /parquet
endpoint returns a JSON list of the Parquet URLs for a dataset:
This returns a URL to the Parquet file for each split:
Get the size of the dataset
The /size
endpoint returns a JSON with the size (number of rows and size in bytes) of the dataset, and for every configuration and split:
This returns the size of the dataset, and for every configuration and split: