This is the official Node.js SDK for journy.io.
You can use your package manager (npm
or yarn
) to install the SDK:
npm install --save @journyio/sdk
or
yarn add @journyio/sdk
To start, first import the client.
import { Client } from "@journyio/sdk";
To be able to use the journy.io SDK you need to generate an API key. If you don't have one you can create one in journy.io.
If you don't have an account yet, you can create one in journy.io or request a demo first.
Go to your settings, under the Connections-tab, to create and edit API keys. Make sure to give the correct permissions to the API Key.
const client = Client.withDefaults("your-api-key");
If you want to use a custom HttpClient:
const http = new OwnHttpClientImplementation();
const client = new Client(http, { apiKey: "your-api-key" });
const result = await client.getApiKeyDetails();
if (result.success) {
console.log(result.data.permissions); // string[]
console.log(result.callsRemaining); // number
}
Every call will return a result, we don't throw errors when a call fails. We don't want to break your application when things go wrong. An exception will be thrown for required arguments that are empty or missing.
You can check whether the call succeeded using result.success
:
const result = await client.getTrackingSnippet({
domain: "www.journy.io",
});
if (!result.success) {
console.log(result.error); // string
console.log(result.requestId); // string
}
await client.getTrackingSnippet({
domain: "", // empty string will throw
});
The request ID can be useful when viewing API logs in journy.io.
To run the tests:
npm run test
We welcome your feedback, ideas and suggestions. We really want to make your life easier, so if we’re falling short or should be doing something different, we want to hear about it.
Please create an issue or contact us via the chat on our website.
If you discover any security related issues, please email security at journy io instead of using the issue tracker.