DEV Community

Rakesh
Rakesh

Posted on

How did I remove the rate limit from my minion translator and how you can do it too : a neogCamp story

Introduction

For those who don't know what I am talking about , Neog Camp is a project oriented bootcamp under the supervision of tanay pratap , where you can only advance to the Level ONE, if you have finished all the assignments from Level ZERO .

And Minion Translator is one of those assignment in which, we have to use the fun translation api to translate from english to minionese .

so what's the problem ?
The problem is rate limiting .

The Problem

Fun translation or similar public apis ratelimit the api calls to maintain their server level.So you can imagine the problems that can arise if 500 folks uses the same api that accepts only 5 calls per hour .

And not only it was causing problem during the devlopment, it was gonna be there even after the deployment too. Imagine sharing your app to your friends or employers and all they get is error occured ! try after sometime message .

The Solution

There was only two possible solutions to these problems and they were

  1. Finding another API that is free and unlimited
  2. Building your own API

I choose the second option after wasting a day in search for the first one .
Before that I have known about APIs in theories only, never used one of them not even a mock one before Neog Camp tutorial. But still somehow It seems feasible after using the Mock Server created by Tanay Pratap .

He have already taken care of the input and output part of the program, so all I have to do was figure out the processing part . When I thought about the inner-workings of fun translation API, It seems like all it was doing underneath is taking our values , comparing it to values in the database and returning whatever the corresponding values as result and If something is not on the database it returns the same.

So first of all I needed to find a database of minion words and thanks to the popularity of minion it was not that hard. I found a extreme large list of minionese words compiled by Bryce Dorn and available under MIT license in github .

After getting the database all I had to do was write a program that can map through the list and compared the input to the words in the list . As we all have done similar program in our second CLI app , I tried similar approach here too . But only could translate single words even after a lot of attempt . So I took the help from our mentors Rohit Gaur and Sreetam Das and Voila , our own api was ready .

Now only one more thing was left that is finding a way to keep it running forever . Which was taken care by Repl.it very efficiently as once deployed, the HTTP Server will continue to run in the background, even after you close the browser tab .

you can read more about it from here .

End Result

I have used it in my own minion translator app . so you can test it here.

Sometimes it may take some time waking a idle server which can be fixed by a quick refresh but normally you won't need it .

How can you use it in your own app ?

Step one

Go to the below link and fork the repl

 https://repl.it/@r4k3sh/minionsapi#index.js

Enter fullscreen mode Exit fullscreen mode

NEUQY95qIL.png

Step Two

Run the Repl

mFC1vNxyZj.png

Step Three

Grab the link it provide

r5gDcWxcHD.png

add /translate/minion.json?text= to it

so for me it becomes :

https://minionsapi.r4k3sh.repl.co/translate/minion.json?text=
Enter fullscreen mode Exit fullscreen mode

You will have similar links based on your repl name and id .

Step Four

Test the api on browser after typing anything after the above url .

If everything goes well you will receive the translated text instantly like below .

XyboJ8JY9n.png

Step Five

Replace the link in your app instead of fun translation api url .

Similarly you can make any other translation API too ,If you can manage to find the wordlist.

That's it neoGrammers .

Thank you.

CREDITS

Bryce Dorn: For Compiling the Word list

Tanay Pratap: For Creating the Server

Sreetam Das & Rohit Gaur: For Writing the final piece of code

Neog Camp : For Existing

Latest comments (0)