I get asked about API response testing a lot, how should you do it, and where to start. I have a general rule when it comes to testing APIs, and that rule is: “test your code, and your code only”.
Let me explain: In your application you are writing code that integrates with an API (this API will be out of your control), and you will most likely use some library of package to integrate with this API (another thing that is out of your control).
Instead focus your testing efforts on what you can control; how you send a request and how you respond to API responses.
So let us walk through the testing code one more time, but this time we are going to fake the request and test the response.