If you have not done so already, contact us to get your API access credentials.
Before your applications can use the TouchPointCare API, you must first authenticate your credentials with the TouchPointCare platform. Once you successfully authenticate, you will receive an authorization token. This token will then be used in each interface call as your "key".
To authenticate, you most post your credentials via an HTML form with the field names of "username" & "password". You must also set a field with the "grant_type" set to "password". Typically this will be completed using the programming language of your choice. Below are code examples for sending credentials to TouchPointCare using Microsoft C# as well as JavaScript with jQuery.
Below is sample code that can be used to authenticate your credentials with TouchPointCare and receive your authorization token. This code sample uses the Microsoft WebRequest and WebResponse objects to call the remote TouchPointCare system and receive a response back. This is similar to the "curl" functionality in the PHP programming language.
// Set the authorization enpoint
String uri = "https://api.touchpointcare.net/authtoken"; // Note that https is required
// Create the Web Request object
WebRequest req = WebRequest.Create(uri);
req.Method = "POST"; // Must be POST
req.ContentType = "application/x-www-form-urlencoded";
// Set your authorization credentials, insert your username and password below...
String AuthBody = "username=" + "YOUR API USERNAME" + "&password=" + "YOUR API PASSWORD" + "&grant_type=password";
// Write the credentials string to the HTML body
byte[] RequestBytes = Encoding.UTF8.GetBytes(AuthBody);
req.ContentLength = RequestBytes.Length;
// Get the response
using (var requestStream = req.GetRequestStream())
{
requestStream.Write(RequestBytes, 0, RequestBytes.Length);
requestStream.Close();
}
HttpWebResponse response = (HttpWebResponse)req.GetResponse();
Stream streamResponse = response.GetResponseStream();
StreamReader StreamRead = new StreamReader(streamResponse);
// Read the response into a string
String ResponseText = StreamRead.ReadToEnd();
// From here, you can use a JSON parsing library to read the authorization token
Test your credentials using Authorization Management Tool.
Now that you have the authorization token, you can begin to use the TouchPointCare API. The authorization token must be included in every call to the TouchPointCare API or you will receive an unauthorized response.
Below is sample code using C# top pass the authorization token to call the TouchPointCare API and receive the response.
String uri = "https://api.touchpointcare.net/api/series"
WebRequest req = WebRequest.Create(uri);
req.Method = "GET";
req.Headers.Add("authorization", "bearer " + AuthToken);
HttpWebResponse response = (HttpWebResponse)req.GetResponse();
Stream streamResponse = response.GetResponseStream();
StreamReader StreamRead = new StreamReader(streamResponse);
String ResponseText = StreamRead.ReadToEnd();
Click here to see an example of retrieving data from the TouchPointCare API.
Coming Soon!
More functionality will be continuously added. Check the full API reference for details.