Data Functions

Using the Studio Data SDK, you can manage your dataset records with several data endpoints.


Create Dataset

Create a dataset from a file upload.

data_sdk.upload_file(
    file='new_file.csv',
    name='Dataset name',
    media_type=MediaType.CSV,
    description='Dataset description')
uf-data-sdk upload-file \
  --name "Dataset name" \
  --desc "Dataset description" \
  --media-type text/csv \
  new_file.csv
curl -X POST https://data-api.foursquare.com/v1/datasets/data?name=My+Dataset \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: text/csv' \
--data-binary '@/path/to/my_dataset.csv'

You can use the Python SDK package to upload a Pandas or GeoPandas dataframe.

data_sdk.upload_dataframe(
    dataframe,
    name='Dataset name',
    description='Dataset description')

upload_file reference


Get Dataset Metadata

Get a dataset record. This dataset record only includes the dataset's metadata—not the data itself. Pass the UUID or dataset object to get to receive the dataset's record as a JSON object.

# Get dataset metadata by UUID
data_sdk.get_dataset_by_id("<uuid>")

# Get dataset record by dataset object
## List datasets
datasets = data_sdk.list_datasets()
dataset = datasets[0]
## Get dataset record by dataset object
data_sdk.get_dataset_by_id(dataset)
curl -X GET https://data-api.foursquare.com/v1/maps/<uuid> \
  -H 'Authorization: Bearer <token>'
curl -X GET https://data-api.foursquare.com/v1/maps/<uuid> \
  -H 'Authorization: Bearer <token>'

get_dataset_by_id reference


Download Dataset

Download data for a given dataset. Pass the UUID or dataset object to get to receive the dataset. Provide output_file to write the dataset data to, or leave empty to return a bytes object with the dataset data.

# Download dataset record by dataset object
## List datasets
datasets = data_sdk.list_datasets()
dataset = datasets[0]

# Download to local file
data_sdk.download_dataset(dataset, output_file='output.csv')
# Download to buffer
buffer = data_sdk.download_dataset(dataset)
uf-data-sdk download-dataset --dataset-id <uuid> --output-file output.csv
curl -X GET https://data-api.foursquare.com/v1/datasets/<uuid> \
  -H 'Authorization: Bearer <token>'

You can use the Python SDK package to download the data as a Pandas or GeoPandas dataframe.

If the original dataset was a CSV file, a pandas DataFrame will be returned. If it was a GeoJSON file, a geopandas GeoDataFrame will be returned.

# Download dataset record by dataset object
datasets = data_sdk.list_datasets()
dataset = datasets[0]

# Download to a dataframe
df = data_sdk.download_dataframe(dataset)

download_dataset reference


Update Dataset

Update an existing dataset with a binary data upload. Pass the UUID or dataset object of the dataset to update.

View map configuration specifications in the map and layer format documentation

# Select a dataset to update
dataset = datasets[0]

# Update the dataset using file upload
data_sdk.upload_file(
    file='new_file.csv',
    dataset=dataset,
    media_type=MediaType.CSV)
uf-data-sdk update-dataset --dataset-id --media-type <media_type> <path>
PUT https://data-api.foursquare.com/v1/datasets/{id}/data HTTP/1.1

You can use the Python SDK package to update the data with a Pandas or GeoPandas dataframe.

# Update the dataset with dataframe
data_sdk.upload_dataframe(
    dataframe,
    dataset=dataset,
    name='Dataset name',
    description='Dataset description')

upload_dataset reference


Delete Dataset

Delete a dataset record. Pass the UUID of the dataset to delete the dataset record. This will delete all data associated with the dataset.

❗️

Warning!

This operation cannot be undone. If you delete a dataset that appears in maps, the dataset will be removed from the map. This may cause the map to render incorrectly.

# Delete dataset by dataset object

## Select dataset
datasets = data_sdk.list_datasets()
dataset = datasets[0]
## Delete selected Dataset
data_sdk.delete_dataset(dataset)

# Delete dataset by UUID
data_sdk.delete_dataset("<UUID>")
uf-data-sdk delete-dataset --dataset-id <uuid>
DELETE https://data-api.foursquare.com/v1/datasets/<uuid> HTTP/1.1

delete_dataset reference


List Datasets

List all dataset records on the authorized account.

datasets = data_sdk.list_datasets()
uf-data-sdk list-datasets
GET https://data-api.foursquare.com/v1/datasets HTTP/1.1

If you are part of an organization, you can pass the organization parameter to get all dataset records for the organization of the authorized account.

datasets = data_sdk.list_datasets(organization=True)
uf-data-sdk list-datasets --organization
GET https://data-api.foursquare.com/v1/datasets/for-organization HTTP/1.1

This function returns a list of dataset objects. You can use these dataset objects in other functions.

list_datasets reference


Sign In