0.0.27 • Published 8 months ago

@fern-api/assemblyai v0.0.27

Weekly downloads
-
License
-
Repository
github
Last release
8 months ago

Assembly AI Node Library

npm shield fern shield

The Assembly AI Node.js library provides access to the Assembly AI API from JavaScript/TypeScript.

Documentation

API reference documentation is available here.

Installation

npm install --save @fern-api/assemblyai
# or
yarn add @fern-api/assemblyai

HTTP Client Usage

The SDK exports a vanilla HTTP client, AssemblyAIClient. You can use this to call into each of our API endpoints and get typed responses back.

Try it out

import { AssemblyAIClient } from "@fern-api/assemblyai";

const aai = new AssemblyAIClient({
    apiKey: "YOUR_API_KEY",
});

const transcript = await aai.transcript.get("transcript-id");

console.log("Received response!", transcript);

Handling Errors

When the API returns a non-success status code (4xx or 5xx response), a subclass of AssemblyAIError will be thrown:

import { AssemblyAIClient, AssemblyAIError } from "@fern-api/assemblyai";

try {
  const transcript = await aai.transcript.get("transcript-id");
} catch (err) {
  if (err instanceof AssemblyAIError) {
    console.log(err.statusCode); 
    console.log(err.message);
    console.log(err.body); 
  }
}

Request Options

The HTTP Client accepts a RequestOptions class where you can specify a customized timeout.

const transcript = await aai.transcript.get("transcript-id", {
    timeoutInSeconds: 60 // increase timeout in seconds
});

Using the Transcriber class

Additionally, the SDK also exports a Transcriber class that has utilities on top of the HTTP client, such as automatic polling.

import { Transcriber } from "@fern-api/assemblyai";

const transcriber = new Transcriber({
    apiKey: "YOUR_API_KEY",
});

const transcript = await transcriber.transcribe({
    data: "https://example.org/audio.mp3",
    poll: true,
});

console.log(transcript.text);

Beta status

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning the package version to a specific version in your package.json file. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributing

While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!

0.0.27

8 months ago

0.0.26

8 months ago

0.0.25

8 months ago

0.0.24

8 months ago

0.0.23

8 months ago

0.0.22

8 months ago

0.0.21

8 months ago

0.0.20

8 months ago

0.0.19

8 months ago

0.0.18

8 months ago

0.0.17

9 months ago

0.0.16

9 months ago

0.0.15

9 months ago

0.0.14

9 months ago

0.0.13

9 months ago

0.0.12

9 months ago

0.0.11

9 months ago

0.0.10

9 months ago

0.0.6

9 months ago

0.0.5

9 months ago

0.0.4

9 months ago

0.0.3

9 months ago