- You already use it in daily internet browsing!
- Accessing data
- Analysis Services (e.g., translation api)
- YouTube playlist from Code.org
- Protocols (http)
- An API (application programming interface) is how applications talk to each other on the internet
- Client (e.g., your phone, your computer, some other device) sends a request
- Server (e.g., data service, cloud service) sends a response
- Response will contain a status code (see list)
- GET: Get data
- Parameters are included in URL
- POST: Modify data
- Parameters are included in request body
- JSON: Contains key-value pairs
- Header: Parameters that are consistent each time you send a request (e.g., authentication information)
- Body: Parameters that change based on what you need.
- Local API
- Postman: Great for demos. Not required for development.
- R: httr, jsonlite, r lists
- Public APIs
- Documentation
- URL
- GET vs POST
- parameters (what goes into header vs body)
- authentication
- usage limits
- Documentation
- Find a Public API and its documentation (preferably no authentication required)
- Try to connect to it using R
- A few demos afterwards of ones that don't require authentication
- Authentication tokens: Don't share them and keep them safe!
- Webscraping: Not always legal. There's a reason some sites don't offer data through APIs.
- Security: If you are loading data to a service, make sure it doesn't contain PHI/PII.