//native
type Assemblyai = {
apiKey: string;
};
/**
* List transcripts
* Retrieve a list of transcripts you created.
Transcripts are sorted from newest to oldest. The previous URL always points to a page with older transcripts.
*/
export async function main(
auth: Assemblyai,
limit: string | undefined,
status: "queued" | "processing" | "completed" | "error" | undefined,
created_on: string | undefined,
before_id: string | undefined,
after_id: string | undefined,
throttled_only: string | undefined,
) {
const url = new URL(`https://api.assemblyai.com/v2/transcript`);
for (const [k, v] of [
["limit", limit],
["status", status],
["created_on", created_on],
["before_id", before_id],
["after_id", after_id],
["throttled_only", throttled_only],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.apiKey,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 32 days ago