{"_id":"564509aa2c74cf1900da48c7","project":"563a252d50bf950d00e09798","version":{"_id":"563a252d50bf950d00e0979b","__v":7,"project":"563a252d50bf950d00e09798","createdAt":"2015-11-04T15:33:01.701Z","releaseDate":"2015-11-04T15:33:01.701Z","categories":["563a252e50bf950d00e0979c","563a2a691846790d008952fe","563a3394daf1c00d00136d9b","563a3467d25e8919005f3f0c","563a347850bf950d00e097b4","570e5cec10aa423200391fb5","5890d358d6cb8e2500a3f311"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"category":{"_id":"563a252e50bf950d00e0979c","project":"563a252d50bf950d00e09798","pages":["563a252f50bf950d00e0979e","563a35ac1846790d0089532c","563d1407d8f2d20d00448d3c","563d1d3f9799fb0d0004776a","564509aa2c74cf1900da48c7","56453b7e9f3f550d00fa3c7b","564b498aeed7de0d003672c3","564b523ce5d9d61700d580e0","564b58ea1a8e610d006bfd49","564b59baee12850d00958656","564b6773d969330d00aba984","564b69b2d7b95d0d00ed050f","564b7fa8cc472d0d00da9447","564b905fa8a0ba21002ad6b1","564ba051288b1a2b00b3ae83","564ba6275cc43717009bcff1","564bb2138841060d00abb2e0","564bb74e05c99e1700161dd1","564c8ad60ddedc210051e582","564cca42d0c5b42b002305e8","564cca8ecfa4452b0019926d","564ce34f404ce53500fdb255","564cea76404ce53500fdb272","564cedb77d4d31170028dd2e","564cefc1bc81632100b10468","564cf17d1f42792b00820515","564cf5462248461700bd4017","564ddd49a8671617004e7b90","564ddf9ead1d5217003e2e18","564de1dea8671617004e7b99","564de3c11133043500f4bf96","564de669e39c4435005a1f65","564df3f16eaa3a2100868961","5655d3519347d30d00d7e8e2"],"version":"563a252d50bf950d00e0979b","__v":34,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-11-04T15:33:02.244Z","from_sync":false,"order":9999,"slug":"documentation","title":"Documentation"},"user":"54c7fdeae317000d007c2765","__v":16,"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-11-12T21:50:34.749Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":10,"body":"[block:api-header]\n{\n  \"type\": \"get\",\n  \"title\": \"GET /datasources\"\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"Description\",\n    \"0-1\": \"Get a list of all the data sources to which the user has access.\",\n    \"1-0\": \"Permissions\",\n    \"2-0\": \"Resource URL\",\n    \"3-0\": \"Parameters\",\n    \"1-1\": \"dashboard.library\",\n    \"2-1\": \"https://app.klipfolio.com/api/1.0/datasources\",\n    \"3-1\": \"client_id={id}\"\n  },\n  \"cols\": 2,\n  \"rows\": 4\n}\n[/block]\n##Example Request\nGET https://app.klipfolio.com/api/1/datasources?client_id=0123456789abcdef0123456789abcdef\n\n##Example Response\n```\n{\n  \"meta\": {\n    \"success\": true,\n    \"status\": 200,\n    \"count\": 4,\n    \"total\": 4\n  },\n  \"data\": {\n    \"datasources\": [\n      {\n        \"id\": \"c98bad42a8c8a63e0b5e6c0f7aca9898\",\n        \"name\": \"Example: Marketing Web Analytics\",\n        \"description\": \"Sample data you can use when trying out Klipfolio. This is an example of typical web analytics data that you might pull out of services like Google Analytics, GoSquared or Adobe Analytics.\",\n        \"refresh_interval\": 0,\n        \"date_last_refresh\": \"2016-06-17T13:33:57Z\",\n        \"is_dynamic\": false\n      },\n     \n    ]\n  }\n}\n```\n[block:api-header]\n{\n  \"type\": \"get\",\n  \"title\": \"GET /datasources/{id}\"\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"Description\",\n    \"0-1\": \"Get the details for the specific data source id.\",\n    \"1-0\": \"Permissions\",\n    \"2-0\": \"Resource URL\",\n    \"3-0\": \"Parameters\",\n    \"1-1\": \"dashboard.library\",\n    \"2-1\": \"https://app.klipfolio.com/api/1.0/datasources/{id}\",\n    \"3-1\": \"id={datasource id}\"\n  },\n  \"cols\": 2,\n  \"rows\": 4\n}\n[/block]\n##Example Request\nGET https://app.klipfolio.com/api/1/datasources/0123456789abcdef0123456789abcdef\n\n##Example Response\n```\n{\n  \"data\": {\n       \"id\":\"0123456789abcdef0123456789abcdef\",\n       \"company\":\"Self\",\n       \"name\":\"Sample Datasource\",\n       \"description\":\"Datasource sample details\",\n       \"connector\":\"google_adwords\",\n       \"format\":\"csv\",\n       \"refresh_interval\":432000,\n       \"created_by\":\"98765432109876543210987654321\",\n       \"is_dynamic\":false,\n       \"disabled\":false,\n       \"date_created\":\"2014-11-04T20:26:22Z\",\n       \"date_last_refresh\":\"2014-11-12T21:43:10Z\"\n  },\n  \"meta\": {\n      \"status\": 200,\n      \"success\": true\n  }\n```\n[block:api-header]\n{\n  \"type\": \"post\",\n  \"title\": \"POST /datasources\"\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"Description\",\n    \"0-1\": \"Create a data source.  Data source properties can optionally be specified in the post data.\",\n    \"1-0\": \"Permissions\",\n    \"2-0\": \"Resource URL\",\n    \"3-0\": \"Fields\",\n    \"1-1\": \"datasource.create\",\n    \"2-1\": \"https://app.klipfolio.com/api/1.0/datasources/{id}\",\n    \"3-1\": \"name, description, format, connector, refresh_interval, properties, client_id (optional)\\n\\nWhere connector could be: 'box', 'comscore', 'db', 'dropbox', 'facebook', 'ftp', 'google_adwords', 'google_analytics', 'google_drive', 'google_spreadsheets', 'hubspot', 'iformbuilder', 'marketo', 'omniture', 'radian6', 'salesforce', 'searchMetrics', 'shopify', 'simple_rest', 'survey_monkey', 'versature', 'xero', 'xmla'\"\n  },\n  \"cols\": 2,\n  \"rows\": 4\n}\n[/block]\n##Example Requests\n\n**Note: optionally include 'client_id' in the post data to create a data source for a client.\n**\n\nPOST https://app.klipfolio.com/api/1/datasources -d \n“{'name': 'Example','description': 'This is a new data source', 'format': 'xml', 'connector': 'simple_rest', 'refresh_interval': 1800, 'properties': {'endpoint_url': 'http://test/data/scatter.xml', 'method': 'GET'}}”\n\n\n**This is an example request for a Google Analytics dynamic data source:**\n\n`POST https://app.klipfolio.com/api/1/datasources -d \n\"{'name': 'Test', \n'description': 'Test', \n'connector': 'google_analytics', \n'format': 'csv', \n'refresh_interval': 12345, \n'properties': {\n'endpoint_url': 'https://www.googleapis.com/analytics/v3/data/ga\\?ids=ga:{props.profile_id}\\&dimensions=ga:deviceCategory,ga:date\\&metrics=ga:sessions\\&start-date={date.add(-365).format()}\\&end-date={date.today}\\&max-results=10000', \n'oauth_provider_id': 'google20', \n'oauth_user_header': '123456abcdefg123456abcdef1234abcd12ab1234abcd', \n'oauth_user_token': 'ab12.Ai-aA1G23BcD4EF5gHijk678lMNOpqrSTu-vW_x9Yzabcd1Efghij2kl3m4_N5OPQjQ', \n'token_id': '123ab45c6a123b123a1abc1234abc12b1', \n'prop:profile_id': '123456789'}}\"`\n\n##Example Response\n**Note that both the data source id and the corresponding data source instance id is returned.**\n```\n{\n \"meta\": {\n   \"success\": true,\n   \"status\": 201,\n   \"location\": \"/datasources/5d8821caa9ac3b2a291496e182de13e2\",\n   \"instance_location\": \"/datasource_instances/5d8821caa9ac3b2a291496e182de13e2\"\n },\n \"data\": { }\n}\n```\n[block:api-header]\n{\n  \"type\": \"put\",\n  \"title\": \"PUT /datasources/{id}\"\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"Description\",\n    \"0-1\": \"Update the specified data source.\",\n    \"1-0\": \"Permissions\",\n    \"2-0\": \"Resource URL\",\n    \"3-0\": \"Fields\",\n    \"2-1\": \"https://app.klipfolio.com/api/1.0/datasources\",\n    \"1-1\": \"datasource.edit\",\n    \"3-1\": \"name, description, refresh_interval\"\n  },\n  \"cols\": 2,\n  \"rows\": 4\n}\n[/block]\n##Example Request\nPUT https://app.klipfolio.com/api/1/datasources/8ea607c46ba6a7ba6e4c16ee292d7608 -d \n\"{'name': 'Updated Data Source Name', \n'description': 'This is cool info',\n'refresh_interval': 14400}\"\n\n##Example Response:\n```\n{ \"meta\": { \"success\": true, \"status\": 200 }, \"data\": { } }\n```\n\n**Note: Use [Data Source Instances Data](doc:data-source-instances-data) to update the specified data source with data.**\n[block:api-header]\n{\n  \"type\": \"delete\",\n  \"title\": \"DELETE /datasources/{id}\"\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"Description\",\n    \"0-1\": \"Delete the data source associated with a specific data source ID.\",\n    \"1-0\": \"Permissions\",\n    \"2-0\": \"Resource URL\",\n    \"3-0\": \"Parameters\",\n    \"1-1\": \"datasource.delete\",\n    \"2-1\": \"https://app.klipfolio.com/api/1.0/datasources/{id}\",\n    \"3-1\": \"id={datasource id}\"\n  },\n  \"cols\": 2,\n  \"rows\": 4\n}\n[/block]\n##Example Request\nDELETE https://app.klipfolio.com/api/1/datasources/0123456789abcdef0123456789abcdef\n\n##Example Response\n```\n{\n\"data\": {},\n\"meta\": {\n    \"status\": 200,\n    \"success\": true\n}\n}\n```","excerpt":"Viewing, creating, updating and managing data sources.","slug":"data-sources","type":"basic","title":"Data Sources"}

Data Sources

Viewing, creating, updating and managing data sources.

[block:api-header] { "type": "get", "title": "GET /datasources" } [/block] [block:parameters] { "data": { "0-0": "Description", "0-1": "Get a list of all the data sources to which the user has access.", "1-0": "Permissions", "2-0": "Resource URL", "3-0": "Parameters", "1-1": "dashboard.library", "2-1": "https://app.klipfolio.com/api/1.0/datasources", "3-1": "client_id={id}" }, "cols": 2, "rows": 4 } [/block] ##Example Request GET https://app.klipfolio.com/api/1/datasources?client_id=0123456789abcdef0123456789abcdef ##Example Response ``` { "meta": { "success": true, "status": 200, "count": 4, "total": 4 }, "data": { "datasources": [ { "id": "c98bad42a8c8a63e0b5e6c0f7aca9898", "name": "Example: Marketing Web Analytics", "description": "Sample data you can use when trying out Klipfolio. This is an example of typical web analytics data that you might pull out of services like Google Analytics, GoSquared or Adobe Analytics.", "refresh_interval": 0, "date_last_refresh": "2016-06-17T13:33:57Z", "is_dynamic": false }, ] } } ``` [block:api-header] { "type": "get", "title": "GET /datasources/{id}" } [/block] [block:parameters] { "data": { "0-0": "Description", "0-1": "Get the details for the specific data source id.", "1-0": "Permissions", "2-0": "Resource URL", "3-0": "Parameters", "1-1": "dashboard.library", "2-1": "https://app.klipfolio.com/api/1.0/datasources/{id}", "3-1": "id={datasource id}" }, "cols": 2, "rows": 4 } [/block] ##Example Request GET https://app.klipfolio.com/api/1/datasources/0123456789abcdef0123456789abcdef ##Example Response ``` { "data": { "id":"0123456789abcdef0123456789abcdef", "company":"Self", "name":"Sample Datasource", "description":"Datasource sample details", "connector":"google_adwords", "format":"csv", "refresh_interval":432000, "created_by":"98765432109876543210987654321", "is_dynamic":false, "disabled":false, "date_created":"2014-11-04T20:26:22Z", "date_last_refresh":"2014-11-12T21:43:10Z" }, "meta": { "status": 200, "success": true } ``` [block:api-header] { "type": "post", "title": "POST /datasources" } [/block] [block:parameters] { "data": { "0-0": "Description", "0-1": "Create a data source. Data source properties can optionally be specified in the post data.", "1-0": "Permissions", "2-0": "Resource URL", "3-0": "Fields", "1-1": "datasource.create", "2-1": "https://app.klipfolio.com/api/1.0/datasources/{id}", "3-1": "name, description, format, connector, refresh_interval, properties, client_id (optional)\n\nWhere connector could be: 'box', 'comscore', 'db', 'dropbox', 'facebook', 'ftp', 'google_adwords', 'google_analytics', 'google_drive', 'google_spreadsheets', 'hubspot', 'iformbuilder', 'marketo', 'omniture', 'radian6', 'salesforce', 'searchMetrics', 'shopify', 'simple_rest', 'survey_monkey', 'versature', 'xero', 'xmla'" }, "cols": 2, "rows": 4 } [/block] ##Example Requests **Note: optionally include 'client_id' in the post data to create a data source for a client. ** POST https://app.klipfolio.com/api/1/datasources -d “{'name': 'Example','description': 'This is a new data source', 'format': 'xml', 'connector': 'simple_rest', 'refresh_interval': 1800, 'properties': {'endpoint_url': 'http://test/data/scatter.xml', 'method': 'GET'}}” **This is an example request for a Google Analytics dynamic data source:** `POST https://app.klipfolio.com/api/1/datasources -d "{'name': 'Test', 'description': 'Test', 'connector': 'google_analytics', 'format': 'csv', 'refresh_interval': 12345, 'properties': { 'endpoint_url': 'https://www.googleapis.com/analytics/v3/data/ga\?ids=ga:{props.profile_id}\&dimensions=ga:deviceCategory,ga:date\&metrics=ga:sessions\&start-date={date.add(-365).format()}\&end-date={date.today}\&max-results=10000', 'oauth_provider_id': 'google20', 'oauth_user_header': '123456abcdefg123456abcdef1234abcd12ab1234abcd', 'oauth_user_token': 'ab12.Ai-aA1G23BcD4EF5gHijk678lMNOpqrSTu-vW_x9Yzabcd1Efghij2kl3m4_N5OPQjQ', 'token_id': '123ab45c6a123b123a1abc1234abc12b1', 'prop:profile_id': '123456789'}}"` ##Example Response **Note that both the data source id and the corresponding data source instance id is returned.** ``` { "meta": { "success": true, "status": 201, "location": "/datasources/5d8821caa9ac3b2a291496e182de13e2", "instance_location": "/datasource_instances/5d8821caa9ac3b2a291496e182de13e2" }, "data": { } } ``` [block:api-header] { "type": "put", "title": "PUT /datasources/{id}" } [/block] [block:parameters] { "data": { "0-0": "Description", "0-1": "Update the specified data source.", "1-0": "Permissions", "2-0": "Resource URL", "3-0": "Fields", "2-1": "https://app.klipfolio.com/api/1.0/datasources", "1-1": "datasource.edit", "3-1": "name, description, refresh_interval" }, "cols": 2, "rows": 4 } [/block] ##Example Request PUT https://app.klipfolio.com/api/1/datasources/8ea607c46ba6a7ba6e4c16ee292d7608 -d "{'name': 'Updated Data Source Name', 'description': 'This is cool info', 'refresh_interval': 14400}" ##Example Response: ``` { "meta": { "success": true, "status": 200 }, "data": { } } ``` **Note: Use [Data Source Instances Data](doc:data-source-instances-data) to update the specified data source with data.** [block:api-header] { "type": "delete", "title": "DELETE /datasources/{id}" } [/block] [block:parameters] { "data": { "0-0": "Description", "0-1": "Delete the data source associated with a specific data source ID.", "1-0": "Permissions", "2-0": "Resource URL", "3-0": "Parameters", "1-1": "datasource.delete", "2-1": "https://app.klipfolio.com/api/1.0/datasources/{id}", "3-1": "id={datasource id}" }, "cols": 2, "rows": 4 } [/block] ##Example Request DELETE https://app.klipfolio.com/api/1/datasources/0123456789abcdef0123456789abcdef ##Example Response ``` { "data": {}, "meta": { "status": 200, "success": true } } ```