Chapter 5: Introduction to Web APIs


Overview

Web APIs are the other essential component under the web services umbrella. Like web feeds, they are provided in a clearly defined manner by many of the top web-aware firms. The primary difference between web APIs and web services is the level of interaction available — feeds are relatively static; you get one page, and it's the same page everyone else gets. APIs, on the other hand, are entire programs, ready to provide information, ship products, or query databases, all depending on your request. From an object-oriented (OO) standpoint, dealing with an API is much like dealing with a class. It receives your request, and then, based entirely on the information you gave it (it cannot come back and request information), it returns a result.

Although numerous APIs are used today, for the purposes of this book the focus here is on the two most popular. The first, Representational State Transfer (REST), uses long GET requests to indicate exactly what action is desired. Requests performed using REST look identical to the request seen after filling out a form that uses the GET method, and you can in fact perform REST requests in that exact manner. The second, Simple Object Access Protocol (SOAP), posts XML objects to the server and receives a similarly fashioned XML object as a response.

This chapter covers the following topics:

  • The choice between using REST and SOAP

  • An introduction to REST and SOAP

  • How REST and SOAP both work

  • How to generate SOAP and REST requests

  • Handling REST and SOAP responses




Professional Web APIs with PHP. eBay, Google, PayPal, Amazon, FedEx, Plus Web Feeds
Professional Web APIs with PHP. eBay, Google, PayPal, Amazon, FedEx, Plus Web Feeds
ISBN: 764589547
EAN: N/A
Year: 2006
Pages: 130

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net