How to get data from rest api with pagination

Hello everyone.

I need get data from REST API that using pagination control. First I call one endpoint to get a list of cars code, second I call the other endpoint that has all cars features passing cars code and page number.
This endpoint needs the cars code and the number of page, to get all pages that some cars have, I pass page ONE that returns total pages of this car, then I need call this endpoint n times as the totalPages returned.

Example: baseUrl/CarCode=123&page1
{
"data":[
{someFeatures},
{someFeatures}
]
"currentpage":1,
"totalPage":2
}
So to get all data, the flows needs loop to mount the url passing the cars code and page one and iterate all pages that the cars have, after change the cars code and so on.

If someone could help me I apreciate.
Best regards.

With the limited info you have supplied, something like this should return the pages.

[{"id":"114c8b0afdd4ac77","type":"complete","z":"d1395164b4eec73e","name":"","scope":["23e3e918f0559d77"],"uncaught":false,"x":170,"y":3060,"wires":[["06014f770a9c7632","b12f3d2f3eb2e592"]]},{"id":"06014f770a9c7632","type":"debug","z":"d1395164b4eec73e","name":"debug 2464","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":370,"y":3060,"wires":[]},{"id":"b12f3d2f3eb2e592","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"page","pt":"msg","to":"$$.payload.currentpage + 1","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":160,"y":3140,"wires":[["cc194e3babf87bfe"]]},{"id":"cc194e3babf87bfe","type":"switch","z":"d1395164b4eec73e","name":"","property":"payload.totalPage","propertyType":"msg","rules":[{"t":"gte","v":"page","vt":"msg"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":310,"y":3140,"wires":[["23e3e918f0559d77"],["28b402736e6dcf1d"]]},{"id":"23e3e918f0559d77","type":"http request","z":"d1395164b4eec73e","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"http://192.168.1.10:1880/testpage?CarCode={{carCode}}&page={{page}}","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":490,"y":3140,"wires":[["b17f964e695e3b54"]]},{"id":"28b402736e6dcf1d","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"complete","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":3200,"wires":[["d164a90ad08cbabd"]]},{"id":"76e84f9f762374dd","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"page","v":"1","vt":"str"},{"p":"carCode","v":"123","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":150,"y":3200,"wires":[["23e3e918f0559d77"]]},{"id":"b17f964e695e3b54","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"\"page\" & $$.payload.currentpage","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":3140,"wires":[["d164a90ad08cbabd"]]},{"id":"d164a90ad08cbabd","type":"join","z":"d1395164b4eec73e","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"30","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":730,"y":3200,"wires":[["bf6ce6d4b346f3a2"]]},{"id":"bf6ce6d4b346f3a2","type":"debug","z":"d1395164b4eec73e","name":"debug 2462","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":950,"y":3220,"wires":[]}]

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.