SDKs
Javascript
How to Use the Tensor One JavaScript SDK
You can use the Tensor One JavaScript SDK to create web applications, automate processes, or incorporate server-side logic through the Tensor One API.
1. Set up the Tensor One SDK.
Verify that npm (or Yarn) and Node.js are installed on your computer. Next, install the SDK by executing:
npm install --save tensorone-sdk
# or
yarn add tensorone-sdk
Tensorone-sdk is now included in your package.dependencies in JSON.
2. Add Your API Key
To use the SDK, import it and configure it using your API key and endpoint ID. It’s recommended to store these credentials securely using environment variables.
Example:
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 code:
- Imports the SDK
- Initializes the client using your API key
- Prepares a reference to the specified endpoint
Note: Tensor One SDK uses ES Modules (ESM) and supports asynchronous operations.
3. Secure Your API Key
API keys should never be hardcoded. Use .env
files or secret management tools to protect sensitive credentials.
Best Practice: Set your API key in a
.env
file and usedotenv
to load it at runtime.
4. Learn More
For details on endpoint interaction and advanced SDK features, see Javascript Endpoints.