@styley/typescript-sdk v0.0.3
Styley TypeScript SDK
π Table of Contents
- Install Node.js & npm
- Setup Project Workspace
- Install TypeScript & SDK Dependencies
- Environment Variables
- Deployments
- Models
- Summary of Available Methods
Install Node.js & npm
Install Using Official Installer (Recommended)
Go to the Node.js official download page:
π https://nodejs.org/
Download the installer for your operating system:
- Windows: Download the
.msi
file. - MacOS: Download the
.pkg
file. - Linux: Use the pre-built binary or use the package manager for your OS.
- Windows: Download the
Run the installer and follow the instructions.
Verify Installation Check if Node.js and npm are installed and running correctly.
node -v # Check Node.js version
npm -v # Check npm version
Expected output:
v20.5.1 # Example node version
8.5.0 # Example npm version
If you see "command not found", double-check that Node.js is installed and is in your PATH.
Setup Project Workspace
- Create a project directory:
mkdir typescript-sdk-project
cd typescript-sdk-project
- Initialize a new npm project (this creates package.json):
npm init -y
This will create a package.json
file with default values.
Install TypeScript & SDK Dependencies
Install TypeScript globally (optional, but useful for running
tsc
command globally):
npm install -g typescript
- Install Styley TypeScript SDK and other required dependencies locally in your project:
npm install --save-dev typescript
npm install --save @styley/typescript-sdk
- Initialize TypeScript configuration:
npx tsc --init
This creates a tsconfig.json
file in the root of your project, which configures how TypeScript compiles your code.
To run the TypeScript SDK, youβll need a file with TypeScript code.
Create a file called index.ts
in your project directory.
TypeScript Compatibility
This SDK is compatible with TypeScript versions 4.0 and above. Please ensure that your project uses a compatible TypeScript version to avoid any issues.
Environment Variables
To authenticate API requests, you must set the following environment variables in your system.
export X_STYLEY_KEY=***************************
Deployments
π€ Create Deployment
This method creates a new deployment using the specified model ID, name, and arguments.
import { Styley } from '@styley/typescript-sdk';
const styley = new Styley();
async function main() {
const deployment = await styley.deployments.create({
model: '6db33e45-29cf-4880-8ee0-3d9074c32e5e',
name: 'Property Details and Maps',
args: {
"Basement": "false",
"City": "Arlington",
"Garage": "false",
"Pool": "true",
"State": "NY",
},
sync: false,
});
console.log("deployment: ", deployment);
}
π Get Deployment Job
Get the status of a deployment job using its job ID.
import { Styley } from '@styley/typescript-sdk';
const styley = new Styley();
//Change the "job_id" placeholder with actual jobID from the deployment response
const jobStatus = await styley.deployments.getJob("job_id");
console.log("jobStatus: ", jobStatus);
π List Deployments
Retrieve a list of all deployments.
import { Styley } from '@styley/typescript-sdk';
const styley = new Styley();
const deployments = await styley.deployments.list();
console.log("deployments: ", deployments);
Models
π List Models
Retrieve a list of all models available for deployments.
import { Styley } from '@styley/typescript-sdk';
const styley = new Styley();
const models = await styley.models.list();
console.log("models: ", models);
π Get Model By ID
Fetch a specific modelβs details using its model ID.
import { Styley } from '@styley/typescript-sdk';
const styley = new Styley();
const model = await styley.models.getById("6db33e45-29cf-4880-8ee0-3d9074c32e5e");
console.log("model: ", model);
π Get Model By Name
Fetch model details using its name.
import { Styley } from '@styley/typescript-sdk';
const styley = new Styley();
const model = await styley.models.getByName("Property Details and Maps");
console.log("model: ", model);
Summary of Available Methods
Class | Method | Description |
---|---|---|
Deployments | create(payload) | Create a new deployment. |
Deployments | list() | List all deployments. |
Deployments | getJob(jobID) | Get the status of a deployment job. |
Models | list() | List all available models. |
Models | getById(id) | Get model details by model ID. |
Models | getByName(name) | Get model details by model name. |