To ensure a smooth and successful API integration, we recommend using the following checklist as a reference guide for building an API integration with WISEflow.
When calling endpoints in a sequence, one of the calls in the sequence might fail and be subject to a retry. If this happens, the sequence should be stopped at the point of failure.
Example:
A call sequence:
- Call A, success
- Call B, fails
- Call C
Whenever a call fails, the rest of the sequence will not work as intended, the rest of the sequence should be omitted, and appropriate error handling takes place.
Exponential backoff retry is a way to manage retries in a responsible and structured way. It works by waiting progressively longer between each retry request. This approach is less load-heavy on the API and will provide a better, more stable API. The WISEflow API will respond with an 429 error if there are too many requests to the API.
Example:
Exponential backoff retries request exponentially:
- If the request fails, wait 2 seconds before the next retry
- If the request fails, wait 4 seconds before the next retry
- If the request fails, wait 8 seconds before the next retry
- …
- …
exponentialBackoff = interval * multiplier^n
where
- interval is the initial interval for the first retry
- n is the number of failures that have occurred
- the multiplier is the multiplier for the retry
While waiting progressively longer between each retry, the retries are however still synchronised.
Add Jitter to the Exponential Backoff Retry
Adding jitter to the exponential backoff adds some randomness to the retry calls that will break the synchronisation:
- If the request fails, wait 2 seconds + random interval before the next retry
- If the request fails, wait 4 seconds + random interval before the next retry
- If the request fails, wait 8 seconds + random interval before the next retry
- …
- …
exponentialBackoff = interval * multiplier^n +/- jitter
where
- interval is the initial interval for the first retry
- n is the number of failures that have occurred
- the multiplier is the multiplier for the retry
- jitter is added or subtracted to break synchronisation
Now each retry call will be spread over a random period within a set interval.
Each response from the WISEflow API includes an “X-Trace-Id”. The trace Id is a unique way of identifying and tracking what exactly is happening with a request. Logging the trace Id is a useful way to diagnose unexpected or undesirable behaviour.
Adding an “X-Client-Name” to the header when making calls to the API will make error handling and diagnostics easier. The “X-Client-Name” should be easily recognisable, e.g., University of WISEflow.