Javascript SDK
The Javascript SDK provides typescript bindings for faster dev time. To Install the Javascript SDK Note: Please speak to your customer success contact for additional information on how to access the SDK at this time.
Static
npm install datamilk-sdk
yarn add datamilk-sdk
Dynamic
<script async src=”https://[Contact Customer Success]/datamilk-sdk?apiKey=[API_KEY]”/>
Add the line above to the head of your web page. Fast load time for the library is extremely important and hence MUST be placed in the HEAD directly. Due to the async attribute it will not impact the user experience of the website. Do not use a tag manager for loading the DataMilk script as it will result in SEVERELY worse performance due to latency.
Define a callback that will be called once the script is ready to accept requests.
window.onDataMilkLoad = function () {
// developer can now access the window.dataMilk object which is the API
}
SDK Configuration The following settings can be configured on the JavaScript SDK and passed in to the SDK client when it is created.
export interface DmClientConfig {
apiKey: string;
// URL of end point being used.
serverUrl?: string;
// How many milliseconds for request to timeout.
timeoutMillis?: number;
}
NOTE: The JavaScript SDK will automatically manage api versions by checking with the server for compatibility.