Download presentation
Presentation is loading. Please wait.
Published byともみ きちや Modified over 6 years ago
1
IST256 : Applications Programming for Information Systems
API’s
2
Agenda Connection Activity Teaching: Practice Activities (3)
HTTP Kahoot! Teaching: API’s, Python Wrappers, Package management, OAUTH Practice Activities (3) Thursday
3
Kahoot!: Connect Activity
Let’s review HTTP and Python requests with a game of Kahoot!
4
API == Application Program Interface
An API represents a contract for how one software application should interact with another. They allow programs to interact with each other without human intervention. The application which uses the API is called the consumer. The application which supplies the API is called the provider. API’s are an important part of the web. They allow various services to be connected to each other. A Program which combines API’s to accomplish a task is known as a Mash-Up.
5
API’s R Awesum! Leverage the power of the Internet to do almost anything! If you can USE it on a web page or mobile phone It probably has an API! Whether or not you can access the API is up to the provider. Not all API’s are free.
6
How do I determine if the service I want to use has an API?
7
Spend some time digging…
8
Where can discover API’s to use?
9
A Registry of API’s http://www.programmableweb.com/
15,000 + API’s to search through Includes source code examples for how to use a.k.a. “Consume” the api. Links to the API Documentation
10
Do I have to use requests and json to consume my API?
11
Nope! Try a Package (PyPi)
PyPi is the Python Package index. It is a repository of Python packages. Packages are code others have written which accomplish a variety of tasks, including make it easier to work with API’s! When you find a package you want installed on your system, use the pip command from a terminal / command prompt.
12
PyPi: The Python Package Index
A Repository of Python Packages which you can download and install on your system. Use the pip command from the command line to install the package you
13
Code With Me ! Follow along as we type some pip commands
Open a command prompt or terminal window $ pip list $ pip search praw $ pip install praw $ pip show praw Short and sweet demo
14
Watch Me Code Reddit.com API bake-off DIY vs. Package requests praw VS
Short and sweet demo
15
API Comparison: DIY vs. Wrapper Package
DIY: import requests Wrapper: import praw Pros No abstractions: You know exactly what its doing Cons More code You must figure out how to crawl the JSON output Pros Less code At lot of work is done for you Cons You have to learn how to use each module
16
Summary: How to use whatever in Python!
Find the API for whatever Visit or whatever’s website or google “whatever api” Look over the API documentation for whatever to understand how it works. (If whatever does not have an API, you’re out of luck for now) Search PiPy for whatever to find a suitable package. Review the documentation so you understand how to use it. If the whatever API has a Python Package use it! Install package using pip from the command line. Else fallback to using requests.
17
Help me Code Let’s write a program to ask you for food choice and a location then uses the Yelp! API to find restaurants at the location.
18
Your “Ticket Out” Conclusion Activity http://bit.ly/2eBCPM7
The activity will be effort graded.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.