Getting started with testing APIs

If someone asked you “How would I get started with testing APIs?” what would be the first thing that springs to mind for you?

For me it’s either 30 Second APIs by @daniel.dainton or Restful-Booker from @mwinteringham.

I recently took Marks Web Services training course where we got to use Restful-Booker and I found it to be a great resource. When I’m trying something new, I always like to have a sandbox to try it in first.

Maybe you have more than one resource that is your go to, I know I do but at the risk of biasing some answers further I’ll leave that one to the community :slight_smile:

8 Likes

You mean REST APIs?

If so, I prefer my own framework that’s on GitHub in my RubyTest project.

There’s an extended example with a ‘tour’ that shows how to test GitHub’s own REST API using the framework.

There are some preliminary stops on the tour that deal with logging, verdicts, exceptions, etc. Actual endpoint testing begins here.

2 Likes

I had a look at 30 second APIs. Great resource, Heather!
I learned a lot about API-requests by ‘playing’ with Postman on my previous project (I had no experience with APIs before that).
I’d suggest anyone to also have a look at Postman’s pre-request scripts and tests to set up some simple tests/checks. I actually ended up building a valuable regression-suite in Postman with simple building blocks. (I did have a developer helping me whenever I ran into trouble, that is off course a very valuable resource to have when learning about API’s.)

1 Like

Thank you for sharing that link Heather.

I’m currently working on creating some Postman based content in a Github repo using the Restful-Booker API. Still early days but it will grow over the next couple of months and provide examples of the awesome Postman features that I tend to use all the time.

I would also recommend this blog post by Daniel Donbavand

2 Likes

If it’s just a REST API you can make HTTP requests against, I wrote a guide to using the Python Requests framework.. It’s very simple and you may find it useful.

6 Likes

I give a talk on it (which I’m turning into a workshop sometime soon). Slides (with demos embedded in the slides), code in C# and postman examples are here: https://github.com/g33klady/TestingRESTServices

3 Likes

I’d start with understanding what APIs are:
What is an API, exactly?

Then I’d encourage people to explore an API observe how it behaves. Swagger’s “Pet Store” demo is a nice simple example and it doubles as a nice introduction to Swagger (which is a tool for automatically generating API documentation but also provides an interface to “try” requests with examples).
Swagger Pet Store demo

If you’re looking for a more complex and typical API, there are lots of publicly available APIs, a list of them is here:
Any-api.com
The tricky part with these is that you are having to learn a lot all at once though. So be aware of these topics and learn them one at a time instead of all at once:

  • Request verbs (GET, POST, PUT, DELETE)
  • HTTP Status codes
  • Understanding response bodies
  • Constructing request bodies
  • Authentication and authorisation
  • JSON and XML
  • Understanding resources
  • What IDs mean and how you can use them
  • Understanding data types (integers, strings, floats, etc)
  • Headers

I run a workshop covering all of this so I’m happy to help!

5 Likes

I also wrote a follow up blog post on what to learn next if you already understand these basics.
So you can test an API, what to learn next?

4 Likes

Just read an interesting post on Medium, very detailed for making the decision.
Top 10 API Testing Tools (Details & Updates Done for You!)

1 Like

30 Second APIs is an awesome resource! I used to struggle to test API code, but now I can spin up my own API in a 30 seconds if I just want to try something in my automation code, or even add it as a “before” step in my package.json. so that I have another API ready and waiting if waiting 30 seconds is too long.

2 Likes

I would highly recommended this framework to others

When I had to quickly learn load testing, I found the documentation and tutorials written by Soap UI really helpful. Even when I was completely new to the idea of APIs, I was able to set up a load test.

2 Likes

I just came across this website, might be useful - https://workwithapis.com/

2 Likes