santiment / sanpy

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

Add get_many to work with timeseries_data_per_slug #155

Closed IvanIvanoff closed 1 year ago

IvanIvanoff commented 1 year ago

Changes

Add san.get_many function:

>>> import san
>>> san.get_many("daily_active_addresses", slugs=['ethereum', 'bitcoin', 'uniswap'], from_date='2022-02-02', to_date='2022-02-05')

datetime                                     bitcoin        ethereum    uniswap                               
2022-02-02 00:00:00+00:00  970442.0  509158.0    759.0
2022-02-03 00:00:00+00:00  928382.0  486902.0   922.0
2022-02-04 00:00:00+00:00  883889.0  527781.0    936.0
2022-02-05 00:00:00+00:00  956375.0  596015.0    974.0

Add get_many method to the AsyncBatch class:

from san import AsyncBatch

batch = AsyncBatch()

batch.get(
    "daily_active_addresses",
    slug="santiment",
    from_date="2018-06-01",
    to_date="2018-06-05",
    interval="1d"
)
batch.get_many(
    "daily_active_addresses",
    slugs=["bitcoin", "ethereum"],
    from_date="2018-06-01",
    to_date="2018-06-05",
    interval="1d"
)
[daa, daa_many] = batch.execute(max_workers=10)