//native
/**
* Create batch tasks
* Queue up to 100 search, fetch or research calls to run asynchronously in one request. Poll each returned task with Get task.
*/
export async function main(
auth: RT.Linkup,
tasks: {
type: "search" | "fetch" | "research"
input: { [key: string]: any }
}[]
) {
const url = new URL("https://api.linkup.so/v1/tasks")
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${auth.token}`,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify(tasks),
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 3 hours ago