that defines how software components interact with each other • Generically, this can refer to any software Function definition, Object Definition ( in OOP )
Services” with some or all of the following properties: - Request / Response messaging protocol - HTTP(s) - Object Serialization / message payload ( JSON, XML ) - Authentication ( Basic / OAuth / OAuth 2.0)
from SOAP (Simple Object Access Protocol) / SOA ( Service Oriented Architecture) • To RESTful ( Representational State Transfer ) services and Resource Oriented Architectures.
that adheres to the principles: 1. Statelessness - Each request is independent and contains all information for server to return a response - Server does not need to keep track of previous requests (state) in memory. Any state management is the responsibility of the client. - Simpler to implement and scale
methods POST, GET, PUT, DELETE corresponds to CRUD ( Create, Read, Update, Delete ) POST → Create GET → Read PUT → Update DELETE → Delete In other web service designs GET and POST used interchangably to Create,Read, Update, Delete ; PUT and DELETE rarely used
endpoints are intuitive and human readable For Example http://api.devcon.ph/events/<year>/<month>/ GET http://api.devcon.ph/events/2014/07/ returns a list of devcon events for July 2014
Resources are serialized to JSON or XML and transferred to the client User: Name: …? Address: …? Telephone: …? User: Name: Jane Address: Ortigas Telephone: 092398 {“Name”: “Jane”, “Address”: “Ortigas”, “Telephone”: “092398” }
version 1.1 all requests require authentication • We will be using a client to avoid implementing the OAuth dance ourselves • https://dev.twitter.com/docs/api
gonna get you all set up to use My App Name. In the web browser window that opens please choose to Allow access. Copy the PIN number that appears on the next page and paste or type it here: Opening: https://api.twitter.com/oauth/authorize? oauth_token=vNgKqIkvgL4Ci0WKWLf4trB73rA2KGgNJsdsVYmGpLY Please enter the PIN: Created new window in existing browser session.
of http modules: - urllib, urllib2, httplib2, pycurl - This is due to a varied number of historical reasons but we will be using “Requests” as the most concise HTTP library to consume APIs http://docs.python-requests.org/en/latest/