API Request Cookbook

#Database  

image

Context

Over the years I’ve had to get overly familiar with API requests, and have reimplemented the same design pattern across multiple projects involving the retrieval, processing and display of API data.

This article is a collection of these common workflows.

In Python 🐍

Useful Libraries

1import requests
2import pandas as pd
3import json

Reference: https://requests.readthedocs.io/en/latest/api/

API Calls

1endpoint = "http://www.datasources.com"
2response = requests.get(endpoint)
3data = response.json()

API Calls with Base64 Auth

API Calls over Proxy

API Call Caching

API Data Processing

API Data File Write