Question

Testing Rate Limits

  • 17 November 2022
  • 1 reply
  • 261 views

I am having trouble developing with rate limits in mind. Is there a way to simulate the rate limits being exceeded for sending sms and getting messages?


1 reply

Userlevel 1

It's very easy to exceed the rate limit. There is no way to simulate it but as you wish, just put the API call function in a loop and call more times than the rate.

This is a simply example using Node JS

for (var i=0; i<60; i++) {
    await send_sms()
}

async function send_sms(){
  try{
    var resp = await platform.post('/restapi/v1.0/account/~/extension/~/sms', {
             from: {phoneNumber: "fromNumber"},
             to: [{phoneNumber: "toNumber"}],
             text: "Hello from Node JS",
        })
    var jsonObj = await resp.json()
    console.log("SMS sent. Message status: " + jsonObj.messageStatus, jsonObj.id)
    var obj = resp.headers
    console.log(obj)
  }catch(e){
    console.log(await e.response.json())
  }
}

Please read this article to learn more about how to deal with API rate limit.

Reply