How to use this git repo?

Hi, this is my first time using js so bear with me (I’m an experienced python programmer).

How am I supposed to use this repo in js: GitHub - omerdn1/otter.ai-api: Unofficial API for Otter.ai

I installed the package with npm and created the setup script (and updated it to fit my login info), but I’m getting a SyntaxError: SyntaxError: Cannot use import statement outside a module at the first line import OtterApi from 'otter.ai-api';.

I’m totally lost. Don’t know how modules work in js. Would greatly appreciate your help. :slight_smile:

You can’t use ES Modules in Node without jumping through some hoops (or maybe using the latest version?)

Try changing the import statement to:

const OtterApi = require('otter.ai-api')
1 Like

Thank you for the response!

This seems to work as the error is no longer there. However, I’m now getting a separate SyntaxError (which is may be unrelated to the first error?): SyntaxError: await is only valid in async functions and the top level bodies of modules.

This is from the following code:

const OtterApi = require(‘otter.ai-api’);

const otterApi = new OtterApi({
  email: 'email@example.com', // Your otter.ai email
  password: 'abc123!#', // Your otter.ai password
});

await otterApi.init() // Performs login

The error happens at the last line. Any ideas?

Yes, as the error says, you can’t use await at the top level (in your version of Node), it needs to be inside an async function. You’ll need to rewrite that line. I don’t want to just give you the answer here so try to come up with some solutions and do some googling and let me know if you can’t figure it out.

1 Like

I thought I had upgraded to the latest version of Node, but apparently running the installer on my mac didn’t upgrade it. Must be because I might have installed it with brew a while ago. Anyways, I just upgraded to v18.1.0 and I’m still getting the await error.

My current guess to solve it is something like this:

const OtterApi = require('otter.ai-api');

async function main() {

    const otterApi = new OtterApi({
        email: 'email’, // Your otter.ai email
        password: 'pw', // Your otter.ai password
    });

    await otterApi.init() // Performs login
}

main();

But I’m getting an error that “OtterApi is not a constructor.”

Huh, now I’m as confused as you were. I see you posted an issue on the GitHub repo. Hope the author can give you some better help…

Yeah, so just posted another comment on the issue page:

So I had to change the import to const OtterApi = require('otter.ai-api').default; to make it work.

I don’t know why this works though.

But anyways, now my issue is related to “axios” since it is giving me an error for logging in.

Successfuly logged in to Otter.ai
/Users/jacquesthibodeau/Desktop/Code/ai-alignment-audio-transcription/otter.ai-api/node_modules/axios/lib/core/createError.js:16
  var error = new Error(message);
              ^

Error: Request failed with status code 401
    at createError (/Users/jacquesthibodeau/Desktop/Code/ai-alignment-audio-transcription/otter.ai-api/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/Users/jacquesthibodeau/Desktop/Code/ai-alignment-audio-transcription/otter.ai-api/node_modules/axios/lib/core/settle.js:17:12)
    at IncomingMessage.handleStreamEnd (/Users/jacquesthibodeau/Desktop/Code/ai-alignment-audio-transcription/otter.ai-api/node_modules/axios/lib/adapters/http.js:260:11)
    at IncomingMessage.emit (node:events:539:35)
    at endReadableNT (node:internal/streams/readable:1344:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

Will open another issue for this. There is a closed issue about it, but it was supposed to be fixed and merge so not sure?

It looks like there haven’t been any updates in a year and half or so, maybe you’ll want to reverse engineer a bit and make the API calls yourself. It could be that Otter.ai’s API has changed since this library was made :thinking:

(I don’t know anything about Otter.ai so I can’t say anything for sure!)

Yeah, that is my worry. That would suck if the API was updated in such a way that breaks the code. I just tried with the getSpeech() method to see if I can grab one of the conversations from otter.ai, but it didn’t work. Apparently you can only “bulk export” from the website if you are a business user so I thought that might be it (getSpeeches() grabs everything).

The issue is likely with respect to the otter.ai API. :confused: I think they did update a lot of things. And probably wanted people to pay for the business feature of bulk export. Not sure.

Anyways, thanks for your help!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.