{"_id":"589255ee3e57ea0f00071805","parentDoc":null,"project":"563a252d50bf950d00e09798","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":"57d1da1665042a17006686d5","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"},"__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-02-01T21:41:02.028Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"**Creating a new Facebook data source**\n\nCreate a new Facebook data source using the POST  ` /datasources method`. \n\n**Note:** In this instance, you need to find the oauth_user_token from your Facebook account. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl https://app.klipfolio.com/api/1/datasources -X POST -d \\\"{'name':'<datasource name>', \\n'description':'<datasource description>', 'connector':'facebook', 'format':'json',\\n'refresh_interval':14400,\\n'properties':{'endpoint_url':\\n'https:\\\\/\\\\/graph.facebook.com\\\\/me', 'oauth_user_token':'<XXX>',\\n'oauth_provider_id':'facebook20'}}\\n\\\" --header \\\"kf-api-key:<apikey>\\\"  -H Content-Type:application/json\",\n      \"language\": \"curl\"\n    }\n  ]\n}\n[/block]\n\n**Uploading a file to an existing datasource**\n\nPUT data to upload a file to an existing datasource using --upload-file. This example is using JSON.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl https://app.klipfolio.com/api/1/datasource-instances/0123456789abcdef0123456789abcdef/data -X PUT --upload-file  revenue_date.json --header \\\"kf-api-key:01234df230c488e9c5c18862a8967df5ab367c6e\\\" -H Content-Type:application/json\",\n      \"language\": \"curl\"\n    }\n  ]\n}\n[/block]\n**Creating a data source using the REST/URL connector**\n\nCreate a data source using our REST/URL connector that connects to any service, even if it is not listed as one of our Service Connectors.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl https://app.klipfolio.com/api/1/datasources -X POST -d \\n{\\n\\t\\\"name\\\": \\\"TESTPostman POST Klipfolio API\\\",\\n\\t\\\"description\\\": \\\"Post man test\\\",\\n\\t\\\"connector\\\": \\\"simple_rest\\\",\\n\\t\\\"format\\\": \\\"json\\\",\\n\\t\\\"refresh_interval\\\": 14400,\\n\\t\\\"properties\\\": {\\n  \\t\\\"endpoint_url\\\": \\\"https://yourUniqueEndpoint.com/api/values\\\",\\n  \\t\\\"method\\\": \\\"get\\\",\\n  \\t\\\"parameters\\\": \\\"[{\\\\\\\"name\\\\\\\":\\\\\\\"x-api-\\t\\tkey\\\\\\\",\\\\\\\"value\\\\\\\":\\\\\\\"1aBCDefgHi2JkLmnOpqrs3TuvwX4yZAB5CdE67fg\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"header\\\\\\\"]\\\",\\n\\t}\\n}\",\n      \"language\": \"curl\"\n    }\n  ]\n}\n[/block]","excerpt":"This page will help you get started with common API calls.","slug":"api-call-examples","type":"basic","title":"API Call Examples"}

API Call Examples

This page will help you get started with common API calls.

**Creating a new Facebook data source** Create a new Facebook data source using the POST ` /datasources method`. **Note:** In this instance, you need to find the oauth_user_token from your Facebook account. [block:code] { "codes": [ { "code": "curl https://app.klipfolio.com/api/1/datasources -X POST -d \"{'name':'<datasource name>', \n'description':'<datasource description>', 'connector':'facebook', 'format':'json',\n'refresh_interval':14400,\n'properties':{'endpoint_url':\n'https:\\/\\/graph.facebook.com\\/me', 'oauth_user_token':'<XXX>',\n'oauth_provider_id':'facebook20'}}\n\" --header \"kf-api-key:<apikey>\" -H Content-Type:application/json", "language": "curl" } ] } [/block] **Uploading a file to an existing datasource** PUT data to upload a file to an existing datasource using --upload-file. This example is using JSON. [block:code] { "codes": [ { "code": "curl https://app.klipfolio.com/api/1/datasource-instances/0123456789abcdef0123456789abcdef/data -X PUT --upload-file revenue_date.json --header \"kf-api-key:01234df230c488e9c5c18862a8967df5ab367c6e\" -H Content-Type:application/json", "language": "curl" } ] } [/block] **Creating a data source using the REST/URL connector** Create a data source using our REST/URL connector that connects to any service, even if it is not listed as one of our Service Connectors. [block:code] { "codes": [ { "code": "curl https://app.klipfolio.com/api/1/datasources -X POST -d \n{\n\t\"name\": \"TESTPostman POST Klipfolio API\",\n\t\"description\": \"Post man test\",\n\t\"connector\": \"simple_rest\",\n\t\"format\": \"json\",\n\t\"refresh_interval\": 14400,\n\t\"properties\": {\n \t\"endpoint_url\": \"https://yourUniqueEndpoint.com/api/values\",\n \t\"method\": \"get\",\n \t\"parameters\": \"[{\\\"name\\\":\\\"x-api-\t\tkey\\\",\\\"value\\\":\\\"1aBCDefgHi2JkLmnOpqrs3TuvwX4yZAB5CdE67fg\\\",\\\"type\\\":\\\"header\\\"]\",\n\t}\n}", "language": "curl" } ] } [/block]