API Design in Node.js, v5

Testing APIs with Postman

Scott Moss
Netflix
API Design in Node.js, v5

Lesson Description

The "Testing APIs with Postman" Lesson is part of the full, API Design in Node.js, v5 course featured in this preview video. Here's what you'd learn in this lesson:

Scott demonstrates testing APIs with Postman including, making a GET request to a local server and explains how servers can return different parseable data types like JSON or HTML.

Preview
Close

Transcript from the "Testing APIs with Postman" Lesson

[00:00:00]
>> Speaker 1: OK, now let's test our route So, like I showed you earlier, I'm using something called Postman You can download Postman just by Googling Postman and downloading it I actually want to show you that part right quick because it was kind of tricky with their sign-up process

[00:00:00]
If you click to sign up for free, don't do that Click the download button instead Click the one for your platform – the orange button that sticks out and is free No, actually click the gray button that they don't want you to see Find your platform and download it

[00:00:00]
This is about making an account and dealing with their trial As of today, the only paid features Postman has are for teams We're not working on a team right now, so you don't need those features You're just testing APIs If you have your own tool to test APIs, use that

[00:00:00]
I prefer to use tools in the terminal There are also tools built into VS Code that let you test APIs Postman has been around for a while and isn't going anywhere There's another tool called Insomnia, which I think is better than Postman They used to charge, but now they have a free version after hearing feedback from users

[00:00:00]
Both do the same thing – they allow you to test your API visually I'm in Postman, so now I'll test my API It's localhost, which is the long way of saying 127.0.0.1 Every website has a port like 8080, but the browser drops it off, so make sure you have your port For me, I'm doing a GET request to /health

[00:00:00]
I'm changing the verb to GET and putting in /health I'll hit send and get back my JSON message Any observations Was making an API easier than you thought This is essentially it Everything else is just supporting this simple API endpoint You can play around and send different things back

[00:00:00]
It doesn't really matter what you send We can also send other things, not just JSON For example, you can use helper methods like send file I can even send HTML, and Postman will render it A server can send back anything as long as it's parsable over the network threshold

[00:00:00]
You can't send executable logic over the network You can send a string that represents a function definition, but you can't send anything directly executable You can only send things that could be written to a file You also can't send cyclic things by default For instance, date objects typically can't be sent over the wire without converting them to a string first.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now