GitHub - amentumspace/async_api_caller: Neat Python package that abstracts away complexity of making asynchronous API calls in Python for common use case of high volume of calls with parameters that change between calls.

1 min read Original article ↗

Making asynchronous web API calls using asyncio is pretty complicated. This package abstracts away complexity for the common case of needing to make multiple web API calls while varying query parameters.

import async_api_caller
url = "https://ocean.amentum.io/gebco"
headers = {'API-Key': API_KEY}
param_list = [
    {
        "latitude": 42,
        "longitude": 42
    },{
        "latitude": 43,
        "longitude": 43
    }
]

responses_json = async_api_caller.run(
    url, headers, param_list
)

To avoid making duplicate API calls to metered APIs, responses are automatically cached in a sqlite database cache.db. Delete the file to refresh it.