⚒ī¸API: Get started

Get started using the saaster API

The API of saaster provides the oppurtunity to use the functionality of saaster in other application. To use the API of saaster you need to create one. Follow this guide for this process:

⛓ī¸API Settings

We have chosen to use custom headers for passing additional parameters like the customerID and language etc. This approach offers a number of benefits when compared to using path parameters or query parameters. By using headers, we can add new parameters to the API without modifying the endpoint itself, making it more flexible for different use cases. Additionally, custom headers are not visible in the URL, ensuring that sensitive information such as user IDs or authentication tokens can be passed securely without being exposed in the URL. This approach also keeps the URL clean and easy to read, making it easier to understand the purpose of the endpoint.

First steps

In order to use the saaster API, you need to follow these steps:

  1. Generate an access token. Example:

    curl -X GET \
       http://localhost/api/authenticate \
       -H 'Accept: application/json' \
       -H 'apiID: 1' \
       -H 'apiKey: 1c1932d0-81da-4ad0-93bd-5ca03002f17e' \
  2. Use the access token to create a request to the saaster API. The example below fetches the current plan of a customer:

    curl -X GET \
       http://localhost/api/getPlanFeatureSetting \
       -H 'Accept: application/json' \
       -H 'Authorization: Bearer {access-token}' \
       -H 'customerID: 1' \

    Make sure to replace {access-token} with the token you received in Step 1.

CFML example:

// Change values to your API
apiID = 1
apiKey = "YourOwnKey"

// Authenticate with API and get token
cfhttp(method="get", charset="utf-8", url="http://localhost/api/authenticate", result="getToken") {
    cfhttpparam(name="Content-Type", type="header", value="application/json");
    
    // Custom saaster related header variables
    cfhttpparam(name="apiID", type="header", value="#apiID#");
    cfhttpparam(name="apiKey", type="header", value="#apiKey#");
}

token = DeserializeJSON(getToken.filecontent).token;

cfhttp(method="get", charset="utf-8", url="http://localhost/api/getPlanFeatureSetting", result="getPlanFeatureSettings") {
    
    cfhttpparam(name="Authorization", type="header", value="Bearer #token#");
    cfhttpparam(name="Content-Type", type="header", value="application/json");

    // Custom saaster related header variables
    cfhttpparam(name="settingVariable", type="header", value="YourVariableName");
    cfhttpparam(name="planID", type="header", value="1");
    cfhttpparam(name="language", type="header", value="en");
}

dump( var=getPlanFeatureSettings.filecontent, label="getPlanFeatureSettings");

Last updated