{{Intro.to.APIs}}
Bit Project X Postman
Reimagining the Classroom
Leveraging technology to rethink the way we teach
bitproject.org/join
Presenters
Kevin Vuong�Developer Relations�Bit Project
Jefferson Chhen�Developer�Bit Project
Michelle Hu�Developer�Bit Project
Daniel Kim�President�Bit Project
{{Intro to APIs}}
Before we get started:
Download Postman!
getpostman.com/downloads
Why are APIs Useful?�Easy Data Access
Data APIs make authenticated access to all kinds of data easy!
Make a Postman Account!
What is an API?
APIs allow programs to interact with each other without exposing source code
Why are APIs Useful?�Faster Development
You don’t need to build everything from scratch.
Makes development easier and faster!
What is a RESTful API?
RESTful APIs allow programs to communicate with each other using HTTP (Hypertext Transfer Protocol) Requests
HTTP
Server
Webpage
HTTP Methods
GET: retrieves data
POST: assigns a value to an empty object
PUT: re-assign/ change a value
DELETE: gets rid of an existing value
Endpoints
Status Code
API Testing Game
bitbloxs.herokuapp.com
Objective
Rules
What is cURL?
cURL is a command-line tool for getting or sending data including files using URL syntax.
Open your
Terminal/Command Prompt
GET Requests
We use a GET request when we want to query a collection of data or a specific piece of data
GET requests return a data object (usually in JSON) and a 200 status code
curl --location --request GET "https://bitbloxs.herokuapp.com/boxes?api_key=thisistheapikey"
POST Requests
POST requests are used to send data to the server. It creates a new object.
curl --location --request POST "https://bitbloxs.herokuapp.com/change/23/yellow?api_key=thisistheapikey"
PUT Requests
A PUT request is used to change existing data
In contrast to POST, which creates new data
curl --location --request PUT "https://bitbloxs.herokuapp.com/change/23/blue?api_key=thisistheapikey"
DELETE Requests Explained
A DELETE method is used to delete existing data
curl --location --request DELETE "https://bitbloxs.herokuapp.com/delete/23?api_key=thisistheapikey"
What is Postman?
Postman is a collaboration platform for API development.
Makes testing APIs super simple!
Postman Features�Easy Testing
Postman allows easy API testing with a click of a button.
No need to use curl command!
Postman Features�Mock Server
Configuration of mock servers allow for simulation of endpoints without implementing an actual back-end.
This is good for visualizing the data that you would get.
Postman Features
Collections
Postman also allows you to organize a set of API requests.
This makes it quick and easy access to see/edit/delete a request.
Creating a New Collection
Create a Collection
We are going to create a request to get a single box’s color
Postman Features
Environments
Environments allow easy switching between, development and production servers. Environments let you customize requests using variables so you can easily switch between different setups without changing your requests.
Creating an Environment
Click the gear icon. Then, click ADD
Postman Features�Credentials
Variables in a Postman collection can be used in the entire collection - allows you to encapsulate sensitive data
Create Variables for your Credentials
Our URL is
https://bitbloxs.herokuapp.com
Create Variables for your Credentials
An API Key is required to access an API. Our API’s key is thisistheapikey
Open Collection
Make sure that you click the menu icon on the bottom left to open the menu!
Creating a GET Request
Use Authentication
Creating the route
input the following link:
{{url}}boxes/22
Postman Features�Documentation
Postman also auto generates beautiful documentation.
This makes it quick and easy for developers to understand all of the features of an API.
Let’s Explore
explore.postman.com/templates/4301
Click View Documentation
Importing Collections
Click the Run in Postman button
Open Collection
Make sure that you click the menu icon on the bottom left to open the menu!
Set Environment
Make sure the environment is set to “Deploy”
Experiment with Postman
In the collection click the “Get all boxes” request. �Click the send button and see what happens!
Experiment with Postman
POST in Postman
Double click the Change color request in the collection.
Your Postman client should look like this
POST in Postman
On the link, replace <string:color> to either blue, orange, green, or yellow.
Your link should look something like this.
POST in Postman
On the link, replace <int:box_id> with a number from 1 to 400.
Your link should look something like this.
After this step, click the Send button!
Psst
Repeat for Put/Delete
Requests
BitBloxs.herokuapp.com
May the best team win!
HOW TO
WIN
Postman Features�Collection Runner
Collections are groups of requests that can be run together as a series of requests, against a corresponding environment.
Click the Runner Button
Postman Features�Collection Runner
Configure the POST route to look something like this.
Replace {{box_id}} with the number and add the color you want.
How we use Postman
Apply here!
Developer Relations meeting now - stick around!
apply.bitproject.org