Validating API Responses and Performance Using JavaScript

Determining the present state of an API that’s critical to your product’s performance is the reason why companies apply API monitoring on a 24/7 basis. If your product depends on a sequence of calls to multiple APIs (perhaps internal as well as external), your product could appear “down” to your customers if even one of […]

Continue reading

Using Regular Expressions and JavaScript to Validate API Responses

Regular expressions (RegEx) are “a sequence of characters that define a search pattern, mainly for use in pattern matching with strings, or string matching.” Amazingly, the RegEx concept was invented back in the 1950s, by U.S. mathematician Stephen Cole Kleene, who was a student of Alan Turing, among others. In his book Mastering Regular Expressions, […]

Continue reading

Using JavaScript to Validate API Response Bodies

In prior posts, I’ve illustrated how API Science’s JavaScript validations capability can be used to validate API response timing versus data size, API HTTP response headers, and HTTP response status codes. What hasn’t yet been investigated is how you can use the API Science JavaScript validation facility to validate the API response body. We’ll use […]

Continue reading

Using JavaScript to Validate HTTP Response Codes in API Responses

In addition to using JavaScript to validate HTTP headers received by your API Science monitors, JavaScript can be applied for fine-grained validation of the HTTP Status Code for each API response. The status code normally associated with a successful response is 200 (“OK”). However, all 2xx status codes indicate that from the server’s point of […]

Continue reading

Using JavaScript to Validate HTTP Headers in API Responses

In my last post, I applied JavaScript to create a timing versus data size validation for my XKCD API monitor: var timing = context.response.timing.total; var size = context.response.meta.downloadSize; if (timing > 5000) { assert(size > 10000, “Download size vs speed issue”); } The validation checks how long it took to complete the API check. If […]

Continue reading

Using JavaScript and Chai Asserts to Validate API Response Timing versus Data Size

My last post described the possibility of applying JavaScript and API Science’s built-in Chai Assertion Library to validate responses from API calls. In that post, I created a monitor that calls the xkcd.com API, which returns JSON formatted responses. Now it’s time to write some JavaScript that validates the API’s responses. The API Science monitoring […]

Continue reading