APIs, REST, PUSH (Tue Nov 7, lecture 28)

Homework due for today

Legend: : Participation | : Early | : PDF | : Portfolio | : Zipped

  1. Read and do: Articles and do steps below: * RESTful Web Services * Download and install this WebService Demo Code to your computer. Look at all the examples and get them to work. Understand what they are doing. * Download and install a REST Client app. For example rest-client or Chrome Advanced Rest Client * Familiarize yourself with one or two real Web Services (also called Web APIs or APIs). Here are some interesting starting points:
    1. Everything known about wine: Wine.com API
    2. Open Government Data: Sunlight Foundation API
    3. APIs of cooking recipes: Yummly
    4. Reddit API
    5. US Census Bureau
    6. Weather Information
    7. A huge directory of all kinds of web services: Programmable Web * Most web services (APIs) need an API-key of some kind (free). Get one * Experiment with the REST client and one of the Web services described above * Using the REST client app above: try some calls and get them to work * Deliverable: A post describing your experience. What api you tried and what you learned. And describing one specific way in which your product could use a Web Service API
  2. Read: About Feature Toggles, and about WebSockets and ActionCables
  3. PR Meetings coming up! Target your PR meeting for April 3, during lab time: between 2 and 5. You should get in touch with them asap!
  4. Prod Update with Pito: On April 3d I would like to have 45 minute conversations with each team separately so I can hear your thinking, see your progress, and give you some suggestions or ideas as they come up. Please schedule the time with me using this link: Pito Product Update Meetings. You will only see time slots for Monday. If you absolutely cannot make it Monday, talk to me. Otherwise, I expect to see each team individually at the selected time. The sooner you sign up on the calendly link the more flexibility you will have on the time!

Creating a WEB Service

Accessing a web service

  • Accessing and testing out a Web Api before using it
  • Writing throw away code (“spikes”)
  • Use a gem or build a gem: isolation
  • Don’t be scared: How to look inside a gem at its code (see gem gem-open)
  • If the gem doesn’t do what you need, look for another one!
  • Discuss the exmples in ruby Web Service Demo Code

Web PUSH Capability

  • Defined
  • Often used in conjunction with AJAX
Websockets
  • Websockets: Why are they needed?
ActionCable
  • Rails: ActionCable: Railsification of Websockets
  • Heroku Demo
  • Uses system cache software called “Redis”
  • Rails Server also acts as a WebSockets server
  • Channel:
    • Communication channel, carrying “messages”
    • Analogous to a Controller
    • Can stream messages to subscribers
  • Message
    • A packet of JSON sent from the server back to the client
    • Analogous to an action
  • Consumer
    • Usually it is the web browser of a user
    • It can subscribe to messages from a certain channel
  • An example that I found useful: Real Time Rails, WebSockets

Look at next class