TypeScript SDK

WARNING

This SDK tool is still working in progress! Currently there has yet to be a stable version release, please feel free to open any issue regarding this SDK in our community repo

#Requirements

  • Node 16+
  • npm 7+ | pnpm 6+ | yarn 1+

#Installation

npm
yarn
pnpm
Copy

npm i instill-sdk

#Usage

next.js
node.js
Copy

import InstillClient from "instill-sdk";

#Configuration

  • baseUrl: string
    • local: http://localhost:8080
    • production: https://api.instill.tech
  • appVersion: string
    • v1alpha
  • apiToken: string
    • local
      • username: admin
      • password: password // This is the initial password, once they login for the first time, they will need to change it to other password
    • production
      • go the setting page and create a api token. https://console.instill.tech/settings

#Connect with Instill Cloud


const client = new InstillClient(
"https://api.instill.tech", // baseUrl
"v1alpha", // appVersion
"<your_api_token>" // get console API token from `https://console.instill.tech/settings`
);

#Connect with Instill Core


const client = new InstillClient(
"http://localhost:8080", // baseUrl
"v1alpha", // appVersion
"<your_api_token>" // get console API token from `http://localhost:3000/settings`
);

#Example Apps

#Connect SDK with Instill Cloud


import { useEffect, useState } from "react";
import InstillClient, { User } from "instill-sdk";
export default function TypescriptSdkDemo() {
const [user, setUser] = useState<User[]>([]);
const client = new InstillClient(
"https://api.instill.tech",
"v1alpha",
"<your_api_token>" // get console API token from `https://console.instill.tech/settings`
);
useEffect(() => {
client.Auth.getUserQuery()
.then((data: any) => {
console.log("data", data);
setUser(data);
})
.catch((error: any) => {
console.log("error", error);
});
}, []);
return (
<>
<h1>User Data</h1>
<pre style={{ backgroundColor: "white" }}>
{JSON.stringify(user, null, 4)}
</pre>
</>
);
}

#Connect with Instill Core

INFO

Make sure you have Instill Core upruning in your local machine. To run the VDP locally please follow our tutorial on VDP


import { useEffect, useState } from "react";
import InstillClient, { User } from "instill-sdk";
export default function TypescriptSdkDemo() {
const [user, setUser] = useState<User[]>([]);
const client = new InstillClient(
"http://localhost:8080",
"v1alpha",
"<your_api_token>" // get console API token from `http://localhost:3000/settings`
);
useEffect(() => {
client.Auth.getUserQuery()
.then((data: any) => {
console.log("data", data);
setUser(data);
})
.catch((error: any) => {
console.log("error", error);
});
}, []);
return (
<>
<h1>User Data</h1>
<pre style={{ backgroundColor: "white" }}>
{JSON.stringify(user, null, 4)}
</pre>
</>
);
}

#Example Templetes

#Next App

#Node App

#API Reference

#Pipelines

FunctionParams
listPipelinesQuerypageSize, nextPageToken
listUserPipelinesQuerypageSize, nextPageToken, userName
getUserPipelineQuerypipelineName
ListUserPipelineReleasesQueryuserName, pipelineName, pageSize, nextPageToken
getUserPipelineReleaseQuerypipelineReleaseName
watchUserPipelineReleaseQuerypipelineReleaseName
createUserPipelineMutationuserName, payload
updateUserPipelineMutationpayload
deleteUserPipelineMutationpipelineName
renameUserPipelineMutationpayload
createUserPipelineReleaseMutationpipelineName, payload
updateUserPipelineReleaseMutationpipelineReleaseName, payload
deleteUserPipelineReleaseMutationpipelineReleaseName
triggerUserPipelineActionpipelineName, payload, returnTraces
triggerAsyncUserPipelineActionpipelineName, payload, returnTraces
setDefaultUserPipelineReleaseMutationpipelineReleaseName
restoreUserPipelineReleaseMutationpipelineReleaseName
triggerUserPipelineReleaseActionpipelineReleaseName, payload, returnTraces
triggerAsyncUserPipelineReleaseActionpipelineReleaseName, payload, returnTraces

#Connector

FunctionParams
listConnectorResourcesQueryuserName, pageSize, nextPageToken, filter
listUserConnectorResourcesQuerypageSize, nextPageToken, filter
listConnectorDefinitionsQueryconnectorDefinitionName
getConnectorDefinitionQueryconnectorDefinitionName
getUserConnectorResourceQueryconnectorDefinitionName
watchUserConnectorResourceuserName, payload
createUserConnectorResourceMutationconnectorDefinitionName
deleteUserConnectorResourceMutationpayload
updateUserConnectorResourceMutationpayload
renameUserConnectorResourcepayload
testUserConnectorResourceConnectionActionconnectorDefinitionName
connectUserConnectorResourceActionconnectorDefinitionName
disconnectUserConnectorResourceActionconnectorDefinitionName

#Metric

FunctionParams
listPipelineTriggerRecordsQuerypageSize, nextPageToken, filter
listTriggeredPipelineQuerypageSize, nextPageToken, filter
listTriggeredPipelineChartQuerypageSize, nextPageToken, filter

modelDefinitionName,

#Model

FunctionParams
getModelDefinitionQuerymodelDefinitionName
listModelDefinitionsQuerypageSize, nextPageToken
getUserModelQuerymodelName
listModelsQuerypageSize, nextPageToken
listUserModelsQueryuserName, pageSize, nextPageToken
getUserModelReadmeQuerymodelName
watchUserModelmodelName
createUserModelMutationuserName, payload
updateModelMutationpayload
deleteUserModelMutationmodelName
deployUserModelActionmodelName
undeployUserModeleActionmodelName

#Operation

FunctionParams
getOperationQueryoperationName
checkUntilOperationIsDoenoperationName

#Mgmt

FunctionParams
getUserQueryapiToken
checkUserIdExistid
getApiTokenQuerytokenName
listApiTokensQuerypageSize, nextPageToken
updateUserMutationpayload
createApiTokenMutationpayload
deleteApiTokenMutationtokenName

#Generate proto-ts


./generate_proto.sh

It will genrate protobuf into dist/protogen-ts folder

Last updated: 1/31/2024, 5:42:53 PM