jreyesr / insomnia-plugin-batch-requests

An Insomnia plugin to repeatedly send a request, each time replacing some data with information from a CSV file, and collecting response data into the CSV file.
https://jreyesr.github.io/posts/insomnia-batch-requests/
MIT License
7 stars 0 forks source link

Need iteration delay to avoid API rate limiting #1

Closed dotJson closed 1 year ago

dotJson commented 1 year ago

This plugin is the closest thing to emulate Postman runners - great work.

When running long iterations a rate limit can be triggered, but if there was a way to set an iteration interval it would help to avoid this. Can it be done? Here's the Postman method as an example. It's in milliseconds but seconds would be enough. iteration

jreyesr commented 1 year ago

Hello @dotJson! Thank you! Yes, this was absolutely inspired by Postman's Runner, which is more geared towards repeatedly calling an API for testing. I focused more on extracting data from those calls, which in Postman is not easy.

Regarding the rate limit: Yes, it should absolutely be possible! In fact, I toyed with the idea of providing a Serial/Parallel selection (so that you could send requests in parallel if the API didn't mind). That would probably have come with more configuration: a "# of threads" config for the parallel mode, and a "delay between requests" config for serial mode. It turned out that such a "parallel mode" is not amenable to the hacks that I had to use to make the plugin work, so that entire part got shelved.

That being said, it's definitely possible to add a configuration option for a "delay between requests". Unless Insomnia doesn't allow plugins to sleep for X milliseconds, that is. I don't see why it wouldn't be allowed, though.

Also, I quite like the idea of adding a delay config. Since I have free time these days, I'll get to work on this right away.

Finally, thank you so much for checking out the plugin, and also for requesting new functionality!

dotJson commented 1 year ago

Dude that's awesome. I hope it is an easy add. The use case for me is a CSV with hundreds of (potentially more) lines to POST. The endpoint will puke on parallel calls so its serial, and slow. We usually set it to 2 seconds and let it burn away. Also, it's an XML body where I put the variables instead of the URL. Works well.

jreyesr commented 1 year ago

Hey there @dotJson! Just wanted to let you know that v1.1.0 has been released, and it contains this functionality. You should be able to update your installation... or maybe uninstall and reinstall it? I haven't seen a button to update a plugin in Insomnia, and couldn't find anything in the docs either.

In any case, currently you probably have v1.0.1. Once you install v1.1.0, there should be a new section in the Batch Requests dialog, just above the progress bar. You can set the delay in 100-millisecond steps. I was tempted to go for 1-second steps, as you requested and as Insomnia does for the Repeat on Interval functionality, but I ultimately settled on a bit more granularity, without going into full millisecond-level precision as Postman does.

image

If you find any bugs or otherwise wish to provide any feedback, you're more than welcome. Otherwise, thank you for the request, it was a fun exercise!