NodeJS/Typescript
NodeJs Sdk
Installation
npm install npm i @ajent-foundation/typescript-sdk
Usage
import { SessionsApi, PageApi } from "@ajent-foundation/typescript-sdk"
import as dotenv from "dotenv"
// Load environment variables
dotenv.config()
async function main() {
// Setup authentication
const mode = "private"
const apiKeyHeaders = {
"x-api-key-id": process.env.API_KEY_ID,
"x-api-key": process.env.API_KEY
}
const environmentUUID = process.env.ENVIRONMENT_UUID || ""
const environmentSecret = process.env.ENVIRONMENT_SECRET || ""
// Create a new session
const sessionsApi = new SessionsApi()
const session = await sessionsApi.modeV1SessionsPost(mode, {
leaseTime: 5,
isVncEnabled: true,
vncMode: "rw",
driver: "api",
showMouse: true,
isProxyEnabled: false
}, undefined, environmentUUID, environmentSecret, {
headers: apiKeyHeaders
})
// Navigate to a webpage
const pageApi = new PageApi()
await pageApi.modeV1PageGoToPagePost(mode, {
sessionUUID: session.data.sessionUUID,
url: "https://google.com"
}, {
headers: apiKeyHeaders
})
}
NPM
Github
Last updated