{"__v":18,"_id":"5537e24b3faac70d00ff6da8","category":{"__v":7,"_id":"542ac32254d88d140075fc3a","pages":["542ac32254d88d140075fc3c","55369f1f6fd3c40d00334978","5537e1563faac70d00ff6da6","5537e1f63e785d0d00be3feb","5537e22249a5800d00a28e54","5537e24b3faac70d00ff6da8","5537e26349a5800d00a28e56"],"project":"542ac32254d88d140075fc36","version":"542ac32254d88d140075fc39","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-09-30T14:50:10.530Z","from_sync":false,"order":0,"slug":"documentation","title":"Documentation"},"project":"542ac32254d88d140075fc36","user":"542ac2d054d88d140075fc29","version":{"__v":4,"_id":"542ac32254d88d140075fc39","project":"542ac32254d88d140075fc36","createdAt":"2014-09-30T14:50:10.500Z","releaseDate":"2014-09-30T14:50:10.500Z","categories":["542ac32254d88d140075fc3a","542af0fd54d88d140075ff1b","542af128cedcfc140004b8d0","5537e2870899730d0081368d"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-04-22T18:02:51.466Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"POST /dataset/push\"\n}\n[/block]\nAdds new data to an existing dataset. Controls for duplicate information by remapping rows when identical information is already in Exversion.\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"title\": \"Missing Values\",\n  \"body\": \"In order to ensure the best possible query results, Exversion normalizes pushed data to conform to the dataset's existing schema. If the dataset is empty a schema is created from the first row submitted through the API. For that reason please make sure there are no missing values (empty strings are acceptable). The API will reject any new data that contains parameters not listed in the schema.\"\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"access_token\",\n    \"1-0\": \"dataset\",\n    \"2-0\": \"data\",\n    \"2-1\": \"A dictionary of objects representing the data you wish to add to the repository\",\n    \"1-1\": \"The ID of the data repository you are adding data to\",\n    \"0-1\": \"The access token provided by OAuth authentication. Can also be generated directly on Exversion's web platform if you only want to access your own account.\",\n    \"h-0\": \"parameter\",\n    \"h-1\": \"value\"\n  },\n  \"cols\": 2,\n  \"rows\": 3\n}\n[/block]\n**Example Requests**\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"import requests\\nimport json\\n\\nurl = 'https://www.exversion.com/api/v1/dataset/push/'\\npayload = {'access_token':[YOUR ACCESS TOKEN], 'dataset':[DATASET ID],'data':[{'test':0,'gender':'f','Age':30,'name':'Marianne'}, {'test':0,'gender':'m','name':'Jacek'}]}\\nr = requests.post(url, data=json.dumps(payload))\\n\",\n      \"language\": \"python\"\n    },\n    {\n      \"code\": \"<?php\\n\\t$post = json_encode(\\n    array('access_token'=>[YOUR ACCESS TOKEN],\\n          'dataset'=>[DATASET ID],\\n          'data':array(\\n            array('test'=>0,\\n                  'gender'=>'f',\\n                  'Age'=>30,\\n                  'name'=>'Marianne'),\\n            array('test'=>0,\\n                  'gender'=>'m',\\n                  'name'=>'Jacek'))\\n  );\\n\\t\\t\\n$ch = curl_init('https://www.exversion.com/api/v1/dataset/push/');\\n    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, \\\"POST\\\");\\n    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);\\n    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\\n    curl_setopt($ch, CURLOPT_HTTPHEADER, array(\\n      'Content-Type: application/json',\\n      'Content-Length: ' . strlen($post))\\n       );\\n    $result = json_decode(curl_exec($ch));\\n?>\",\n      \"language\": \"php\"\n    },\n    {\n      \"code\": \"require 'unirest'\\nresponse = Unirest.post \\\"https://www.exversion.com/api/v1/dataset/push/\\\", \\n\\t\\theaders:{ \\\"Accept\\\" => \\\"application/json\\\" }, \\n    parameters:{'access_token'=>[YOUR ACCESS TOKEN],\\n          'dataset'=>[DATASET ID],\\n          'data':[{'test'=>0,\\n                  'gender'=>'f',\\n                  'Age'=>30,\\n            'name'=>'Marianne'},\\n            \\t\\t\\t{'test'=>0,\\n                  'gender'=>'m',\\n                    'name'=>'Jacek'}]}\",\n      \"language\": \"ruby\"\n    }\n  ]\n}\n[/block]\n**Example Response**\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\\"status\\\":200,\\n \\\"message\\\":\\\"Success\\\",\\n \\\"body\\\":{\\n   \\\"inserted\\\":[\\n     {\\n       \\\"test\\\":\\\"1\\\",\\n      \\t\\\"gender\\\":\\\"f\\\",\\n      \\t\\\"age\\\":\\\"30\\\",\\n      \\t\\\"name\\\":\\\"Marianne\\\"\\n     },\\n     {\\n       \\\"test\\\":\\\"0\\\",\\n       \\\"gender\\\":\\\"m\\\",\\n       \\\"name\\\":\\\"Jacek\\\",\\n       \\\"age\\\":\\\"\\\"\\n     }\\n   ],\\n   \\\"updated\\\":[],\\n   \\\"failed\\\":[]\\n }\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"Exversion will respond to your request with a dictionary specifying what it did with each row of data you sent it.\\n\\n- **inserted**: This data was not already in Exversion, so it was added\\n- **updated**: This data was in Exversion already, so Exversion updated it so that it is included in your dataset\\n- **failed**: There was something wrong with this data and it could not be added to the system\",\n  \"title\": \"Inserted, Updated or Failed?\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"POST /dataset/edit\"\n}\n[/block]\nEdit specific data points. Requires the _id of the specific data point (which is part of the information returned by any dataset query). This is intended to fixes errors, mistakes, corruption or inconsistencies in the data, not to update existing data points with new information. All changes are tracked and can be reverted through the web interface.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"parameter\",\n    \"h-1\": \"value\",\n    \"0-0\": \"access_token\",\n    \"0-1\": \"The access token provided by OAuth authentication. Can also be generated directly on Exversion's web platform if you only want to access your own account.\",\n    \"1-0\": \"edits\",\n    \"1-1\": \"An array of objects detailing changes made to data on Exversion\"\n  },\n  \"cols\": 2,\n  \"rows\": 2\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"The Edit Object\",\n  \"body\": \"Each edit is an object with the following attributes:\\n- **dataset**: the ID of the dataset being changed\\n- **_id**: the ID of the specific data point being changed\\n- **changes**: the attributes in the data point to change with their new values\"\n}\n[/block]\n**Example Requests**\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"import requests\\nimport json\\n\\nurl = 'https://www.exversion.com/api/v1/dataset/edit/'\\npayload = {'access_token':[YOUR ACCESS TOKEN],'edits':[{'dataset':[DATASET ID], '_id':[DATA POINT ID], 'changes':{'test':1,'name':'Tal','age':25}}]}\\nr = requests.post(url, data=json.dumps(payload))\",\n      \"language\": \"python\"\n    },\n    {\n      \"code\": \"<?php\\n\\t$post = json_encode(\\n    array('access_token'=>[YOUR ACCESS TOKEN],\\n          'edits'=>array(\\n            array(\\n              'dataset'=>[DATASET ID],\\n              '_id'=>[DATA POINT ID],\\n              'changes'=>array('test'=>1,'name'=>'Tal','age'=>25)))\\n  );\\n\\t\\t\\n\\t$ch = curl_init('https://www.exversion.com/api/v1/dataset/edit/');\\n    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, \\\"POST\\\");\\n    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);\\n    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\\n    curl_setopt($ch, CURLOPT_HTTPHEADER, array(\\n      'Content-Type: application/json',\\n      'Content-Length: ' . strlen($post))\\n       );\\n    $result = json_decode(curl_exec($ch));\\n?>\",\n      \"language\": \"php\"\n    },\n    {\n      \"code\": \"require 'unirest'\\nresponse = Unirest.post \\\"https://www.exversion.com/api/v1/dataset/edit/\\\", \\n\\t\\theaders:{ \\\"Accept\\\" => \\\"application/json\\\" }, \\n    parameters:{'access_token'=>[YOUR ACCESS TOKEN],\\n          \\t\\t'edits'=>[\\n              \\t{'dataset'=>[DATASET ID],\\n              \\t'_id'=>[DATA POINT ID],\\n                'changes'=>{'test'=>1,'name'=>'Tal','age'=>25}}]}\",\n      \"language\": \"ruby\"\n    }\n  ]\n}\n[/block]\n**Example Response**\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\\"status\\\":200,\\n \\\"message\\\":\\\"Success\\\",\\n \\\"body\\\":[\\n   {\\n     \\\"test\\\":1,\\n     \\\"gender\\\":\\\"f\\\",\\n     \\\"name\\\":\\\"Tal\\\",\\n     \\\"age\\\":25\\n   }\\n ]\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"POST /dataset/schema\"\n}\n[/block]\nAdd or remove columns from the dataset. When adding a column data points will have to be updated separately. Label columns type delete when deleting them, type insert when adding one.\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"parameter\",\n    \"h-1\": \"value\",\n    \"0-0\": \"access_token\",\n    \"0-1\": \"The access token provided by OAuth authentication. Can also be generated directly on Exversion's web platform if you only want to access your own account.\",\n    \"1-0\": \"changes\",\n    \"1-1\": \"An array of objects specifying columns to be added or removed from their datasets\"\n  },\n  \"cols\": 2,\n  \"rows\": 2\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"The Schema Change Object\",\n  \"body\": \"Each change is an object with the following attributes\\n- **dataset**: the ID of the dataset being changed\\n- **type**: either 'insert' for adding a column or 'delete' for removing it\\n- **column_name**: name of the column to be added or removed\"\n}\n[/block]\n**Example Requests**\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"import requests\\nimport json\\n\\nurl = 'https://www.exversion.com/api/v1/dataset/schema/'\\npayload = {\\\"access_token\\\":[YOUR ACCESS TOKEN], \\\"changes\\\":[{\\\"dataset\\\":[DATASET ID], \\\"type\\\":\\\"delete\\\", \\\"column_name\\\":\\\"name\\\"}]}\\nr = requests.post(url, data=json.dumps(payload))\",\n      \"language\": \"python\"\n    },\n    {\n      \"code\": \"<?php\\n\\t$post = json_encode(\\n    array('access_token'=>[YOUR ACCESS TOKEN],\\n          'changes'=>array(\\n            \\t\\t\\t\\t\\t\\tarray('dataset'=>[DATASET ID],\\n                              'type'=>\\\"delete\\\",\\n                              'column_name'=>\\\"name\\\"))\\n  );\\n\\t\\t\\n\\t$ch = curl_init('https://www.exversion.com/api/v1/dataset/schema/');\\n    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, \\\"POST\\\");\\n    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);\\n    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\\n    curl_setopt($ch, CURLOPT_HTTPHEADER, array(\\n      'Content-Type: application/json',\\n      'Content-Length: ' . strlen($post))\\n    );\\n    $result = json_decode(curl_exec($ch));\\n?>\",\n      \"language\": \"php\"\n    },\n    {\n      \"code\": \"require 'unirest'\\nresponse = Unirest.post \\\"https://www.exversion.com/api/v1/dataset/schema/\\\", \\n\\t\\theaders:{ \\\"Accept\\\" => \\\"application/json\\\" }, \\n    parameters:{'access_token'=>[YOUR ACCESS TOKEN],\\n          'changes'=>[\\n            {'dataset'=>[DATASET ID],\\n             'type'=>\\\"delete\\\",\\n              'column_name'=>\\\"name\\\"}\\n            ]\\n      }\",\n      \"language\": \"ruby\"\n    }\n  ]\n}\n[/block]\n**Example Response**\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\\"status\\\":200,\\n \\\"message\\\":\\\"Column name has been added to dataset XXX and all tracking children\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"adding-or-changing-data","type":"basic","title":"Adding or Changing Data"}

Adding or Changing Data


[block:api-header] { "type": "basic", "title": "POST /dataset/push" } [/block] Adds new data to an existing dataset. Controls for duplicate information by remapping rows when identical information is already in Exversion. [block:callout] { "type": "danger", "title": "Missing Values", "body": "In order to ensure the best possible query results, Exversion normalizes pushed data to conform to the dataset's existing schema. If the dataset is empty a schema is created from the first row submitted through the API. For that reason please make sure there are no missing values (empty strings are acceptable). The API will reject any new data that contains parameters not listed in the schema." } [/block] [block:parameters] { "data": { "0-0": "access_token", "1-0": "dataset", "2-0": "data", "2-1": "A dictionary of objects representing the data you wish to add to the repository", "1-1": "The ID of the data repository you are adding data to", "0-1": "The access token provided by OAuth authentication. Can also be generated directly on Exversion's web platform if you only want to access your own account.", "h-0": "parameter", "h-1": "value" }, "cols": 2, "rows": 3 } [/block] **Example Requests** [block:code] { "codes": [ { "code": "import requests\nimport json\n\nurl = 'https://www.exversion.com/api/v1/dataset/push/'\npayload = {'access_token':[YOUR ACCESS TOKEN], 'dataset':[DATASET ID],'data':[{'test':0,'gender':'f','Age':30,'name':'Marianne'}, {'test':0,'gender':'m','name':'Jacek'}]}\nr = requests.post(url, data=json.dumps(payload))\n", "language": "python" }, { "code": "<?php\n\t$post = json_encode(\n array('access_token'=>[YOUR ACCESS TOKEN],\n 'dataset'=>[DATASET ID],\n 'data':array(\n array('test'=>0,\n 'gender'=>'f',\n 'Age'=>30,\n 'name'=>'Marianne'),\n array('test'=>0,\n 'gender'=>'m',\n 'name'=>'Jacek'))\n );\n\t\t\n$ch = curl_init('https://www.exversion.com/api/v1/dataset/push/');\n curl_setopt($ch, CURLOPT_CUSTOMREQUEST, \"POST\");\n curl_setopt($ch, CURLOPT_POSTFIELDS, $post);\n curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\n curl_setopt($ch, CURLOPT_HTTPHEADER, array(\n 'Content-Type: application/json',\n 'Content-Length: ' . strlen($post))\n );\n $result = json_decode(curl_exec($ch));\n?>", "language": "php" }, { "code": "require 'unirest'\nresponse = Unirest.post \"https://www.exversion.com/api/v1/dataset/push/\", \n\t\theaders:{ \"Accept\" => \"application/json\" }, \n parameters:{'access_token'=>[YOUR ACCESS TOKEN],\n 'dataset'=>[DATASET ID],\n 'data':[{'test'=>0,\n 'gender'=>'f',\n 'Age'=>30,\n 'name'=>'Marianne'},\n \t\t\t{'test'=>0,\n 'gender'=>'m',\n 'name'=>'Jacek'}]}", "language": "ruby" } ] } [/block] **Example Response** [block:code] { "codes": [ { "code": "{\"status\":200,\n \"message\":\"Success\",\n \"body\":{\n \"inserted\":[\n {\n \"test\":\"1\",\n \t\"gender\":\"f\",\n \t\"age\":\"30\",\n \t\"name\":\"Marianne\"\n },\n {\n \"test\":\"0\",\n \"gender\":\"m\",\n \"name\":\"Jacek\",\n \"age\":\"\"\n }\n ],\n \"updated\":[],\n \"failed\":[]\n }\n}", "language": "json" } ] } [/block] [block:callout] { "type": "info", "body": "Exversion will respond to your request with a dictionary specifying what it did with each row of data you sent it.\n\n- **inserted**: This data was not already in Exversion, so it was added\n- **updated**: This data was in Exversion already, so Exversion updated it so that it is included in your dataset\n- **failed**: There was something wrong with this data and it could not be added to the system", "title": "Inserted, Updated or Failed?" } [/block] [block:api-header] { "type": "basic", "title": "POST /dataset/edit" } [/block] Edit specific data points. Requires the _id of the specific data point (which is part of the information returned by any dataset query). This is intended to fixes errors, mistakes, corruption or inconsistencies in the data, not to update existing data points with new information. All changes are tracked and can be reverted through the web interface. [block:parameters] { "data": { "h-0": "parameter", "h-1": "value", "0-0": "access_token", "0-1": "The access token provided by OAuth authentication. Can also be generated directly on Exversion's web platform if you only want to access your own account.", "1-0": "edits", "1-1": "An array of objects detailing changes made to data on Exversion" }, "cols": 2, "rows": 2 } [/block] [block:callout] { "type": "info", "title": "The Edit Object", "body": "Each edit is an object with the following attributes:\n- **dataset**: the ID of the dataset being changed\n- **_id**: the ID of the specific data point being changed\n- **changes**: the attributes in the data point to change with their new values" } [/block] **Example Requests** [block:code] { "codes": [ { "code": "import requests\nimport json\n\nurl = 'https://www.exversion.com/api/v1/dataset/edit/'\npayload = {'access_token':[YOUR ACCESS TOKEN],'edits':[{'dataset':[DATASET ID], '_id':[DATA POINT ID], 'changes':{'test':1,'name':'Tal','age':25}}]}\nr = requests.post(url, data=json.dumps(payload))", "language": "python" }, { "code": "<?php\n\t$post = json_encode(\n array('access_token'=>[YOUR ACCESS TOKEN],\n 'edits'=>array(\n array(\n 'dataset'=>[DATASET ID],\n '_id'=>[DATA POINT ID],\n 'changes'=>array('test'=>1,'name'=>'Tal','age'=>25)))\n );\n\t\t\n\t$ch = curl_init('https://www.exversion.com/api/v1/dataset/edit/');\n curl_setopt($ch, CURLOPT_CUSTOMREQUEST, \"POST\");\n curl_setopt($ch, CURLOPT_POSTFIELDS, $post);\n curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\n curl_setopt($ch, CURLOPT_HTTPHEADER, array(\n 'Content-Type: application/json',\n 'Content-Length: ' . strlen($post))\n );\n $result = json_decode(curl_exec($ch));\n?>", "language": "php" }, { "code": "require 'unirest'\nresponse = Unirest.post \"https://www.exversion.com/api/v1/dataset/edit/\", \n\t\theaders:{ \"Accept\" => \"application/json\" }, \n parameters:{'access_token'=>[YOUR ACCESS TOKEN],\n \t\t'edits'=>[\n \t{'dataset'=>[DATASET ID],\n \t'_id'=>[DATA POINT ID],\n 'changes'=>{'test'=>1,'name'=>'Tal','age'=>25}}]}", "language": "ruby" } ] } [/block] **Example Response** [block:code] { "codes": [ { "code": "{\"status\":200,\n \"message\":\"Success\",\n \"body\":[\n {\n \"test\":1,\n \"gender\":\"f\",\n \"name\":\"Tal\",\n \"age\":25\n }\n ]\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "POST /dataset/schema" } [/block] Add or remove columns from the dataset. When adding a column data points will have to be updated separately. Label columns type delete when deleting them, type insert when adding one. [block:parameters] { "data": { "h-0": "parameter", "h-1": "value", "0-0": "access_token", "0-1": "The access token provided by OAuth authentication. Can also be generated directly on Exversion's web platform if you only want to access your own account.", "1-0": "changes", "1-1": "An array of objects specifying columns to be added or removed from their datasets" }, "cols": 2, "rows": 2 } [/block] [block:callout] { "type": "info", "title": "The Schema Change Object", "body": "Each change is an object with the following attributes\n- **dataset**: the ID of the dataset being changed\n- **type**: either 'insert' for adding a column or 'delete' for removing it\n- **column_name**: name of the column to be added or removed" } [/block] **Example Requests** [block:code] { "codes": [ { "code": "import requests\nimport json\n\nurl = 'https://www.exversion.com/api/v1/dataset/schema/'\npayload = {\"access_token\":[YOUR ACCESS TOKEN], \"changes\":[{\"dataset\":[DATASET ID], \"type\":\"delete\", \"column_name\":\"name\"}]}\nr = requests.post(url, data=json.dumps(payload))", "language": "python" }, { "code": "<?php\n\t$post = json_encode(\n array('access_token'=>[YOUR ACCESS TOKEN],\n 'changes'=>array(\n \t\t\t\t\t\tarray('dataset'=>[DATASET ID],\n 'type'=>\"delete\",\n 'column_name'=>\"name\"))\n );\n\t\t\n\t$ch = curl_init('https://www.exversion.com/api/v1/dataset/schema/');\n curl_setopt($ch, CURLOPT_CUSTOMREQUEST, \"POST\");\n curl_setopt($ch, CURLOPT_POSTFIELDS, $post);\n curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\n curl_setopt($ch, CURLOPT_HTTPHEADER, array(\n 'Content-Type: application/json',\n 'Content-Length: ' . strlen($post))\n );\n $result = json_decode(curl_exec($ch));\n?>", "language": "php" }, { "code": "require 'unirest'\nresponse = Unirest.post \"https://www.exversion.com/api/v1/dataset/schema/\", \n\t\theaders:{ \"Accept\" => \"application/json\" }, \n parameters:{'access_token'=>[YOUR ACCESS TOKEN],\n 'changes'=>[\n {'dataset'=>[DATASET ID],\n 'type'=>\"delete\",\n 'column_name'=>\"name\"}\n ]\n }", "language": "ruby" } ] } [/block] **Example Response** [block:code] { "codes": [ { "code": "{\"status\":200,\n \"message\":\"Column name has been added to dataset XXX and all tracking children\"\n}", "language": "json" } ] } [/block]