DataPress logo
API Reference

Creating Datasets

Version:  4.0
Updated:  14th July 2024

Overview

Post a partial dataset JSON to create a new dataset.

  • The following fields are required:
    • title
    • masthead, the ID of one of the existing mastheads, from the site JSON.
    • team, the ID of one of the existing teams, from the teams JSON.
  • All other fields are optional.
    • id is automatically assigned.
    • sharing defaults to public.
Note
You cannot upload files while creating the dataset.
First, the dataset must be assigned an ID. Then you can use the upload files API.
POST
https://data.website/api/dataset
HTTP Headers
AuthorizationAPI key.stringRequired
Content-TypeMust be "application/json". Most clients will set this automatically.stringRequired
HTTP Return Codes
200Returns the full dataset JSON.
400Returns a JSON object explaining the error.
403API key does not have editor permissions.

Example: Minimal dataset

import requests, os, json

api_key = os.getenv("DATAPRESS_API_KEY")

headers = { "Authorization": api_key }
dataset = {
    "title": "My new dataset",
    "masthead": "the-masthead-slug", # from /api/site
    "team": "tm123"  # from /api/teams
}

url = f"https://data.website/api/dataset"

response = requests.post(url, json=dataset, headers=headers)
print(json.dumps(response.json(), indent=2))