### Install Autotab SDK for Node.js Source: https://docs.autotab.com/api-reference/quickstart This snippet demonstrates how to install the Autotab SDK package using npm, enabling programmatic interaction with Autotab services in Node.js applications. ```javascript npm install autotab ``` -------------------------------- ### Execute and Retrieve Autotab Skill Run in Node.js Source: https://docs.autotab.com/api-reference/quickstart This example illustrates how to programmatically start an Autotab skill execution and retrieve its result using the Node.js SDK. It requires an API key for authentication and a specific skill ID to initiate the run. ```javascript import { Configuration, RunApi } from 'autotab'; const runClient = new RunApi(new Configuration({ apiKey: process.env['AUTOTAB_API_KEY'], })); async function main() { const run = await runClient.start({ runSkillRequest: { skillId: "skill_fe517503-384a-45c5-87a3-94f98126e626" } }); console.log("result:", await runClient.retrieve({ id: run.id })) } main(); ``` -------------------------------- ### Run Autotab Skill using Node.js SDK Source: https://docs.autotab.com/api-reference Demonstrates how to initialize the Autotab Run API client, start a skill execution, and retrieve its result using the Node.js SDK. This example requires an API key set as an environment variable and a specific skill ID. ```javascript import { Configuration, RunApi } from 'autotab'; const runClient = new RunApi(new Configuration({ apiKey: process.env['AUTOTAB_API_KEY'], })); async function main() { const run = await runClient.start({ runSkillRequest: { skillId: "skill_fe517503-384a-45c5-87a3-94f98126e626" } }); console.log("result:", await runClient.retrieve({ id: run.id })) } main(); ``` -------------------------------- ### Install Autotab npm package Source: https://docs.autotab.com/api-reference Installs the Autotab SDK for Node.js projects using npm, providing access to Autotab's API functionalities. ```javascript npm install autotab ``` -------------------------------- ### Start Autotab Skill Run using JavaScript SDK Source: https://docs.autotab.com/api-reference/run/start This snippet demonstrates how to initiate a skill run using the Autotab JavaScript SDK. It configures the API client with an API key from environment variables and calls the `start` method with a specific `skillId` to execute a skill, then logs the result. ```JavaScript import { Configuration, RunApi } from 'autotab'; const runClient = new RunApi(new Configuration({ apiKey: process.env['AUTOTAB_API_KEY'], })); async function main() { const run = await runClient.start({ runSkillRequest: { skillId: "skill_fe517503-384a-45c5-87a3-94f98126e626" } }); console.log("result:", run); } main(); ``` -------------------------------- ### Python Client Example for Listing Autotab Skills Source: https://docs.autotab.com/api-reference/skill/list This Python code snippet demonstrates how to use the Autotab Python client to authenticate with an API key and retrieve a list of skills. It includes error handling for API exceptions. ```Python import autotab from autotab.rest import ApiException client = autotab.Client( autotab.Configuration( api_key = os.environ["AUTOTAB_API_KEY"] ) ) try: skills = await autotab.SkillApi(client).list() print(f"skills: {\"\n\".join([skill.model_dump_json(indent=2) for skill in skills])}") except ApiException as e: print(f"Exception: {e})") ``` -------------------------------- ### Handle Autotab Webhook Events with Node.js Express Source: https://docs.autotab.com/api-reference/webhooks This Node.js Express server example demonstrates how to set up an endpoint to receive and process Autotab webhook events. It includes robust signature verification using `crypto` to ensure the authenticity of incoming requests and handles different run session states (FINISH, CANCEL, TIMEOUT). The setup requires `express`, `body-parser`, `crypto`, `dotenv`, and the `autotab` SDK. ```node import express, { Request, Response } from 'express'; import bodyParser from 'body-parser'; import crypto from 'crypto'; import dotenv from 'dotenv'; import autotab, { RunSession, RunSessionState } from 'autotab'; dotenv.config(); const WEBHOOK_SECRET = process.env.AUTOTAB_WEBHOOK_SECRET; const app = express(); app.use(bodyParser.raw({ type: 'application/json' })); app.post("/webhook/autotab", async (req: Request, res: Response) => { const signature = req.headers['autotab-signature'] as string | undefined; if (!verifySignature(req.body, signature)) { return res.status(401).json({ error: "Invalid signature" }); } try { const runSession: RunSession = JSON.parse(req.body.toString()); switch (runSession.state) { case RunSessionState.FINISH: await handleSessionCompleted(runSession); break; case RunSessionState.CANCEL: await handleSessionFailed(runSession); break; case RunSessionState.TIMEOUT: await handleSessionTimedOut(runSession); break; default: console.warn(`Unhandled event type: ${runSession.event}`); } res.json({ status: "success" }); } catch (e) { console.error("Error processing webhook:", e); res.status(500).json({ error: e.message }); } }); function verifySignature(requestBody: Buffer, signature: string | undefined): boolean { if (!signature || !WEBHOOK_SECRET) { return false; } const expectedSignature = crypto.createHmac('sha256', WEBHOOK_SECRET) .update(requestBody) .digest('hex'); return crypto.timingSafeEqual(Buffer.from(expectedSignature), Buffer.from(signature)); } const PORT = process.env.PORT || 3000; app.listen(PORT, () => { console.log(`Server running on port ${PORT}`); }); ``` -------------------------------- ### Autotab Run API: Start Skill Execution Endpoint Source: https://docs.autotab.com/api-reference/run/start Comprehensive documentation for the Autotab API's `POST /run/start` endpoint, detailing how to initiate a skill execution. It specifies the required authorization header, the structure of the JSON request body, and the schema of the successful `RunSession` response, along with common error codes. ```APIDOC POST /run/start Description: Initiates a new skill run. Authorization: - Type: Header - Name: Authorization - Type: string - Required: true - Description: Your Autotab API key. Request Body (application/json): runSkillRequest: object skillId: string (required) Description: The unique identifier of the skill to execute. Responses: 200 OK: Description: Successful Response. A RunSession object detailing the initiated run. Schema: id: skill_id: owner: created_at: "2023-11-07T05:31:56Z" (ISO 8601 datetime) environment: start_time: "2023-11-07T05:31:56Z" (ISO 8601 datetime) end_time: "2023-11-07T05:31:56Z" (ISO 8601 datetime) state: Example: { "id": "", "skill_id": "", "owner": "", "created_at": "2023-11-07T05:31:56Z", "environment": "client", "start_time": "2023-11-07T05:31:56Z", "end_time": "2023-11-07T05:31:56Z", "state": "play" } 404 Not Found: Description: The requested resource was not found. 422 Unprocessable Entity: Description: The request was well-formed but unable to be processed due to semantic errors. ``` -------------------------------- ### List Skills API Endpoint Reference Source: https://docs.autotab.com/api-reference/skill/list Detailed API documentation for the GET /skill/list endpoint, which retrieves a list of available skills. It specifies the HTTP method, path, required authorization, and the structure of successful and error responses. ```APIDOC GET /skill/list Authorization: - Type: header - Name: Authorization - Required: true - Description: Your Autotab API key Responses: - Status: 200 Description: Successful Response Content-Type: application/json Schema: Skill[] Example: [ { "id": "", "name": "", "description": "", "owner": "", "created_at": "2023-11-07T05:31:56Z", "last_modified_at": "2023-11-07T05:31:56Z", "inputs": [] } ] - Status: 404 Description: Not Found ``` -------------------------------- ### API Reference for Autotab Skill Retrieve Endpoint Source: https://docs.autotab.com/api-reference/skill/retrieve Comprehensive documentation for the Autotab Skill Retrieve API endpoint. It specifies the HTTP method, path, required authorization, path parameters, and the structure of successful and error responses, including an example JSON payload for a successful retrieval. ```APIDOC GET /skill/{id} - Description: Retrieves a specific Autotab Skill by its unique identifier. Authorizations: - Authorization: string (header, required) - Description: Your Autotab API key. Path Parameters: - id: string (required) - Description: The unique identifier of the skill to retrieve. Responses: - 200 OK (application/json): Successful Response - Description: The retrieved Skill object. - Schema: { "id": "", "name": "", "description": "", "owner": "", "created_at": "2023-11-07T05:31:56Z", "last_modified_at": "2023-11-07T05:31:56Z", "inputs": [] } - 404 Not Found - 422 Unprocessable Entity ``` -------------------------------- ### Retrieve Autotab Run Session using JavaScript Source: https://docs.autotab.com/api-reference/run/retrieve This JavaScript example demonstrates how to use the Autotab SDK to retrieve a specific run session by its ID. It initializes the API client with an API key from environment variables and then calls the `retrieve` method on the `RunApi` instance. ```JavaScript import { Configuration, RunApi } from 'autotab'; const runClient = new RunApi(new Configuration({ apiKey: process.env['AUTOTAB_API_KEY'], })); async function main() { const run = await runClient.retrieve({ id: "run_344ed4ce-6c14-4b13-96b5-3bbb2000c2e5" }); } main(); ``` -------------------------------- ### Autotab API: GET /run/list Endpoint Reference Source: https://docs.autotab.com/api-reference/run/list Comprehensive documentation for the Autotab API endpoint used to retrieve a list of run sessions. This entry details the HTTP method, endpoint path, required authorization header, available query parameters for filtering results, and the structure of a successful JSON response. ```APIDOC GET /run/list Authorization: - Name: Authorization - Type: string - Location: header - Required: true - Description: Your Autotab API key Query Parameters: - Name: skill_id - Type: string | null - Description: The skill to list run sessions for - Name: state_filter - Type: enum[] | null - Description: The state filter to list run sessions for Response (200 OK): - Content-Type: application/json - Type: RunSession[] - Description: Successful Response - Example: [ { "id": "", "skill_id": "", "owner": "", "created_at": "2023-11-07T05:31:56Z", "environment": "client", "start_time": "2023-11-07T05:31:56Z", "end_time": "2023-11-07T05:31:56Z", "state": "play" } ] ``` -------------------------------- ### Autotab Run Session Retrieval API Endpoint Source: https://docs.autotab.com/api-reference/run/retrieve Comprehensive API documentation for the GET /run/{id} endpoint, used to retrieve details of a specific Autotab run session. It outlines required authorization, path parameters, and the structure of successful and error responses, including a sample JSON payload for a successful retrieval. ```APIDOC GET /run/{id} - Description: Retrieves details of a specific Autotab run session by its ID. Authorizations: - Name: Authorization Type: Header Required: true Description: Your Autotab API key. Path Parameters: - Name: id Type: string Required: true Description: The unique identifier of the run session. Responses: - Status: 200 OK Content-Type: application/json Description: Successful Response, returning the run session data. Schema: object (RunSessionWithData or Response Retrieve) Example Body: { "id": "", "skill_id": "", "owner": "", "created_at": "2023-11-07T05:31:56Z", "environment": "client", "start_time": "2023-11-07T05:31:56Z", "end_time": "2023-11-07T05:31:56Z", "state": "play", "inputs": {}, "data": {} } - Status: 404 Not Found Description: The specified run session ID was not found. - Status: 422 Unprocessable Entity Description: Invalid request parameters or format. ``` -------------------------------- ### List Autotab Runs using JavaScript SDK Source: https://docs.autotab.com/api-reference/run/list This JavaScript code snippet demonstrates how to use the Autotab SDK to list all available runs. It initializes the `RunApi` client with an API key, typically sourced from environment variables, and then asynchronously calls the `list()` method to fetch and log the runs. ```JavaScript import { Configuration, RunApi } from 'autotab'; const runClient = new RunApi(new Configuration({ apiKey: process.env['AUTOTAB_API_KEY'], })); async function main() { const runs = await runClient.list(); console.log("runs:", runs); } main(); ``` -------------------------------- ### Retrieve Autotab Skill using Python Client Source: https://docs.autotab.com/api-reference/skill/retrieve Demonstrates how to retrieve an Autotab Skill using the official Python client library. It shows client initialization with an API key from environment variables, making the asynchronous API call, and handling potential exceptions during the process. ```Python import autotab from autotab.rest import ApiException import os client = autotab.Client( autotab.Configuration( api_key = os.environ["AUTOTAB_API_KEY"] ) ) try: skill = await autotab.SkillApi(client).retrieve( id="skill_923d8f38-be0d-4637-9fbe-46ec9cb48312" ) print(f"skill: {skill.model_dump_json(indent=2)}") except ApiException as e: print(f"Exception: {e}") ``` -------------------------------- ### Cancel Autotab Run using Python SDK Source: https://docs.autotab.com/api-reference/run/cancel Demonstrates how to programmatically cancel an Autotab run using the official Python SDK. It initializes the client with an API key from environment variables and calls the `cancel` method on the `RunApi` instance, handling potential API exceptions. ```Python import autotab from autotab.rest import ApiException from pprint import pprint client = autotab.Client( autotab.Configuration( api_key = os.environ["AUTOTAB_API_KEY"] ) ) try: await autotab.RunApi(client).cancel( id="run_344ed4ce-6c14-4b13-96b5-3bbb2000c2e5" ) except ApiException as e: print(f"Exception: {e}) ``` -------------------------------- ### Autotab Run Cancellation API Endpoint (POST /run/{id}/cancel) Source: https://docs.autotab.com/api-reference/run/cancel Comprehensive documentation for the Autotab API endpoint used to cancel an existing run. It specifies the HTTP method, path parameters, required authorization, and possible HTTP response codes with their respective content types and descriptions. ```APIDOC POST /run/{id}/cancel Description: Cancels an existing Autotab run. Authorizations: Authorization: Type: string Location: header Required: true Description: Your Autotab API key Path Parameters: id: Type: string Required: true Description: The unique identifier of the run to cancel. Responses: 200 OK: Content-Type: application/json Description: Successful Response. The response body is of type string. Example: "" 404 Not Found: Description: The specified run ID was not found. The response body is of type string. Example: "" 422 Unprocessable Entity: Description: Invalid input or request. The response body is of type null. Example: "null" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.