120 likes | 137 Views
Learn about HTTP protocol, Web APIs, and practice activities including coding demos of various APIs. Gain practical skills in working with JSON data and accessing different web services efficiently.
E N D
IST256 : Applications Programming for Information Systems The HTTP Protocol and Web Services
Agenda • Connection Activity • Attendance • Teaching: • HTTP • Web Services • Practice Activities (3) • Thursday
Connect Activity • https://goo.gl/TJOuaW • Sign in with your NetID and Password • Enter Today’s PIN 9901
HTTP The Protocol of The Web • When you type a URL into your browser you’re making a request. • The site processing your request sends a response. • Part of the response is the status code. This indicates “what happened” • The other part of the response is content(HTML) which is rendered by the browser. • HTTP is a text based protocol.
Watch Me Code A Non-Python Demo of HTTP • What happens when you request a site? Like syr.edu?
What is a Web API? • An API is short for Application Programming Interface. • A Web API uses HTTP Protocolto communicate with your program. • Web API’s can return data in many formats. We’ll focus on the JSON (JavaScript Object Notation) format which converts easily to Python listsand dictionaries.
Watch Me Code Google’s Geocoding API • Get a GPS coordinate (Latitude and Longitude) for a City or Street Address • HTTP GET: http://maps.googleapis.com/maps/api/geocode/json?address=addr
Web API: Weather Forecasting • https://darksky.net/dev • Darksky.net / Forecast IO • Sign up for an API key • 1000 free requests / day
Watch Me Code Let’s Continue Our Geocode Example: • Get Current weather for Lat/Lng • Refactor as a function • Write a program to ask for a location, show current conditions for location!
Other Web API’s • https://itunes.apple.com/search?term - iTunes Search • https://swapi.co/ - Star Wars API • https://www.omdbapi.com/ - Movie Database API • http://www.pokeapi.co/ - Pokemon API • http://open-notify.org/ - Space API • http://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php- Earthquake API
Help me Code Let’s write a program to ask you for a sub-Reddit and then print the titles of the top stories in that sub-Reddit Example API Call: (news) sub-Reddit https://www.reddit.com/r/news/top.json • First we get it to work with this url • Then let’s write the full program
Conclusion Activity Your “Ticket Out” • http://bit.ly/2eBCPM7 • The activity will be effort graded.