Application Programming Interfaces (APIs)
What is an API?
- API stands for Application Programming Interface
- A way for one computer to access the functionality of a service or application on another computer.
- A set of rules that allows one software application to interact with another.
Why use an API?
- Access to data: APIs allow you to access data from other services or applications.
- Automation: APIs allow you to automate tasks that would otherwise be manual.
- Integration: APIs allow you to integrate different services or applications.
API for our purposes: Access Databases
- Databases run on servers and are not directly accessible from the web.
- Databases have their own language.
- The web has its own language.
- The API is a translator between the language of the web and the language of the database.
Server/Cloud Architecture
- Client: User’s computer or device.
- Server: Computer hosting the database / API.
- API: accessible through the port (doorway) 8443 (or other).
- Database: accessible through the port 5432 (or other).
Server/Cloud Architecture, cont.
- API accepts a route and/or query parameters in a URL.
- What are query parameters? (I’ll show you in a moment.)
- Query parameters communicate what to get from database.
- API responds with info from database.
URL & Parameters
- www.example.com/api/v1/data?param1=value1¶m2=value2
- base URL: www.example.com/
- route/path: api/v1/data
- ?: start of query parameters
- query parameters: param1=value1¶m2=value2
- param1: key
- value1: value
- &: separator between parameters
Accessing APIs
- All information on the web is accessable.
- Some information is documented and open.
- Documented APIs are easier to access.
- Undocumented APIs can be accessed via web scraping.
- Ethical Considerations
For Friday
- Find an online database or API that you would like to access (related to your domain).
- Some are protected, that’s okay.
- If protected, read the documentation to see how to access the data.
- It should be related to your domain somehow.
For Friday, cont.
- In class on Friday, your domain group will compare and contrast the APIs you found.
- You will present on the API (or group of APIs if they could be combined somehow) you chose is most useful for your domain.
- If they could be combined, how so?
- What makes it/them particularly useful?
- What was the criteria you used to come to that conclusion?