santiment / sanpy

Santiment API Python Client
MIT License
94 stars 29 forks source link

Add async batch #151

Closed IvanIvanoff closed 2 years ago

IvanIvanoff commented 2 years ago

Multiple queries can be executed in a batch to speed up the performance.

There are two batch classes provided - Batch and AsyncBatch.

Note: If you have been using Batch() and want to switch to the newer AsyncBatch() you only need to change the batch initialization. The functions for adding queries and executing the batch, as well as the format of the response, are the same.

from san import AsyncBatch

batch = AsyncBatch()

batch.get(
    "daily_active_addresses/santiment",
    from_date="2018-06-01",
    to_date="2018-06-05",
    interval="1d"
)
batch.get(
    "transaction_volume/santiment",
    from_date="2018-06-01",
    to_date="2018-06-05",
    interval="1d"
)
[daa, trx_volume] = batch.execute(max_workers=10)
robcaulk commented 2 years ago

This is a very needed feature - thank you for implementing.