API

Resources

API Documentation

The Statwing API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and to use HTTP response codes to indicate API errors. JSON will be returned in all responses from the API, including errors.

API Endpoint (note that the 'www' is required!)

https://www.statwing.com/

Summary of Resource URL Patterns
  • /api/p0/datasets
  • /api/p0/datasets/{DATASET_ID}
  • /api/p0/datasets/{DATASET_ID}/users
  • /api/p0/users
  • /api/p0/users/{USER_ID}
  • /api/p0/users/{USER_ID}/datasets

Authentication

You authenticate to the Statwing API by providing one of your secret API keys in the request. You can manage your API keys from your Statwing Integration account.

Authentication to the API occurs via HTTP Basic Auth. Provide your API key as the basic auth username. You do not need to provide a password. All API requests must be made over HTTPS; calls made over plain HTTP will fail. You must authenticate for all requests.

In the following curl examples, curl uses the -u flag to pass basic auth credentials. Add a colon after your API key to prevent it from asking you for a password.

curl -i -XGET https://www.statwing.com/api/p0/datasets \
  -u M2sFjReGPFVrFdr8hwo6n0Tsm9aUZReG:

Versioning

Whenever we make backwards-incompatible changes to the Statwing API, we release new dated version of it. The current version is 2013-09-20.

Errors

Statwing responses to the API requests by the conventional HTTP response codes indicating the success or failure. In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error that resulted from the provided information (e.g. a required parameter was missing, or the provided id didn't match any object), and codes in the 5xx range indicate an error with our servers. There are some exceptions in the response codes and, not all the errors map cleanly to them.

HTTP Status Code Summary
  • 200 OK - Everything worked as expected.
  • 400 Bad Request - Often missing a required parameter.
  • 401 Unauthorized - No valid API key provided.
  • 402 Request Failed - Parameters were valid but request failed.
  • 404 Not Found - The requested item doesn't exist.
  • 500, 502, 503, 504 Server errors - something went wrong on our end.

Datasets

The datasets are the basic objects to define the data you analyze with Statwing. The API allows you to create new datasets as well as update and retrieve information of existing ones.

For every unique dataset you want to analyze with Statwing, you create a new dataset object. You can restrict the access to your datasets, either by allowing access for only specific users, who are linked to the datasets, or providing a private link for users without an account. When sharing the dataset through a link, the shared attribute of the dataset must be set to "link". Dataset object contains information including the id, name, creation time and filesize of the uploaded dataset.

At the moment we accept datasets in comma-separated value (.csv), Triple-S, xlsx and xls formats through our API.

https://www.statwing.com/api/p0/datasets/

Dataset object

Attributes
id:
string

Random string with "dat_" prefix. Generated automatically by Statwing, when the dataset object is created.

name:
string

Arbitrary name for the dataset. Can be changed by update method.

filesize:
integer

The size of the dataset file, in bytes.

state:
string {"queued" | "processing" | "failed" | "processed"}
  • Queued: the dataset is in the queue waiting to be processed by our system.
  • Processing: the processing of the dataset is in progress.
  • Failed: the processing of the dataset failed.
  • Processed: the processing of the dataset finished successfully.
shared:
string {"restricted" | "link"}
  • Restricted: the dataset can only be accessed by you and the users defined in the dataset[users].
  • Link: the dataset can be accessed, without authentication, through the private link provided by you.
created_at:
string (ISO 8601 datetime)
subdomain:
string

The subdomain of your api integration.

fileurl:
string

A url from where the dataset will be downloaded to our system.

Fileurl in the curl request needs to be url encoded. See for example the curl request in the creating a dataset section, where the ampersand ('&') is replaced with '%26'.

url_base:
string

A url pointing to the dataset in our system.

url_readonly:
string

If available, a url that provides read-only access to the dataset.

users:
A list of User objects

When the shared attribute of the dataset is set to restricted, these users have access to the dataset.

{
  "id": "dat_kuPrFoYkh9y4DuBcR8mFlb4A1AAChAos",
  "name": "ClevelandWard1.csv",
  "filesize": 927177,
  "state": "processed",
  "shared": "restricted",
  "created_at": "2013-09-16T23:46:38Z",
  "subdomain": "test",
  "url_base": "https://test.statwing.com/p0/datasets/dat_kuPrFoYkh9y4DuBcR8mFlb4A1AAChAos",
  "users": [
    {
      "id": "usr_BeUNgZDkuYIzta2gI8PqPABOap0CYpkF",
      "partner_user_id": null,
      "url": "https://test.statwing.com/p0/datasets/dat_w4xsNWqEY60LhNfBXdQ7YQiYqRySZlHX/users/usr_BeUNgZDkuYIzta2gI8PqPABOap0CYpkF"
    }
  ]
}

Creating a Dataset

Create a new dataset object. At the moment we accept datasets in comma-separated value (.csv), Triple-S, xlsx and xls formats through our API.

Statwing tries to infer the proper parser type from the dataset file's mimetype and name, but to ensure the correct parser is used, the parse settings should be defined.

For both csv and tsv files, the dataset[parse_settings][parser] should be set to "csv". For tsv files, additional dataset[parse_settings][delimiter] should be set to "\t".

For Excel files, the dataset[parse_settings][parser] should be set according to the specific Excel file format, either "xlsx" or "xls".

Triple-S datasets have to be in a .zip file, containing the meta file in .xml or .sss file, and the actual data file in .csv or .asc file. When creating a dataset in Triple-S format, the dataset[parse_settings][parser] has to be "sss".

Arguments
dataset[fileurl]:
url string, required

Url from where the dataset will be downloaded to our servers.

The fileurl in the curl request needs to be url encoded.

For example:

https://gist.github.com/slermukka/6983882/raw/6c63ad1196e60ae485954a123026c4aac08d6a0b/congressional_data.csv?example=amper%26example2=sand

or https://gist.github.com/sandbox/6983768/raw/81e00eff263d6ac9fdedbe28de7d33dc8e850f2f/statwing.csv?param1=test1%26param2=test2

Contact us if there is a specific authentication protocol we need to implement.

For applications which provide a developer user id and secret api key, we currently can authentication with a scheme similar to AWS S3, involving the RFC 2104HMAC-SHA1 Signature of selected elements from the request (specifically the HTTP-Verb, Content-MD5, Content-Type, '', and dataset[fileurl]). We authenticate the request by adding an HTTP hmac header with user_id:Signature.

dataset[name]:
string, required

An arbitrary string naming the dataset.

dataset[share_readonly]:
boolean, optional
  • When true, allow sharing of the dataset with a readonly link, accessible at the dataset's url_readonly attribute
dataset[shared]:
string, optional, default 'restricted'

Either 'restricted' or 'link'

  • Restricted: the dataset can only be accessed by you and the users defined in the dataset[users].
  • Link: the dataset can be accessed through a secret link, without user login required.
dataset[parse_settings][parser]
string, optional

Defines the parser used to parse the dataset. Statwing tries to infer the proper parser type from the file's mimetype and name, but to ensure the correct parser is used, the parse settings should be defined.

  • csv For csv and tsv files. Additional dataset[parse_settings][delimiter] required for tsv files.
  • sss For Triple-S files. No dataset[parse_settings][delimiter] required.
  • xlsx For xlsx files. No dataset[parse_settings][delimiter] required.
  • xls For xls files. No dataset[parse_settings][delimiter] required.
dataset[header][parameter_name]
string, optional

Adds 'parameter_name', e.g. 'authCode', 'oneTimeToken', etc, to the header when Statwing makes the download request to fileurl.

Useful in cases where the fileurl needs a one time use token in the request header on download.

dataset[users][action]:
string, optional

Either "set" or empty

Set users to this dataset, giving them right to access it.

dataset[users][data][][object]:
string, required if dataset[users][action] given

Either "user_id" or "partner_user_id"

Whether to set user according to the unique Statwing id, or the unique id in your system.

  • user_id: The action is performed to the user with the matching Statwing id.
  • partner_user_id: The action is performed to the user with the matching partner user id.
dataset[users][data][][data]:
string, required if dataset[users][action] given

Either user's Statwing id or Partner id, depending of the previous parameter

  • If the previous parameter is "user_id", this should be a string with "usr_" prefix.
  • If the previous parameter is "partner_user_id", this should refer to the user created with your system's unique identifier.
Returns

Return a dataset if the creation was successful. If some of the required fields are not provided and/or the creation fails, returns an error.

POST https://www.statwing.com/api/p0/datasets
curl -i -XPOST https://www.statwing.com/api/p0/datasets \
  -u M2sFjReGPFVrFdr8hwo6n0Tsm9aUZReG: \
  -d dataset[fileurl]="https://gist.github.com/sandbox/6983768/raw/81e00eff263d6ac9fdedbe28de7d33dc8e850f2f/statwing.csv?example_param=test%26other_param=example" \
  -d dataset[name]="statwing.csv"  \
  -d dataset[shared]="restricted" \
  -d dataset[users][action]="add" \
  -d dataset[users][data][][object]="user_id" \
  -d dataset[users][data][][data]="usr_MGI122OQWdMslSSKEi7ZoPaf2nY8ucKH"
curl -i -XPOST https://www.statwing.com/api/p0/datasets \
  -u M2sFjReGPFVrFdr8hwo6n0Tsm9aUZReG: \
  -d dataset[fileurl]="https://gist.github.com/sandbox/6983768/raw/81e00eff263d6ac9fdedbe28de7d33dc8e850f2f/sss.zip" \
  -d dataset[name]="Triple-S example"  \
  -d dataset[shared]="restricted" \
  -d dataset[parse_settings][parser]="sss" \
{
  "id": "dat_yCi8J3vwmhYlNWAnBlbLmejlAkM9bJcM",
  "name": "statwing.csv",
  "filesize": null,
  "state": "queued",
  "shared": "restricted",
  "created_at": "2013-10-18T01:15:27Z",
  "subdomain": "test",
  "fileurl": "https://gist.github.com/sandbox/6983768/raw/81e00eff263d6ac9fdedbe28de7d33dc8e850f2f/statwing.csv?example_param=test&other_param=example",
  "url_base": "https://test.statwing.com/p0/datasets/dat_yCi8J3vwmhYlNWAnBlbLmejlAkM9bJcM",
  "users": [
    {
      "id": "usr_MGI122OQWdMslSSKEi7ZoPaf2nY8ucKH",
      "partner_user_id": null,
      "url": "https://test.statwing.com/p0/datasets/dat_yCi8J3vwmhYlNWAnBlbLmejlAkM9bJcM/users/usr_MGI122OQWdMslSSKEi7ZoPaf2nY8ucKH"
    }
  ]
}

Listing the datasets

Returns a list containing dataset objects linked to the integration. You can adjust the amount and offset of the returned datasets by providing the parameters.

Arguments
offset:
integer, optional

default 0

limit:
integer, optional

default 0

Returns

Return an array, containing up to the limit amount of datasets, beginning from the offset provided. If there are no datasets starting from the offset, the method returns empty array.

GET https://www.statwing.com/api/p0/datasets
curl -i -XGET https://www.statwing.com/api/p0/datasets \
  -u M2sFjReGPFVrFdr8hwo6n0Tsm9aUZReG:
datasets: [
  {
    id: "dat_kuPrFoYkh9y4DuBcR8mFlb4A1AAChAos",
    name: "titanic.csv",
    filesize: 927177,
    state: "processed",
    shared: "restricted",
    created_at: "2013-09-16T23:46:38Z",
    subdomain: "test",
    url_base: "https://www.statwing.com/p0/datasets/dat_kuPrFoYkh9y4DuBcR8mFlb4A1AAChAos",
    users: [
    ]
  },
  {
    id: "dat_w4xsNWqEY60LhNfBXdQ7YQiYqRySZlHX",
    name: "survey.csv",
    filesize: 151391,
    state: "processed",
    shared: "link",
    created_at: "2013-09-16T23:45:01Z",
    subdomain: "test",
    url_base: "https://www.statwing.com/p0/datasets/dat_w4xsNWqEY60LhNfBXdQ7YQiYqRySZlHX",
    users: [
      {
      id: "usr_BeUNgZDkuYIzta2gI8PqPABOap0CYpkF",
      partner_user_id: null,
      url: "https://www.statwing.com/p0/datasets/dat_w4xsNWqEY60LhNfBXdQ7YQiYqRySZlHX/users/usr_BeUNgZDkuYIzta2gI8PqPABOap0CYpkF"
      },
      { ... },
      { ... }
    ]
  },
  { ... },
  { ... }
]

Retrieving a dataset

Returns a dataset object with the id specified in the url.

Arguments
DATASET_ID:
string, required

The identifier of the dataset to be returned. This should be a string with "dat_" prefix.

Returns

Return the dataset object, matching the id provided if found, otherwise returns an error.

GET https://www.statwing.com/api/p0/datasets/{DATASET_ID}
curl -i -XGET https://www.statwing.com/api/p0/datasets/dat_kuPrFoYkh9y4DuBcR8mFlb4A1AAChAos \
  -u M2sFjReGPFVrFdr8hwo6n0Tsm9aUZReG:
{
  id: "dat_kuPrFoYkh9y4DuBcR8mFlb4A1AAChAos",
  name: "titanic.csv",
  filesize: 927177,
  state: "processed",
  shared: "restricted",
  created_at: "2013-09-16T23:46:38Z",
  subdomain: "test",
  url_base: "https://test.statwing.com/p0/datasets/dat_kuPrFoYkh9y4DuBcR8mFlb4A1AAChAos",
  users: [
    {
      "id":"usr_BeUNgZDkuYIzta2gI8PqPABOap0CYpkF",
      "partner_user_id":null,
      "url":"https://test.statwing.com/p0/datasets/dat_kuPrFoYkh9y4DuBcR8mFlb4A1AAChAos/users/usr_BeUNgZDkuYIzta2gI8PqPABOap0CYpkF"
    },
    { ... }
  ]
}

Updating a dataset

By update you can change dataset's name, share permissions, user access permissions, and redownload it.

Arguments
dataset[name]:
string, optional

Arbitrary string for renaming the dataset.

dataset[shared]:
string, optional

Either "restricted" or "link"

  • Restricted: the dataset can only be accessed by you and the users defined in the dataset[users].
  • Link: the dataset can be accessed through a secret link, without user login required.

If something other than 'restricted' or 'link' is given, then the dataset[shared] will be set to restricted.

dataset[fileurl]:
url string, optional

Url from where the dataset will be downloaded to our servers.

Fileurl in the curl request needs to be url encoded. See for example the curl request in the creating a dataset section, where the ampersand ('&') is replaced with '%26'.

The dataset will be redownloaded if dataset[update] is set to true.

dataset[header][parameter_name]
string, optional

Adds 'parameter_name', e.g. 'authCode', 'oneTimeToken', etc, to the header when Statwing makes the download request to fileurl.

Useful in cases where the fileurl needs a one time use token in the request header on download.

dataset[users][action]:
string, optional

Either "add", "set", or "remove"

The action to perform for the dataset[users].

  • Add: adds users to the existing dataset[users] list.
  • Set: clears the dataset[users], and adds the users given in the dataset[users][data] to the dataset[users] list.
  • Remove: removes the users given in the dataset[users][data] from the dataset[users] list.
dataset[users][data][][object]:
string, required if dataset[users][action] given

Either "user_id" or "partner_user_id"

Whether to perrform the action according to user's unique Statwing id, or the unique id in your system.

  • user_id: The action is performed to the user with the matching Statwing id.
  • partner_user_id: The action is performed to the user with the matching partner user id.
dataset[users][data][][data]:
string, required if dataset[users][action] given

Either user's Statwing id or Partner id, depending of the previous parameter

  • If the previous parameter is "user_id", this should be a string with "usr_" prefix.
  • If the previous parameter is "partner_user_id", this should refer to the user created with your system's unique identifier.
dataset[update]:
boolean, optional

Indicating whether to redownload from the dataset[fileurl] or not.

Returns

Return the dataset object matching the target id, regardless of whether the dataset is updated or not. If something goes wrong, responds with an error.

PUT https://www.statwing.com/api/p0/datasets/{DATASET_ID}
curl -i -XPUT https://www.statwing.com/api/p0/datasets/dat_kuPrFoYkh9y4DuBcR8mFlb4A1AAChAos \
  -u M2sFjReGPFVrFdr8hwo6n0Tsm9aUZReG: \
  -d dataset[name]="Titanic Passengers" \
  -d dataset[shared]="link" \
  -d dataset[users][action]="add" \
  -d dataset[users][data][][object]="user_id" \
  -d dataset[users][data][][data]="usr_MGI122OQWdMslSSKEi7ZoPaf2nY8ucKH" \
  -d dataset[fileurl]="https://gist.github.com/sandbox/6983768/raw/81e00eff263d6ac9fdedbe28de7d33dc8e850f2f/statwing.csv" \
  -d dataset[update]="true"
{
  "id":"dat_kuPrFoYkh9y4DuBcR8mFlb4A1AAChAos",
  "name":"Titanic Passengers",
  "filesize":927177,
  "state":"processed",
  "shared":"link",
  "created_at":"2013-09-16T23:46:38Z",
  "subdomain":"test",
  "url_base":"https://test.statwing.com/p0/datasets/dat_kuPrFoYkh9y4DuBcR8mFlb4A1AAChAos",
  "users":[
    {
      "id":"usr_MGI122OQWdMslSSKEi7ZoPaf2nY8ucKH",
      "partner_user_id":null,
      "url":"https://test.statwing.com/p0/datasets/dat_kuPrFoYkh9y4DuBcR8mFlb4A1AAChAos/users/usr_MGI122OQWdMslSSKEi7ZoPaf2nY8ucKH"
    },
    { ... },
    { ... }
  ]
}

Deleting a dataset

Remove the dataset with the id specified in the url.

Arguments
DATASET_ID:
string, required

The identifier of the dataset to delete.

Returns

Return the dataset id and if the deletion completed or not. If something goes wrong, responds with an error.

DELETE https://www.statwing.com/api/p0/datasets/{DATASET_ID}
curl -i -XDELETE https://www.statwing.com/api/p0/datasets/dat_kuPrFoYkh9y4DuBcR8mFlb4A1AAChAos \
-u M2sFjReGPFVrFdr8hwo6n0Tsm9aUZReG:
{
  "dataset_id": "dat_kuPrFoYkh9y4DuBcR8mFlb4A1AAChAos",
  "deleted": true
}

Users

The User objects map to individual users from your system. The API allows you to create new users as well as update and retrieve information of existing ones. By user objects, you can control the access permissions of the datasets.

User object

Attributes
id:
string

Random string with "usr_" prefix. Generated automatically by Statwing, when the user object is created.

partner_user_identity:
string

For example the email or other unique identifier for the user in your system.

{
  id: "usr_TgCCDW4sWHWGSUx4pvd0UZPwOI4vna3b",
  partner_user_identity: "user@yoursystem.com"
}

Creating a user

Create a new user object or return an existing user whose id matches to argument id.

Arguments
partner_user_id:
string, optional

The unique identifier of the user within your system.

The partner_user_id enables linking users from your system to Statwing's user objects.

Partner_user_id can be added and changed later with the update method.

Returns

Returns the created user object if the creation was successful, otherwise returns an error.

POST https://www.statwing.com/api/p0/users
curl -i -XPOST https://www.statwing.com/api/p0/users \
  -u M2sFjReGPFVrFdr8hwo6n0Tsm9aUZReG: \
  -d user[partner_user_id]="user@yoursystem.com"
{
  "id": "usr_TgCCDW4sWHWGSUx4pvd0UZPwOI4vna3b",
  "partner_user_identity": "user@yoursystem.com"
}

Listing the users

Returns a list containing user objects linked to the integration. You can adjust the amount and offset of the returned users by providing the parameters.

Arguments
offset:
integer, optional

default 0

limit:
integer, optional

default 0

Returns

Return an array, containing up to the limit amount, of users, beginning from the offset provided. If there are no users starting from the offset, the method returns empty array.

GET https://www.statwing.com/api/p0/users
curl -i -XGET https://www.statwing.com/api/p0/users \
  -u M2sFjReGPFVrFdr8hwo6n0Tsm9aUZReG:
{
  "users": [
    {
      "id": "user_2zutfOoK5watQqfR25GHv474roTu0kR7",
      "partner_user_identity": null
    },
    {
      "id": "user_BAYfB1zjWAzfP5FCsbMWBcYS7gtBCaSG",
      "partner_user_identity": null
    },
    { ... },
    { ... }
  ]
}

Retrieving a user

Returns a user object matching the id specified in the url.

Arguments
USER_ID:
string, required

the unique identifier of the user to be returned. This should be a string with "usr_" prefix.

Returns

Returns the user object matching the id provided if found, otherwise returns an error.


GET https://www.statwing.com/api/p0/users/{USER_ID}
curl -i -XGET https://www.statwing.com/api/p0/users/usr_TgCCDW4sWHWGSUx4pvd0UZPwOI4vna3b \
  -u M2sFjReGPFVrFdr8hwo6n0Tsm9aUZReG:
{
  "id": "usr_TgCCDW4sWHWGSUx4pvd0UZPwOI4vna3b",
  "partner_user_identity": "user@yoursystem.com"
}

Updating a user

By update you can change user's partner user identity.

Arguments
user[partner_user_id]:
string, optional

The unique identifier of the user within your system.

The partner_user_id enables linking users from your system to Statwing's user objects.

Returns

Return the user object matching the target id, regardless of whether the user is updated or not. If something goes wrong, responds with an error.

PUT https://www.statwing.com/api/p0/users/{USER_ID}
curl -i -XPUT https://www.statwing.com/api/p0/users/usr_TgCCDW4sWHWGSUx4pvd0UZPwOI4vna3b \
  -u M2sFjReGPFVrFdr8hwo6n0Tsm9aUZReG: \
  -d user[partner_user_id]="another@yoursystem.com"
{
  "id": "usr_TgCCDW4sWHWGSUx4pvd0UZPwOI4vna3b",
  "partner_user_identity": "another@yoursystem.com"
}

Dataset/Users

You can manage the users belonging to a specific dataset. Users belonging to a dataset have permission to access and analyze the dataset. The API methods allow you to add a user to the dataset, list all the users belonging to the dataset, and removing a user from the dataset.

https://www.statwing.com/api/p0/datasets/{DATASET_ID}/users

Add User to Dataset

You can add users to a specific dataset, granting them permission to analyze the dataset. If the user with the given partner user identity doesn't exist, the method creates a new user and adds it to the dataset.

Arguments
user[partner_user_id]:
string, required

The identity of the user in your system.

Returns the added user object, including the url pointing to the user. If the adding of the users fails, returns an error

POST https://www.statwing.com/api/p0/datasets/{DATASET_ID}/users
curl -i -XPOST https://www.statwing.com/api/p0/datasets/dat_kuPrFoYkh9y4DuBcR8mFlb4A1AAChAos/users \
  -u M2sFjReGPFVrFdr8hwo6n0Tsm9aUZReG: \
  -d user[partner_user_id]="user@yoursystem.com"
        
{
  "id": "usr_gY8iJkebXYFkoWWvgQd3EY48E43kpTOe",
  "partner_user_id": "user@yoursystem.com",
  "url": "https://www.statwing.com/p0/datasets/dat_kuPrFoYkh9y4DuBcR8mFlb4A1AAChAos/users/usr_gY8iJkebXYFkoWWvgQd3EY48E43kpTOe"
}

Listing the users for dataset

Returns a list containing user objects belonging to the dataset with the id specified in the url.

Arguments
offset:
integer, optional

default 0

limit:
integer, optional

default 0

Returns

Return an array, containing up to the limit amount of users belonging to the dataset, beginning from the offset provided. If there are no users starting from the offset, the method returns an empty array.

GET https://www.statwing.com/api/p0/datasets/{DATASET_ID}/users
curl -i -XGET https://www.statwing.com/api/p0/datasets/dat_kuPrFoYkh9y4DuBcR8mFlb4A1AAChAos/users \
  -u M2sFjReGPFVrFdr8hwo6n0Tsm9aUZReG:
{
  "users": [
    {
      "id": "usr_gY8iJkebXYFkoWWvgQd3EY48E43kpTOe",
      "partner_user_id": "user_1@yoursystem.com",
      "url": "https://www.statwing.com/p0/datasets/dat_kuPrFoYkh9y4DuBcR8mFlb4A1AAChAos/users/usr_gY8iJkebXYFkoWWvgQd3EY48E43kpTOe"
    },
    {
      "id": "usr_fe13aj3ThLWwS23OImitE5jFXgTsAP8u",
      "partner_user_id": "OtherUser",
      "url": "https://www.statwing.com/p0/datasets/dat_kuPrFoYkh9y4DuBcR8mFlb4A1AAChAos/users/usr_fe13aj3ThLWwS23OImitE5jFXgTsAP8u"
    },
    { ... },
    { ... }
  ]
}

Remove User from Dataset

Remove the user from the dataset with the id specified in the url.

Arguments
DATASET_ID:
string, required

The identifier of the dataset from which to remove the user.

USER_ID:
string, required

The identifier of the user to be removed from the dataset.

Returns

Return the identifiers for the user and the dataset it was removed from, in case of successful removal. If something goes wrong or objects with the given id's can't be found, returns an error.

DELETE https://www.statwing.com/api/p0/datasets/{DATASET_ID}/users/{USER_ID}
curl -i -XDELETE https://www.statwing.com/api/p0/datasets/dat_kuPrFoYkh9y4DuBcR8mFlb4A1AAChAos/users/usr_gY8iJkebXYFkoWWvgQd3EY48E43kpTOe \
-u M2sFjReGPFVrFdr8hwo6n0Tsm9aUZReG:
{
  "dataset_id": "dat_kuPrFoYkh9y4DuBcR8mFlb4A1AAChAos",
  "user_id": "usr_gY8iJkebXYFkoWWvgQd3EY48E43kpTOe",
  "restricted": true
}

User/Datasets

You can manage the datasets belonging to a specific user. The user has permission to access and analyze the datasets belonging to a him/her. The API allows you to list all the datasets belonging to a specific user.

https://www.statwing.com/api/p0/users/{USER_ID}/datasets

Listing the datasets for user

Returns a list containing dataset objects belonging to the user with the id specified in the url.

Arguments
USER_ID:
string, required

The identifier of the user to list the datasets for

Returns

Return an array, containing up to the limit amount of datasets belonging to the user, beginning from the offset provided. If there are no datasets starting from the offset, the method returns empty array.

GET https://www.statwing.com/api/p0/users/{USER_ID}/datasets
curl -i -XGET https://www.statwing.com/api/p0/users/usr_2zutfOoK5watQqfR25GHv474roTu0kR7/datasets \
  -u M2sFjReGPFVrFdr8hwo6n0Tsm9aUZReG:
{
  "datasets": [
    {
      "id": "dat_osO88rdnGItI0sZ825RF6aJg8JKbPpCX",
      "name": "statwing.csv",
      "filesize": 51975,
      "state": "processed",
      "shared": "restricted",
      "created_at": "2013-09-21T03:14:10Z",
      "subdomain": "test",
      "fileurl": "https://gist.github.com/sandbox/6983768/raw/81e00eff263d6ac9fdedbe28de7d33dc8e850f2f/statwing.csv",
      "url_base": "https://www.statwing.com/p0/datasets/dat_osO88rdnGItI0sZ825RF6aJg8JKbPpCX",
      "users": [
        {
          "id": "usr_2zutfOoK5watQqfR25GHv474roTu0kR7",
          "partner_user_id": null,
          "url": "https://www.statwing.com/p0/datasets/dat_osO88rdnGItI0sZ825RF6aJg8JKbPpCX/users/usr_2zutfOoK5watQqfR25GHv474roTu0kR7"
        },
        { ... }
      ]
    },
    {
      "id": "dat_wd1V7jI9JqDMGRmcxhIGD4elzd2PwHzl",
      "name": "congressional_data.csv",
      "filesize": 7912763,
      "state": "queued",
      "shared": "link",
      "created_at": "2013-09-21T03:04:41Z",
      "subdomain": "test",
      "fileurl": "https://gist.github.com/slermukka/6983882/raw/6c63ad1196e60ae485954a123026c4aac08d6a0b/congressional_data.csv",
      "url_base": "https://www.statwing.com/p0/datasets/dat_wd1V7jI9JqDMGRmcxhIGD4elzd2PwHzl",
      "users": [
        { ... },
        { ... }
      ]
    },
    { ... },
    { ... }
  ]
}