Welcome to databar-python’s documentation!

Documentation

https://databar-python.readthedocs.io/

Source Code

https://github.com/databar-ai/databar-python

Issue Tracker

https://github.com/databar-ai/databar-python/issues

PyPI

https://pypi.org/project/databar-python/

Introduction

This is a official databar.ai python library. Using this package you can access databar.ai functionality from python.

Quickstart

databar package requires Python 3.8 or newer.

Installation:

pip install databar

To get started with databar-python, you need to have api-key.

Usage example:

import databar

connection = databar.Connection(api_key="<some_api_key>")
my_tables = connection.get_tables()
print(my_tables.data)

coingecko_data_table = connection.get_table(table_id=<coingecko_table_id>)
table_as_pandas_df = coingecko_data_table.as_pandas_df()

Classes

class databar.connection.PaginatedResponse(page: int, has_next_page: bool, data: List[Dict[str, Any]])

Result of request where pagination is used.

Parameters
  • page – Requested page number.

  • has_next_page – Boolean field to determine if there are more data.

  • data – Result of request. List of sources|datasets|api-keys|tables.

class databar.connection.Connection(api_key: str)
__init__(api_key: str) None

Init the connection.

If api_key is incorrect, ValueError will be raised.

Parameters

api_key – Api key from databar.ai

get_plan_info() None

Returns info about your plan. Namely, amount of credits, used storage size, total storage size, count of created tables. The result of this method is cached for 5 minutes.

list_of_sources(page: int = 1, search: Optional[str] = None) PaginatedResponse

Returns a list of available sources using pagination. One page stores 100 records.

Parameters
  • page – Page you want to retrieve. Default is 1.

  • search – Search query you want to apply, for example, Coingecko. Optional.

list_of_datasets(page: int = 1, search: Optional[str] = None, source_id: Optional[int] = None) PaginatedResponse

Returns a list of available datasets using pagination. One page stores 100 records.

Parameters
  • page – Page you want to retrieve. Default is 1.

  • search – Search query you want to apply, for example, Coingecko. Optional.

  • source_id – Id of source to filter datasets. Can be retrieved from list_of_sources(). If it’s passed, then will be returned only datasets of specific source. Optional.

list_of_api_keys(page: int = 1, source_id: Optional[int] = None) PaginatedResponse

Returns a list of api keys using pagination. One page stores 100 records.

Parameters
  • page – Page you want to retrieve. Default is 1.

  • source_id – Id of source to filter api keys. Can be retrieved from list_of_sources(). If it’s passed, then will be returned only api keys of specific source. Optional.

list_of_tables(page: int = 1) PaginatedResponse

Returns list of your tables using pagination. One page stores 100 records.

Parameters

page – Page you want retrieve. Default is 1.

get_table(table_id: int) Table

Returns specific table.

Parameters

table_id – Table id you want to get. List of tables can be retrieved using list_of_tables() method.

create_table_via_dataset(dataset_id: int) Table

Creates table via dataset.

get_params_of_dataset(dataset_id: int) Dict[str, Any]

Returns parameters of dataset. The result is info about authorization, pagination, query parameters of dataset.

calculate_price_of_request(dataset_id: int, params: Dict[str, Any], pagination: Optional[int] = None) float

Calculates price of request in credits.

Parameters
  • dataset_id – Id of dataset you want to calculate price.

  • params – Parameters which must be formed in according to dataset. Can be retrieved from get_params_of_dataset(). Pass empty dictionary if there are no parameters.

  • pagination – Count of rows|pages. Depends on what type of pagination dataset uses. If pagination type is based_on_rows, then count of rows must be sent, otherwise count of pages. If there is no pagination, nothing is required. Optional.

class databar.table.Table(session: Session, tid: int)

Bases: object

get_total_cost() float

Returns total cost of all requests

get_status() str

Returns status of requests.

Status types:
  • none - there are no requests.

  • failed - all requests are failed.

  • partially_completed - part of requests are failed|canceled, part of requests are successful.

  • completed - all requests are successful.

  • processing - requests are processing.

cancel_request()

Cancels processing request.

append_data(params: Dict[str, Any], pagination: Optional[int] = None, authorization_id: Optional[int] = None)

Appends data to table.

Parameters
  • params – Parameters which must be formed in according to dataset. Can be retrieved from get_params_of_dataset(). Pass empty dictionary if there are no parameters.

  • pagination – Count of rows|pages. Depends on what type of pagination dataset uses. If pagination type is based_on_rows, then count of rows must be sent, otherwise count of pages. If there is no pagination, nothing is required. Optional.

  • authorization_id – Id of api key. Can be retrieved from list_of_api_keys(). Pass only if it’s required by dataset. Optional.

as_pandas_df() DataFrame

Returns table as a pandas dataframe.