athidhi
athidhi

Reputation: 21

How to increment a value in an API url

I have an API with an offset value and limit value String requestUrl = https://url//offset=0&offset=1000; this will fetch first 1000 details. I need some more details and for that I need to send the API multiple times. say for example I need execute this API 5 times and offset value should change for the first time to be 1001 and limit to be 2001 How can we implement this in a generic method in java.

Upvotes: 0

Views: 488

Answers (1)

Jonathan Delean
Jonathan Delean

Reputation: 1084

I dont undertand where is your problem, you just have to do that :

x = 1000;
x += 1000;
url = "https://url?offsetStart=" + (x - 1000) + "&offsetEnd=" + x;

And for an API, you can have 2 same parameter like "offset", try "offsetStart" and "offsetEnd"

Upvotes: 1

Related Questions