sbdata package#
Submodules#
sbdata.FlipsideApi module#
- class sbdata.FlipsideApi.FlipsideApi(api_key, max_age_minutes=30, ttl=30, timeout_minutes=5, retry_interval=1, page_size=100000, page_number=1, max_address=100, cached=True)[source]#
Bases:
objectThis class is used to query the flipside crypto api It has methods to easily retrieve the data and save it to csv
- execute_query(sql)[source]#
Execute a query and return a pandas dataframe, it will automatically query all the pages using class parameters. :param sql: The sql query to execute :type sql: str
- Returns:
df – The dataframe containing the results of the query
- Return type:
pandas dataframe
- static export_address(df, np_address, extract_dir, network)[source]#
Export the dataframe to a csv file
Change the idea and exporting straight to an account based csv for easier csv manipulation from other tools If there is no transactions them the file is not created, creating empty file is useless. :param df: Dataframe containing the transactions of potentially many addresses :type df: pd.DataFrame :param np_address: Array containing the addresses :type np_address: numpy.ndarray :param extract_dir: Directory where to export the csv file :type extract_dir: str :param network: Network of the transactions :type network: str
- extract_transactions(extract_dir, array_address)[source]#
Extract the transactions contained in array_address for all the networks and save them to csv in the extract_dir
- Parameters:
extract_dir (str) – The directory where to save the csv files
array_address (array) – The array of addresses to extract
- Returns:
Create csv files in the extract_dir
- Return type:
None
- extract_transactions_between_rec(array_address, start_index, end_index, network, extract_dir)[source]#
Recursive method to extract the transactions for the array of addresses and the network in a df It is used to retry with smaller query if the query timeout or the max rows are reached :param array_address: The array of addresses to extract :type array_address: array :param start_index: The start index of the array_address :type start_index: int :param end_index: The end index of the array_address :type end_index: int :param network: The network to extract the transactions from :type network: str :param extract_dir: The directory where to save the csv files :type extract_dir: str
- Return type:
None
- extract_transactions_net(extract_dir, array_address, network)[source]#
Extract the transactions contained in array_address for the network and save them to csv in the extract_dir Each csv is named as eoa_tx.csv and is stored in a folder named after the network
- Parameters:
extract_dir (str) – The directory where to save the csv files
array_address (array) – The array of addresses to extract
network (str) – The network to extract the transactions from
- Returns:
Create csv files in the extract_dir
- Return type:
None
- extract_transactions_rec(array_address, start_index, end_index, network, extract_dir)[source]#
Recursive method to extract the transactions for the array of addresses and the network in a df It is used to retry with smaller query if the query timeout or the max rows are reached :param array_address: The array of addresses to extract :type array_address: array :param start_index: The start index of the array_address :type start_index: int :param end_index: The end index of the array_address :type end_index: int :param network: The network to extract the transactions from :type network: str :param extract_dir: The directory where to save the csv files :type extract_dir: str
- Return type:
None
- get_arbitrum_transactions_sql_query(array_address, limit=0)[source]#
Get the sql query to extract the transactions for the array of addresses and arbitrum network :param array_address: The array of addresses to extract :type array_address: array :param limit: The limit of the query default 0 everything is retrieved. The limit is the Keyword LIMIT in SQL. :type limit: int
- Returns:
sql – The sql query to execute
- Return type:
str
- get_avalanche_transactions_sql_query(array_address, limit=0)[source]#
Get the sql query to extract the transactions for the array of addresses and avalanche network :param array_address: The array of addresses to extract :type array_address: array :param limit: The limit of the query default 0 everything is retrieved. The limit is the Keyword LIMIT in SQL. :type limit: int
- Returns:
sql – The sql query to execute
- Return type:
str
- get_cross_chain_info_sql_query(array_address, info_type='label', limit=0)[source]#
Get the sql query to extract the cross chain labels or tags for the array of addresses. WARNING you should not provide too many addresses in the array_address parameter because the query may time out. :param array_address: The array of addresses to extract :type array_address: array :param info_type: The type of info to extract. It can be “label” or “tag” :type info_type: str :param limit: The limit of the query default 0 everything is retrieved. The limit is the Keyword LIMIT in SQL. :type limit: int
- Returns:
sql – The sql query to execute
- Return type:
str
- get_eth_transactions_sql_query(array_address, limit=0)[source]#
Get the sql query to extract the transactions for the array of addresses and ethereum network :param array_address: The array of addresses to extract :type array_address: array :param limit: The limit of the query default 0 everything is retrieved. The limit is the Keyword LIMIT in SQL. :type limit: int
- Returns:
sql – The sql query to execute
- Return type:
str
- get_gnosis_transactions_sql_query(array_address, limit=0)[source]#
Get the sql query to extract the transactions for the array of addresses and gnosis network :param array_address: The array of addresses to extract :type array_address: array :param limit: The limit of the query default 0 everything is retrieved. The limit is the Keyword LIMIT in SQL. :type limit: int
- Returns:
sql – The sql query to execute
- Return type:
str
- get_optimism_transactions_sql_query(array_address, limit=0)[source]#
Get the sql query to extract the transactions for the array of addresses and optimism network :param array_address: The array of addresses to extract :type array_address: array :param limit: The limit of the query default 0 everything is retrieved. The limit is the Keyword LIMIT in SQL. :type limit: int
- Returns:
sql – The sql query to execute
- Return type:
str
- get_polygon_transactions_sql_query(array_address, limit=0)[source]#
Get the sql query to extract the transactions for the array of addresses and polygon network :param array_address: The array of addresses to extract :type array_address: array :param limit: The limit of the query default 0 everything is retrieved. The limit is the Keyword LIMIT in SQL. :type limit: int
- Returns:
sql – The sql query to execute
- Return type:
str
- static get_price_feed_eth_ftm_sql_query(limit=0)[source]#
Get the sql query to extract the price feed for ethereum and fantom tokens starting from 2023-12-11 :param limit: The limit of the query default 0 everything is retrieved. The limit is the Keyword LIMIT in SQL. :type limit: int
- static get_string_address(array_address)[source]#
Get the string of the array of addresses to use in the sql query :param array_address: :type array_address: array
- Returns:
lower_str – The string to use in the sql query
- Return type:
str
- get_transactions(array_address, network)[source]#
Get the transactions for the array of addresses and the network in a df
- Parameters:
array_address (array) – The array of addresses to extract
network (str) – The network to extract the transactions from
- Returns:
df – The dataframe containing the transactions
- Return type:
pandas dataframe