> ## Documentation Index
> Fetch the complete documentation index at: https://assemblyai.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Do More With Our SDKs

This guide will show you additional ways to make use of AssemblyAI's Python and JavaScript SDKs.

## Get Started

Before we begin, make sure you have an AssemblyAI account and an API key. You can [sign up for an AssemblyAI account](https://www.assemblyai.com/dashboard/home) and get your API key from your dashboard.

## How to Check and Update Your Version of the SDK

Sometimes errors are encountered because the version of the SDK you are using is not up to date. To see which version you are currently running, type this code in your terminal:

<Tabs>
  <Tab language="python" title="Python" default>
    ```bash theme={null}
    pip show assemblyai
    ```

    If this version is not the same as the current version of the [Python SDK](https://github.com/AssemblyAI/assemblyai-python-sdk) then you can update your version by typing this code in your terminal:

    ```bash theme={null}
    pip install assemblyai --upgrade
    ```
  </Tab>

  <Tab language="javascript" title="JavaScript">
    ```bash theme={null}
    npm info assemblyai version
    ```

    If this version is not the same as the current version of the [JavaScript SDK](https://github.com/AssemblyAI/assemblyai-node-sdk) then you can update your version by typing this code in your terminal:

    ```bash theme={null}
    npm update assemblyai --save
    ```
  </Tab>
</Tabs>

## How to Catch and Log Errors

Catching and logging errors to the console is an easy way help you understand what is going wrong if the code does not run correctly.

<Tabs>
  <Tab language="python" title="Python" default>
    Underneath the line of code where the transcript is created, `transcript = transcriber.transcribe(audio_url, config)`, add the following code to catch and log any errors to the terminal:

    ```python theme={null}
    if transcript.error:
        print(transcript.error)
    ```
  </Tab>

  <Tab language="javascript" title="JavaScript">
    Underneath the line of code where the transcript is created, `const transcript = await client.transcripts.transcribe(params)`, add the following code to catch and log any errors to the terminal:

    ```js theme={null}
    if (transcript.status === "error") {
      console.log(transcript.error);
    }
    ```
  </Tab>
</Tabs>

## How to Log the Transcript JSON and Save it in a File

<Tabs>
  <Tab language="python" title="Python" default>
    If using the error handling code above then add this below it, otherwise add it after the transcript is created, `transcript = transcriber.transcribe(audio_url, config)`:

    ```python theme={null}
    json_file = open('transcript.json', 'w', encoding='utf8')
    json_str = json.dumps(transcript.json_response, ensure_ascii=False, indent=2)

    json_file.write(json_str)
    json_file.close()

    print(json_str)
    ```
  </Tab>

  <Tab language="javascript" title="JavaScript">
    In order to write data to a file, first import the [fs](https://nodejs.org/api/fs.html) package:

    ```js theme={null}
    import fs from "fs";
    ```

    If using the error handling code above then add this below it, otherwise add it after the transcript is created, `const transcript = await client.transcripts.transcribe(params)`:

    ```js theme={null}
    const transcriptJSON = JSON.stringify(transcript, null, "\t");

    fs.writeFile("transcript.json", transcriptJSON, (err) => {
      if (err) throw err;
    });

    console.log(transcriptJSON);
    ```
  </Tab>
</Tabs>

## How to Log the Transcript ID and Retrieve a Previously Created Transcript

To log the transcript ID for a transcription, after the transcript is created and below any error handling, add the following code:

<Tabs>
  <Tab language="python" title="Python" default>
    To log the transcript ID for a transcription, after the transcript is created and below any error handling, add the following code:

    ```python theme={null}
    print(transcript.id)
    ```

    Use the following code to retrieve a previous transcript:

    ```python theme={null}
    transcript = aai.Transcript.get_by_id("<TRANSCRIPT_ID>")

    print(transcript.text)
    ```

    You can also retrieve multiple transcripts, which are then returned in a single `TranscriptGroup` object:

    ```python theme={null}
    transcript_group = aai.TranscriptGroup.get_by_ids(["<TRANSCRIPT_ID_1>", "<TRANSCRIPT_ID_2>"])

    for transcript in transcript_group:
        print(transcript.text)
    ```
  </Tab>

  <Tab language="javascript" title="JavaScript">
    ```js theme={null}
    console.log("Transcript ID: ", transcript.id)
    ```

    To see a list of all previous transcriptions, use the following code:

    ```js theme={null}
    const allTranscriptsResponse = await fetch(
      "https://api.assemblyai.com/v2/transcript?limit=4",
      {
        method: "GET",
        headers: {
          Authorization: "<YOUR_API_KEY>",
        },
      }
    );
    const allTranscripts = await allTranscriptsResponse.json();
    console.log(allTranscripts);
    ```

    There are additional [query parameters](/api-reference/transcripts/list) that can be added to this request to limit the transcripts that are returned. The above example shows how to limit the number of returned transcripts to 4. These will be the four most recently created transcripts.

    To get a specific transcript, use the following code:

    ```js theme={null}
    const transcriptResponse = await fetch(
      "https://api.assemblyai.com/v2/transcript/transcript_id",
      {
        method: "GET",
        headers: {
          Authorization: "<YOUR_API_KEY>",
        },
      }
    );
    const previousTranscript = await transcriptResponse.json();
    console.log(previousTranscript);
    ```

    Make sure when using the above code that you replace `transcript_id` in the url with the ID of the transcript you are looking to fetch.
  </Tab>
</Tabs>
