Importing Swagger API Representations to Create API Monitors

Swagger is an open source project that bills itself as “the World’s most popular framework for APIs”:

Swagger is a simple yet powerful representation of your RESTful API. With the largest ecosystem of API tooling on the planet, thousands of developers are supporting Swagger in almost every modern programming language and deployment environment. With a Swagger-enabled API, you get interactive documentation, client SDK generation and discoverability.

Swagger’s Getting Started page states that Swagger’s goal “is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined via Swagger, a consumer can understand and interact with the remote service with a minimal amount of implementation logic.”

If your API has a Swagger representation, then creating a monitor for your API is straightforward, using API Science’s import capability. In this post, I illustrate how to do this, using the Swagger Petstore API representation.

Creating the API Science Monitor

To create a Swagger Petstore API monitor, log into your API Science account, click “Import” at the top of the page, and scroll down to the “Swagger” section:


Click the “Import From Swagger” button, and enter the Swagger Petstore API URL:


Clicking the “Import” button embeds the Swagger summary page for the Swagger Petstore API:


Let’s say your product depends on information about the Pet Store’s pets. Clicking on the pet link displays the available API calls related to pets:


Futhermore, let’s say your product depends on getting information about specific pets based on the petID. Clicking on “GET /pet/{petID}” link brings up the details:



Entering an integer (for example, 1) into the petId field and clicking the “Try it out!” button produces a result like this:


Clicking the “Run on API Science” button creates your new API Science monitor, runs the monitor, and provides you with its URL:


Your API Science dashboard now includes the new monitor:



Clicking on the monitor name shows you the first result from your new API Science API monitor check:




In a few simple steps, we’ve taken a Swagger API definition and turned it into an API Science monitor. For any API that is a critical component of your product — whether the API is internal or external —  if the API has a Swagger representation, it is possible for you to very easily and quickly create an API Science monitor that checks and logs the API’s current status.

–Kevin Farnham