{"_id":"56d1f33f00a2a70b00b365e9","category":{"_id":"56d1f33900a2a70b00b36598","pages":["56d1f33f00a2a70b00b365e9","56d1f33f00a2a70b00b365ea","56d1f33f00a2a70b00b365eb","56d1f33f00a2a70b00b365ec","56d1f33f00a2a70b00b365ed"],"project":"5526c95cf69851170038b48f","__v":1,"version":"56d1f33700a2a70b00b3658e","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-04-20T16:08:19.335Z","from_sync":false,"order":7,"slug":"rest-api","title":"API"},"__v":1,"user":"5564b8233b87582b003ab99b","project":"5526c95cf69851170038b48f","parentDoc":null,"version":{"_id":"56d1f33700a2a70b00b3658e","project":"5526c95cf69851170038b48f","__v":2,"createdAt":"2016-02-27T19:04:23.946Z","releaseDate":"2016-02-27T19:04:23.946Z","categories":["56d1f33900a2a70b00b3658f","56d1f33900a2a70b00b36590","56d1f33900a2a70b00b36591","56d1f33900a2a70b00b36592","56d1f33900a2a70b00b36593","56d1f33900a2a70b00b36594","56d1f33900a2a70b00b36595","56d1f33900a2a70b00b36596","56d1f33900a2a70b00b36597","56d1f33900a2a70b00b36598","56d1f33900a2a70b00b36599","56d1f33900a2a70b00b3659a","571f9497ada30c34003b7cee"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"beta","version_clean":"2.0.0-beta","version":"2.0.0-beta"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-02-25T14:58:27.205Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"The Ionic REST API is the backbone of the Ionic Platform.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"Unless otherwise noted, all data is sent to and from the API via JSON in HTTP request and response bodies.\"\n}\n[/block]\n## Authentication\n\nThe Ionic API requires token-based authentication on all endpoints, unless otherwise noted. Tokens are plaintext and should be stored securely. HTTPS is required on all endpoints.\n\n### Creating a Token\n\nTo begin, you'll need to login to [apps.ionic.io](https://apps.ionic.io) and go to **Settings** -> **API Keys**. Under **API Tokens**, create a new token and give it a name.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Token Type\",\n  \"body\": \"The token you are creating in this interface is an *app* token, or a token unique to your app.\"\n}\n[/block]\nNext, click **show token** to reveal the actual token, and copy it.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/460xizUGQbqLDoWZp0BE_Screen%20Shot%202016-02-25%20at%209.29.00%20AM.png\",\n        \"Screen Shot 2016-02-25 at 9.29.00 AM.png\",\n        \"2450\",\n        \"1526\",\n        \"#f25563\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n### Using a Token\n\nThe token must be passed along in the HTTP header **Authorization**, prefixed by the string \"Bearer \", such as:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI0NTIyNmRlNy1jNDVkLTRhYzEtOTU3MS0xNGJhNjIzMGJmOTMifQ.pj3_57nFne3bvo9KYJGHTbZQ9MTszsjSPD_ZCjieFcU\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\nYou can test your token with cURL:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -H \\\"Authorization: Bearer [YOUR_TOKEN]\\\" https://api.ionic.io/auth/test\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\nUpon successful authentication, you should see the success message \"You have successfully made an authenticated request to the Ionic Platform API.\"\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/MBul4hx2TF2kS730IJTw_Screen%20Shot%202016-02-25%20at%209.55.40%20AM.png\",\n        \"Screen Shot 2016-02-25 at 9.55.40 AM.png\",\n        \"1602\",\n        \"724\",\n        \"#6fa3bd\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"success\",\n  \"body\": \"Cool! You're authenticated. Now let's move on to some [conventions](doc:api-conventions) of the API.\"\n}\n[/block]","excerpt":"","slug":"api-getting-started","type":"basic","title":"Getting Started"}
The Ionic REST API is the backbone of the Ionic Platform. [block:callout] { "type": "info", "body": "Unless otherwise noted, all data is sent to and from the API via JSON in HTTP request and response bodies." } [/block] ## Authentication The Ionic API requires token-based authentication on all endpoints, unless otherwise noted. Tokens are plaintext and should be stored securely. HTTPS is required on all endpoints. ### Creating a Token To begin, you'll need to login to [apps.ionic.io](https://apps.ionic.io) and go to **Settings** -> **API Keys**. Under **API Tokens**, create a new token and give it a name. [block:callout] { "type": "info", "title": "Token Type", "body": "The token you are creating in this interface is an *app* token, or a token unique to your app." } [/block] Next, click **show token** to reveal the actual token, and copy it. [block:image] { "images": [ { "image": [ "https://files.readme.io/460xizUGQbqLDoWZp0BE_Screen%20Shot%202016-02-25%20at%209.29.00%20AM.png", "Screen Shot 2016-02-25 at 9.29.00 AM.png", "2450", "1526", "#f25563", "" ] } ] } [/block] ### Using a Token The token must be passed along in the HTTP header **Authorization**, prefixed by the string "Bearer ", such as: [block:code] { "codes": [ { "code": "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI0NTIyNmRlNy1jNDVkLTRhYzEtOTU3MS0xNGJhNjIzMGJmOTMifQ.pj3_57nFne3bvo9KYJGHTbZQ9MTszsjSPD_ZCjieFcU", "language": "text" } ] } [/block] You can test your token with cURL: [block:code] { "codes": [ { "code": "curl -H \"Authorization: Bearer [YOUR_TOKEN]\" https://api.ionic.io/auth/test", "language": "shell" } ] } [/block] Upon successful authentication, you should see the success message "You have successfully made an authenticated request to the Ionic Platform API." [block:image] { "images": [ { "image": [ "https://files.readme.io/MBul4hx2TF2kS730IJTw_Screen%20Shot%202016-02-25%20at%209.55.40%20AM.png", "Screen Shot 2016-02-25 at 9.55.40 AM.png", "1602", "724", "#6fa3bd", "" ] } ] } [/block] [block:callout] { "type": "success", "body": "Cool! You're authenticated. Now let's move on to some [conventions](doc:api-conventions) of the API." } [/block]