Sdks
TypeScript Client Guide
Build scalable TypeScript workflows against the Datafuse v1 integration routes.
The TypeScript examples below use fetch to call the same routes that power the app. They work well in Node.js, serverless functions, and front-end tooling that already has a fetch runtime.
1. Initialization
const baseUrl = process.env.DATAFUSE_API_URL || 'https://api.datafuse.xyz'
const token = process.env.DF_TOKEN || ''
const headers = {
Authorization: `Bearer ${token}`
}
2. Discover Integrations
const integrations = await fetch(baseUrl + '/api/v1/integrations', {
headers
}).then((response) => response.json())
for (const integration of integrations.items ?? []) {
console.log(`${integration.id}: ${integration.provider_key}`)
}
3. Resolve and Invoke
const integrationId = integrations.items?.[0]?.id
const tools = await fetch(baseUrl + `/api/v1/integrations/${integrationId}/resolve-tools`, {
method: 'POST',
headers
}).then((response) => response.json())
const toolKey = tools[0]?.slug
const response = await fetch(baseUrl + `/api/v1/integrations/${integrationId}/invoke`, {
method: 'POST',
headers: {
...headers,
'Content-Type': 'application/json'
},
body: JSON.stringify({
tool_key: toolKey,
arguments: {
channel: '#engineering',
text: 'Deployment is complete and staging is ready for validation.'
}
})
}).then((result) => result.json())
console.log(response.successful)
console.log(response.data)
Next Steps
- Review the Client Overview for the shared route surface.
- Open the Python client guide if your app uses Python workers or notebooks.
- Use the curl quickstart if you want the same flow from the terminal.