REST APIs Maxwell Furman Department of MIS Fox School of Business

Slides:



Advertisements
Similar presentations
JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
Advertisements

Give it a REST already Arnon Rotem-Gal-Oz VP R&D xsights
REST - Representational State Transfer
REST Vs. SOAP.
Introduction to Web Services
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Copyright 2004 Monash University IMS5401 Web-based Systems Development Topic 2: Elements of the Web (g) Interactivity.
Web Servers How do our requests for resources on the Internet get handled? Can they be located anywhere? Global?
1 The World Wide Web. 2  Web Fundamentals  Pages are defined by the Hypertext Markup Language (HTML) and contain text, graphics, audio, video and software.
Controling instrument in the RESTful way
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
PHP and SQL Server: Queries IST2101. Three-Tier Architecture Three-tier architecture means that the Web server and the DBMS are on separate servers IST2102.
Web Proxy Server Anagh Pathak Jesus Cervantes Henry Tjhen Luis Luna.
CS 415 N-Tier Application Development By Umair Ashraf July 6,2013 National University of Computer and Emerging Sciences Lecture # 9 Introduction to Web.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
JavaScript & jQuery the missing manual Chapter 11
Chapter 1: Introduction to Web
Web Architecture & Services (2) Representational State Transfer (REST)
REST.  REST is an acronym standing for Representational State Transfer  A software architecture style for building scalable web services  Typically,
Python and REST Kevin Hibma. What is REST? Why REST? REST stands for Representational State Transfer. (It is sometimes spelled "ReST".) It relies on a.
School of Computing and Information Systems CS 371 Web Application Programming PHP – Forms, Cookies, Sessions and Database.
Kingdom of Saudi Arabia Ministry of Higher Education Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences Chapter.
REST - Introduction Based on material from InfoQ.com (Stefan Tilkov) And slides from MindTouch.com (Steve Bjorg) 1.
Overview Web Session 3 Matakuliah: Web Database Tahun: 2008.
DM_PPT_NP_v01 SESIP_0715_JR HDF Server HDF for the Web John Readey The HDF Group Champaign Illinois USA.
API Crash Course CWU Startup Club. OUTLINE What is an API? Why are API’s useful? What is HTTP? JSON? XML? What is a RESTful API? How do we consume an.
Producing a high-impact web experience by integrate Macromedia Flash and ASP By Katie Tuttle CS 330: Internet Architecture and Programming Project.
Representational State Transfer (REST). What is REST? Network Architectural style Overview: –Resources are defined and addressed –Transmits domain-specific.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
RESTful Web Services What is RESTful?
REST By: Vishwanath Vineet.
Web Technologies Lecture 10 Web services. From W3C – A software system designed to support interoperable machine-to-machine interaction over a network.
Representational State Transfer COMP6017 Topics on Web Services Dr Nicholas Gibbins –
REST API Design. Application API API = Application Programming Interface APIs expose functionality of an application or service that exists independently.
National College of Science & Information Technology.
Tiny http client and server
Block 5: An application layer protocol: HTTP
JavaScript and Ajax (Ajax Tutorial)
Section 6.3 Server-side Scripting
The Client-Server Model
API (Application Program Interface)
Thoughts on Architecture for the Internet of Things
RESTful Sevices Distributed Objects Presented by: Shivank Malik
Hypertext Transfer Protocol
Better RESTFul API – Best Practices
Web Development Web Servers.
WEB SERVICES.
REST- Representational State Transfer Enn Õunapuu
Node.js Express Web Services
Advanced Web-based Systems | Misbhauddin
Hypertext Transport Protocol
CMPE 280 Web UI Design and Development October 24 Class Meeting
Representational State Transfer
Materials Engineering Product Data Management (ePDM)
Ashish Pandit IT Architect, Middleware & Integration Services
WEB API.
Ashish Pandit, Louis Zelus, Jonathan Whitman
Chapter 27 WWW and HTTP.
SDWIS Prime REST APIs Elinor Keith
$, $$, $$$ API testing Edition
Introduction of Week 11 Return assignment 9-1 Collect assignment 10-1
A gentle introduction to RESTful APIs
RESTful Web Services.
REST på Microsoft-stacken
WEB SERVICES From Chapter 19, Distributed Systems
Web APIs In computer programming, an application programming interface (API) is a set of subroutine definitions, protocols, and tools for building application.
Week 05 Node.js Week 05
A gentle introduction to RESTful APIs
NEECOM – May 22, 2019 Todd L Gould, CEO
Chengyu Sun California State University, Los Angeles
Presentation transcript:

REST APIs Maxwell Furman Department of MIS Fox School of Business Temple University

Definitions What is a Web API? API stands for Application Programming Interface. A web API allows specifically exposed methods of an application to be accessed and manipulated outside of the program itself. Web APIs use web protocols (HTTP, HTTPS, JSON, XML, etc.). For example, a web API can be used to obtain data from a resource (such as U.S. postal service zip codes) without having to actually visit the application itself (checking usps.com). What is REST? REST is short for Representational State Transfer. REST is a software architectural style… a set of rules and conventions for the creation of an API. A computer scientist by the name of Roy Fielding defined the principles of REST in his 2000 PhD dissertation. Like any theoretical ideal, there are a lot of practical exceptions to Fielding’s principles. But the principles of REST are intended to make APIs and systems that are: efficient, scalable, simple, reliable and modifiable (i.e. future-proof) among other things … all excellent ideals!

What is REST Client-Server architecture – Simply put, RESTful systems separate the systems responsible for storing and processing the data (the server) from the systems responsible for collecting, requesting, consuming, and presenting the data to a user (the client). This separation should be so distinct that the client and server systems can be improved and updated independently each other. Client Server An upgrade to the client should not necessitate an upgrade to the server… and vice versa.

Benefits of REST Statelessness – As far as the server is concerned, all client requests are treated equally. There’s no special, server-side memory of past client activity. The responsibility of managing state (for example, logged in or not) is on the client. This constraint is what makes the RESTful approach so scalable. Be advised! In REST each and every resource request is to convey the application state. That means the state gets transferred with each request!

Benefits of REST Cacheability – Clients and servers should be able to cache resource data that changes infrequently. For example, there are 52 states and other jurisdictions in the U.S.A. That’s not likely to change soon. So, it is inefficient to build a system that queries a database of states each and every time you need that data. Clients should be able to cache that infrequently updated date and web servers should be able to control the duration of that cache. Layered system – A client cannot tell whether it is connected directly to an end server, or to an intermediary along the way. Intermediary servers can also improve system scalability. B A C D As far as the client is concerned, only “A” exists!

The marriage of REST and HTTP Roy Fielding was also one of the principle authors of the HTTP specification. Fielding created the REST constraints with HTTP in mind. Part of the power of the REST architectural style is that HTTP was already widely in use before the REST constraints were formally defined. In theory, the six REST constraints we just reviewed could be applied to other protocols, but in practice RESTful APIs are HTTP based.

RESTful API conventions – HTTP Methods * GET – The get method is used to retrieve data from a resource. According to RESTful conventions, GETs are safe to execute over and over. For example, It is safe to run the following GET request as many times as you want: https://www.amazon.com/s/ref=nb_sb_noss_1?url=search-alias%3Daps&field-keywords=robot * POST – The POST method would be used to create a data record, or initiate an action. Imagine each POST as being a request to make a amazon purchase. You would want to be careful about doing that more times than necessary! PUT -- The PUT method exists in HTTP. It should be used to update an existing data record. DELETE – The DELETE method exists in HTTP. It should be used to delete a data record. * These are the only two methods you will use this semester.

RESTful API conventions – HTTP Status Codes Every HTTP request results in a status code being sent back to the client. Request Status Code Server Client 2xx Status codes indicate success. The most common status code is 200, OK. 3xx Status codes indicate that the client needs to do something else to complete the request. Usually this means making the request from a different location. Status code 301 means the resource has been permanently moved somewhere else.

HTTP Status Codes continued 4xx Status codes indicate a client error. That is, the client sent a request that did not make sense. A classic example of this is “404 Not Found”. Try it! Go to https://www.google.com/bad then try going to https://www.temple.edu/bad Notice that both pages report the code 404. That’s not just a coincidence. The internet is built on standards like HTTP and these error codes are part of that standard. 5xx Status codes indicate a server error. That means that the request made by the client appears to be fine. But the server is experiencing some difficulty. A server experiencing some difficulty might report “500 Internal server error” More thorough documentation of the HTTP status codes can be found here: https://www.restapitutorial.com/httpstatuscodes.html

An Example Client Server

An Example GET https://www.instagram.com/profile?user=somemadeupuser 200 OK { ... } OR 404 Not Found Client Server

An Example POST https://www.instagram.com/comment { picture_id: <id>, comment: "💦" } 200 OK { comment_id: <id>, commenter_id: <id>, picture_id: <id>, comment: "💦" } Client Server

{ picture_id: 0, comment: "💦" } An Example POST https://www.instagram.com/comment { picture_id: 0, comment: "💦" } 404 Not Found Client Server

An Example POST https://www.instagram.com/comment { picture_id: <id>, comment: "" } 400 Bad Request Comment text must not be empty Client Server

Hands-on time Download the purgo.html from the Course Materials Site Add a text input box and a submit button When the button is clicked, submit the text to the purgomalum API, as documented at https://www.purgomalum.com Show the return value from the API in a box on the page