SDKs
Overview
Get started with setting up your Tensor One projects using JavaScript. Whether you're building web applications, server-side implementations, or automating tasks, the Tensor One JavaScript SDK provides the tools you need. This guide outlines the steps to get your development environment ready and integrate Tensor One into your JavaScript projects.
Install the Tensor One SDK
Before integrating Tensor One into your project, you'll need to install the SDK. Using Node.js and npm (Node Package Manager) simplifies this process. Ensure you have Node.js and npm installed on your system before proceeding.
To install the Tensor One SDK, run the following npm command in your project directory.
npm install --save tensorone-sdk
# or
yarn add tensorone-sdk
This command installs the tensorone-sdk
package and adds it to your project's package.json
dependencies.
Add your API key
To use the Tensor One SDK in your project, you first need to import it and configure it with your API key and endpoint ID. Ensure these values are securely stored, preferably as environment variables.
Below is a basic example of how to initialize and use the Tensor One SDK in your JavaScript project.
import tensoroneSdk from 'tensorone-sdk'
const { TENSORONE_API_KEY, ENDPOINT_ID } = process.env
const tensorone = tensoroneSdk(TENSORONE_API_KEY)
const endpoint = tensorone.endpoint(ENDPOINT_ID)
This snippet demonstrates how to import the SDK, initialize it with your API key, and reference a specific endpoint using its ID. Remember, the Tensor One SDK uses the ES Module (ESM) system and supports asynchronous operations, making it compatible with modern JavaScript development practices.
Secure your API key
When working with the Tensor One SDK, it's essential to secure your API key. Storing the API key in environment variables is recommended, as shown in the initialization example. This method keeps your key out of your source code and reduces the risk of accidental exposure.
Note Use environment variables or secure secrets management solutions to handle sensitive information like API keys.
For further information, see Endpoints