Customized API Monitoring Using Parameter Chains and Validation

In my last blog post, we created a monitor that requests the World Bank’s income levels data for nations that are classified as being “lower middle income.” This returns the data countries at this income level across the entire world.

However, the World Bank’s API offers other parameters that can be easily be inserted into an API Science monitor. For example, if your customers are interested primarily in Latin America and the Caribbean, you can request the information for this region only by requesting World Bank region ID “LMC.” To do this, we edit the “WB Lower Middle Income” monitor (click the monitor’s pencil icon on your Dashboard, or click “Edit” from the monitor’s summary page), and click “Show Settings”:


The monitor currently sets the “IncomeLevel” parameter to “LMC”; to add the “region” parameter, click the “+” at the right of the Parameters row, and enter the new key/value pair (region/LCN):


Clicking “Test Now” runs the test and displays the output below:


The response is information for lower middle income countries in Latin America and the Caribbean. But this response is in XML. What if your software is tailored for working with JSON responses?

Not a problem. The World Bank API Overview notes that:

By default, all requests will respond with valid XML. To receive the response in JSON format, you may provide format=json in any request.

Scrolling back to the top of the API monitor page, we click “+” in the Parameters section, and add format as a new key, and JSON as the matching value.

Futhermore, we select “Validate JSON” in the “Validations” section:

income-level-LMC-LCN-JSONNow, the monitor requests the information for lower middle income countries in the Latin America and Caribbean region, in JSON format. If the received response isn’t valid JSON, the monitor test is considered to have failed.

Clicking “Test Now” runs the test and displays the JSON response below:


The response data is the same, but the format is JSON instead of XML.


The revised “WB Lower Middle Income” API monitor illustrates how your team can utilize API Science settings and validations to customize your API monitors to better represent the workflow that occurs when you process an actual customer’s request. But, really, we’ve barely scratched the surface thus far. Future posts will continue this exploration.

–Kevin Farnham