Home » Improved SDKs with Timeouts, Multiple Base URI Support and Custom Exception Classes

Improved SDKs with Timeouts, Multiple Base URI Support and Custom Exception Classes

We never stop thinking of ways to make our SDKs better and easier to use. Due to this constant struggle for self-improvement, you see new features being added every now and then. I will be talking about three of those in this blog:

★ Timeouts

★ Multiple Base URI Support

★ Custom Exception Classes

Timeouts

Timeout and retries are widely talked about terms in networking. And are important to consider when building reliable and consistent applications that require network calls. Some of the leading names in the IT industry (example: Google, Facebook, Amazon, Dropbox) provide timeout and retry features built-in with their SDKs.

But why do we need timeout and retry? Let’s take a simple example. Let’s say you are a developer working on an application which makes an HTTP call to a server and waits for it to send you back some information. You then display this information to the user. Now you’ve written and tested all the code and everything is working perfectly. But after an hour, you try showing the application to your friend and it just breaks. Upon investigation, you find out that the server which you were contacting for data is not performing well. It is receiving a lot of client requests and is not able to reply back very quickly.

This is where retry and timeouts come in. You can use retry mechanism to keep pinging the server to check if it’s free to send back the response. If not, you’ll wait and then send the request again. You will specify a timeout value after which the retries will come to a halt. Suppose you specify a timeout value of 10 seconds. If the server doesn’t respond after 10 seconds, you will stop retrying and show the user a message that the server is busy. This is important because this improves user experience. Network latency drops all the time. Timeouts and retries make the application more robust and reliable.

APIMatic provides SDKs with timeouts and retry behavior by default. The timeout values can be changed as required by the user. Tests generated with the SDKs can also be configured with timeouts. Timeout values can be changed in APIMatic API Editor, within CodeGen Settings and TestGen Settings (for tests) page.

Multiple Base URI Support

This is one of the most recent features that has been added to our new and improved SDKs. Within our SDKs, a base URI is provided by the user which specifies which URI will be used to make HTTP calls to.

However, in the present day, developers use multiple environments to separate out different parts of their project. For example, the tested and running code will be pushed to Production. There could be another environment where all tests are run. Likewise, there could be another environment in which a developer might be adding new features to the code. The environments need to be separated out to make sure nothing breaks. Therefore, we have added Multiple Base URI support with our SDKs to allow developers to use the SDKs with their already configured environments, without any hassle. They can easily specify which environment they want to use and within that environment, which server has to be used for making HTTP calls to.

The figures below show how different environments and corresponding servers can be set up inside the API Editor.

Custom Exception Classes

Many times, during development, programmers encounter situations in which the built-in exception classes are not good enough for displaying the error message that they require. In such cases, they sometimes add useful methods to already built-in exception classes that provide more information about the exception that occurred.

Custom Exceptions can be defined in APIMatic’s API Editor. They are automatically included in the SDK when it is generated. Custom Exceptions are referred to as API Errors in the Editor. It allows specifying custom description of errors corresponding to HTTP response codes within the range of 300–599. Global API errors are applied across all endpoints within the generated SDK.

This concludes everything that I had to talk about today. If these features got you excited, then keep on the lookout for more announcements about our SDK improvements because we are constantly working to improve developer’s experience and provide value-added features with our automatically generated SDKs. Do sign up for APIMatic’s Code Generation as a Serviceand leave all the SDK hassle to us!

Leave a Reply

Your email address will not be published. Required fields are marked *