Back

Is the rate limit error associated with the API key?

  • 0
  • General
  • Web
bazoo
27 Apr, 2023, 20:57

I have several websites, mostly clones, all of them using the same API Key. I'm hitting rate limits, and I don't really know why. I though that this could be the reason.

Would making new API keys reduce the rate limit errors for each website?

TL;DR
User is experiencing rate limit errors while using the Appwrite API. They are using the node-appwrite and appwrite packages for the backend and frontend respectively. The issue occurs when making requests on behalf of the user. The user is using Next.js with TypeScript. They have received suggestions to upgrade their Appwrite version and to backup their files before doing so. The user is also considering creating new API keys for each website to potentially reduce the rate limit errors. Solution: - Upgrade Appwrite to version 1.3.2 and run the necessary migrations. - Backup all files, including docker-compose.yml, .env, database,
Binyamin
27 Apr, 2023, 21:06

Usually accessing using an API key doesn't suffer from rate limits. https://appwrite.io/docs/rate-limits

Binyamin
27 Apr, 2023, 21:07

What endpoint you're trying to reach, As I remember that at least one also had rate limits even for API.

bazoo
27 Apr, 2023, 21:27

/account endpoints.

Binyamin
27 Apr, 2023, 21:42

What is the full error you're getting?

Binyamin
27 Apr, 2023, 21:43

Shouldn't be

bazoo
28 Apr, 2023, 08:36

here are some of them (from docker logs)

TypeScript
[Error] Timestamp: 2023-04-28T06:49:17+00:00
[Error] Method: POST
[Error] URL: /v1/account/sessions/anonymous
[Error] Type: Appwrite\Extend\Exception
[Error] Message: Rate limit for the current endpoint has been exceeded. Please try again after some time.
[Error] File: /usr/src/code/app/controllers/shared/api.php
[Error] Line: 127



[Error] Timestamp: 2023-04-28T08:33:49+00:00
[Error] Method: POST
[Error] URL: /v1/account/recovery
[Error] Type: Appwrite\Extend\Exception
[Error] Message: Rate limit for the current endpoint has been exceeded. Please try again after some time.
[Error] File: /usr/src/code/app/controllers/shared/api.php
[Error] Line: 127

Here's the JSON response from the second error above:

TypeScript
{
  "message":"Rate limit for the current endpoint has been exceeded. Please try again after some time.",
  "code":429,
  "type":"general_rate_limit_exceeded",
  "version":"1.0.2"
}
bazoo
28 Apr, 2023, 08:37

sorry for not replying earlier, i made the post right before going to bed

Binyamin
28 Apr, 2023, 11:41

What version of Appwrite you're using?

bazoo
28 Apr, 2023, 14:53

1.0.2

Binyamin
28 Apr, 2023, 14:58

Maybe in this version setting the user as App (API) user dos not work with API keys. so first what I would do

  1. Backup everything. yml, .env, database and volumes.
  2. Upgrading to 1.1.0 and run migration
  3. Upgrading to 1.2.0 and run migration
  4. Upgrading to 1.3.2 and run migration

Notice that the upgrade should be from one minor to minor

Backup scripts

Upgrade instructions

bazoo
28 Apr, 2023, 15:00

scary undertaking given that it is in production, but i'll give it a try i guess

bazoo
28 Apr, 2023, 15:00

thanks

Binyamin
28 Apr, 2023, 15:00

Yes, it is

Binyamin
28 Apr, 2023, 15:01

That's way it's important to backup everything, then you'll be able to go back in a snap of a finger,

Binyamin
28 Apr, 2023, 15:01

Not really 🫰 but real quick 😉 I will also probably go on a time I have the least amount of users / requests.

Binyamin
28 Apr, 2023, 15:02

BTW is all of your Appwrite is in one server within docker-compose.yml?

Drake
28 Apr, 2023, 17:35

Are you using the node SDK? How are you using an API key? what's the tech stack for your app?

bazoo
28 Apr, 2023, 22:13

yes? I just followed the installation steps on the documentation

bazoo
28 Apr, 2023, 22:20

I'm using these 2, one for the backend and one for the front: https://www.npmjs.com/package/node-appwrite https://www.npmjs.com/package/appwrite

TypeScript
// Server side only code
export const appwrite = new Client()
  .setKey(process.env.APPWRITE_API_KEY!)
  .setProject(process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID!)
  .setEndpoint(ENDPOINT);

// When I need to do something in the backend on behalf of the user
function getAppwriteClient(jwt: string): Client {
  return new Client()
    .setKey(process.env.APPWRITE_API_KEY!)
    .setProject(process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID!)
    .setEndpoint(ENDPOINT)
    .setJWT(jwt);
}

Using Nextjs with TypeScript

Drake
28 Apr, 2023, 22:37

Ah i see. Kk. In this case, those requests on behalf of the user are subject to rate limits

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more