Runscope API Testing and Monitoring    Learn More →

How to Auto-Generate Runscope-powered SDKs for RESTful APIs

By Neil Mansilla on .

The following is a guest post from Adeel Ali from APIMATIC, a company that offers an automatic SDK generator for REST APIs. APIMATIC can import schemas/descriptions of RESTful APIs (WADL, Swagger, I/O Docs, API BluePrint, Google Discovery) and generate SDKs (Android, Windows, iOS, Java, PHP, Python, Ruby, Node.js). Adeel shares an easy to follow guide to building an SDK with APIMATIC and integrating Runscope.

 

Toward Better SDKs - With APIMatic

SDKs or client libraries are an argumentative topic in the API ecosystem. They are rightly criticized being expensive to build as well as painful to update and maintain. On the other hand, they are considered as crucial, which is evident from the fact that almost all of the top APIs come with SDKs. A closer look at the SDK criticism reveals that the actual pain-point lies in the current development lifecycle of SDKs, and it’s no brainer that if SDK development can be made efficient then it will be a win-win for everyone.

A solution to the above pain-point is replacing the problematic manual development of SDKs by automatic SDK generation. Auto-generated SDKs are cost-effective, easy to update, and offer huge reduction in work-load. APIMatic.io is an automatic SDK generator, based in the land of Hobbits with the exact vision of better SDKs. APIMatic was founded in May 2014 by me and Zeeshan, and currently is in public beta phase, that means you can get SDKs for your API in 7 languages for FREE. More about APIMatic can be read in a review by Kin Lane. 

APIMatic & Runscope – A Natural Alliance

We met John Sheehan for the first time last week at APIWorld 2014, where he hinted about embedding Runscope’s API monitoring capabilities in APIMatic SDKs. The idea looked very intuitive because APIs are mostly accessed via SDKs, and by using Runscope powered SDKs, API providers could inspect/debug all of the request and response data traveling back and forth from the clients using their SDKs. The amount of convenience could be assessed by the fact that setting a single flag would automatically enable API debugging capability in SDKs in 7 languages (to date), while no settings would be required at the client side.

The idea has now become a reality, and in the remaining of the post I am going to show how you can generate Runscope powered SDKs.

Runscope Powered SDKs – Step by Step

Step 1
Create a Runscope bucket, and copy the bucket key. 

Step 2
Specify an API description at APIMatic. The two ways to do it are: importing an API description, or describing an API from scratch. I am describing Vimeo’s public API from scratch here, and will only be specifying two end-points to keep the demo simple. 

2.png
3.png

Step 3
Go to CodeGen Settings and enter the obtained Bucket Key from Runscope. Save the settings.

codegen.png

Step 4
Once the API is defined, go back to the API list, and click the validate button to validate the API description.

Step 5
If all is well, you will be presented with icons of different languages to generate SDKs. Choose your favourite language, and click the icon to download the SDK in a ZIP file.

Step 6
Unzip the contents of the downloaded SDK and open the Configuration file to provide your credentials to access the API. The contents of a generated C# Portable Class Library can be seen in the following snippet. It can be noticed in the Configuartion.cs file that the BaseUri has been transformed to the Runscope-desired format. If you are not using an interpreted language, you’ll now need to compile the SDK to get a compiled binary. There is a ReadMe file in the root folder file if you need any assistance.

6.png

Step 7
Now you have a (compiled) library in your hands which you can reference in an application. Here I am referencing and using the .dll file obtained from the previous step in a simple application. This application searches for videos on Vimeo against a provided keyword, and shows the total number of videos found as the result. The code to access the API functions via SDK can be seen in the snippet below.

Step 8
Go back to the Runscope portal, and select your bucket from the top left corner. You can watch all of the API traffic initiated by your app. The summary of the API calls originated by my application can be seen in the following snippet. Click on any particular call to see a detailed record, compare requests or responses, or play around with the other available options at a very friendly portal.

Pasted_Image_9_30_14__4_29_PM.png

That’s it!

Congratulations on generating your first Runscope powered SDK. I love hearing feedback, so please comment on the post, or send me an email. If you need any assistance, don’t hesitate to ask. 

Categories: code samples, howto, apis

Everything is going to be 200 OK®