Skip to content

Commit

Permalink
PLAT-1354 Add catalog-v2/blockchain endpoints
Browse files Browse the repository at this point in the history
This MR adds missing catalog-v2/blockchain endpoints
  • Loading branch information
victoreram committed Dec 11, 2024
1 parent 1119385 commit 35e0177
Show file tree
Hide file tree
Showing 2 changed files with 304 additions and 0 deletions.
256 changes: 256 additions & 0 deletions coinmetrics/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4479,6 +4479,262 @@ def catalog_full_transaction_tracker_assets_v2(
}
return CatalogV2DataCollection(self._get_data, "catalog-all-v2/transaction-tracker", params, client=self)

def catalog_blockchain_accounts_v2(
self,
assets: Optional[Union[str, List[str]]] = None,
page_size: Optional[int] = None,
paging_from: Optional[str] = None,
next_page_token: Optional[str] = None,
format: Optional[str] = "json_stream",
) -> CatalogV2DataCollection:
"""
:param assets: Comma separated list of assets. By default all assets are returned.
:type assets: Optional[Union[str, List[str]]]
:param page_size: Number of items per single page of results.
:type page_size: Optional[int]
:param paging_from: Where does the first page start, at the start of the interval or at the end.
:type paging_from: Optional[str]
:param next_page_token: Token for receiving the results from the next page of a query. Should not be used directly. To iterate through pages just use `next_page_url` response field.
:type next_page_token: Optional[str]
:param format: Default: "json_stream" (Python API Client). Format of the response. Supported values are json, json_stream. Setting format='json_stream' is generally more performant. page_size is ignored when format='json_stream'.
:type format: Optional[str]
:return: List of blockchain-v2/accounts assets
:rtype: CatalogV2DataCollection
"""
params: Dict[str, Any] = {
"assets": assets,
"page_size": page_size,
"paging_from": paging_from,
"next_page_token": next_page_token,
"format": format
}
return CatalogV2DataCollection(self._get_data, "catalog-v2/blockchain-v2/accounts", params, client=self)

def catalog_blockchain_balance_updates_v2(
self,
assets: Optional[Union[str, List[str]]] = None,
page_size: Optional[int] = None,
paging_from: Optional[str] = None,
next_page_token: Optional[str] = None,
format: Optional[str] = "json_stream",
) -> CatalogV2DataCollection:
"""
:param assets: Comma separated list of assets. By default all assets are returned.
:type assets: Optional[Union[str, List[str]]]
:param page_size: Number of items per single page of results.
:type page_size: Optional[int]
:param paging_from: Where does the first page start, at the start of the interval or at the end.
:type paging_from: Optional[str]
:param next_page_token: Token for receiving the results from the next page of a query. Should not be used directly. To iterate through pages just use `next_page_url` response field.
:type next_page_token: Optional[str]
:param format: Default: "json_stream" (Python API Client). Format of the response. Supported values are json, json_stream. Setting format='json_stream' is generally more performant. page_size is ignored when format='json_stream'.
:type format: Optional[str]
:return: List of blockchain-v2/balance-updates assets
:rtype: CatalogV2DataCollection
"""
params: Dict[str, Any] = {
"assets": assets,
"page_size": page_size,
"paging_from": paging_from,
"next_page_token": next_page_token,
"format": format
}
return CatalogV2DataCollection(self._get_data, "catalog-v2/blockchain-v2/balance-updates", params, client=self)

def catalog_blockchain_blocks_v2(
self,
assets: Optional[Union[str, List[str]]] = None,
page_size: Optional[int] = None,
paging_from: Optional[str] = None,
next_page_token: Optional[str] = None,
format: Optional[str] = "json_stream",
) -> CatalogV2DataCollection:
"""
:param assets: Comma separated list of assets. By default all assets are returned.
:type assets: Optional[Union[str, List[str]]]
:param page_size: Number of items per single page of results.
:type page_size: Optional[int]
:param paging_from: Where does the first page start, at the start of the interval or at the end.
:type paging_from: Optional[str]
:param next_page_token: Token for receiving the results from the next page of a query. Should not be used directly. To iterate through pages just use `next_page_url` response field.
:type next_page_token: Optional[str]
:param format: Default: "json_stream" (Python API Client). Format of the response. Supported values are json, json_stream. Setting format='json_stream' is generally more performant. page_size is ignored when format='json_stream'.
:type format: Optional[str]
:return: List of blockchain-v2/blocks assets
:rtype: CatalogV2DataCollection
"""
params: Dict[str, Any] = {
"assets": assets,
"page_size": page_size,
"paging_from": paging_from,
"next_page_token": next_page_token,
"format": format
}
return CatalogV2DataCollection(self._get_data, "catalog-v2/blockchain-v2/blocks", params, client=self)

def catalog_blockchain_transactions_v2(
self,
assets: Optional[Union[str, List[str]]] = None,
page_size: Optional[int] = None,
paging_from: Optional[str] = None,
next_page_token: Optional[str] = None,
format: Optional[str] = "json_stream",
) -> CatalogV2DataCollection:
"""
:param assets: Comma separated list of assets. By default all assets are returned.
:type assets: Optional[Union[str, List[str]]]
:param page_size: Number of items per single page of results.
:type page_size: Optional[int]
:param paging_from: Where does the first page start, at the start of the interval or at the end.
:type paging_from: Optional[str]
:param next_page_token: Token for receiving the results from the next page of a query. Should not be used directly. To iterate through pages just use `next_page_url` response field.
:type next_page_token: Optional[str]
:param format: Default: "json_stream" (Python API Client). Format of the response. Supported values are json, json_stream. Setting format='json_stream' is generally more performant. page_size is ignored when format='json_stream'.
:type format: Optional[str]
:return: List of blockchain-v2/transactions assets
:rtype: CatalogV2DataCollection
"""
params: Dict[str, Any] = {
"assets": assets,
"page_size": page_size,
"paging_from": paging_from,
"next_page_token": next_page_token,
"format": format
}
return CatalogV2DataCollection(self._get_data, "catalog-v2/blockchain-v2/transactions", params, client=self)

def catalog_full_blockchain_accounts_v2(
self,
assets: Optional[Union[str, List[str]]] = None,
page_size: Optional[int] = None,
paging_from: Optional[str] = None,
next_page_token: Optional[str] = None,
format: Optional[str] = "json_stream",
) -> CatalogV2DataCollection:
"""
:param assets: Comma separated list of assets. By default all assets are returned.
:type assets: Optional[Union[str, List[str]]]
:param page_size: Number of items per single page of results.
:type page_size: Optional[int]
:param paging_from: Where does the first page start, at the start of the interval or at the end.
:type paging_from: Optional[str]
:param next_page_token: Token for receiving the results from the next page of a query. Should not be used directly. To iterate through pages just use `next_page_url` response field.
:type next_page_token: Optional[str]
:param format: Default: "json_stream" (Python API Client). Format of the response. Supported values are json, json_stream. Setting format='json_stream' is generally more performant. page_size is ignored when format='json_stream'.
:type format: Optional[str]
:return: Full list of blockchain-v2/accounts assets
:rtype: CatalogV2DataCollection
"""
params: Dict[str, Any] = {
"assets": assets,
"page_size": page_size,
"paging_from": paging_from,
"next_page_token": next_page_token,
"format": format
}
return CatalogV2DataCollection(self._get_data, "catalog-all-v2/blockchain-v2/accounts", params, client=self)

def catalog_full_blockchain_balance_updates_v2(
self,
assets: Optional[Union[str, List[str]]] = None,
page_size: Optional[int] = None,
paging_from: Optional[str] = None,
next_page_token: Optional[str] = None,
format: Optional[str] = "json_stream",
) -> CatalogV2DataCollection:
"""
:param assets: Comma separated list of assets. By default all assets are returned.
:type assets: Optional[Union[str, List[str]]]
:param page_size: Number of items per single page of results.
:type page_size: Optional[int]
:param paging_from: Where does the first page start, at the start of the interval or at the end.
:type paging_from: Optional[str]
:param next_page_token: Token for receiving the results from the next page of a query. Should not be used directly. To iterate through pages just use `next_page_url` response field.
:type next_page_token: Optional[str]
:param format: Default: "json_stream" (Python API Client). Format of the response. Supported values are json, json_stream. Setting format='json_stream' is generally more performant. page_size is ignored when format='json_stream'.
:type format: Optional[str]
:return: Full list of blockchain-v2/balance-updates assets
:rtype: CatalogV2DataCollection
"""
params: Dict[str, Any] = {
"assets": assets,
"page_size": page_size,
"paging_from": paging_from,
"next_page_token": next_page_token,
"format": format
}
return CatalogV2DataCollection(self._get_data, "catalog-all-v2/blockchain-v2/balance-updates", params, client=self)

def catalog_full_blockchain_blocks_v2(
self,
assets: Optional[Union[str, List[str]]] = None,
page_size: Optional[int] = None,
paging_from: Optional[str] = None,
next_page_token: Optional[str] = None,
format: Optional[str] = "json_stream",
) -> CatalogV2DataCollection:
"""
:param assets: Comma separated list of assets. By default all assets are returned.
:type assets: Optional[Union[str, List[str]]]
:param page_size: Number of items per single page of results.
:type page_size: Optional[int]
:param paging_from: Where does the first page start, at the start of the interval or at the end.
:type paging_from: Optional[str]
:param next_page_token: Token for receiving the results from the next page of a query. Should not be used directly. To iterate through pages just use `next_page_url` response field.
:type next_page_token: Optional[str]
:param format: Default: "json_stream" (Python API Client). Format of the response. Supported values are json, json_stream. Setting format='json_stream' is generally more performant. page_size is ignored when format='json_stream'.
:type format: Optional[str]
:return: Full list of blockchain-v2/blocks assets
:rtype: CatalogV2DataCollection
"""
params: Dict[str, Any] = {
"assets": assets,
"page_size": page_size,
"paging_from": paging_from,
"next_page_token": next_page_token,
"format": format
}
return CatalogV2DataCollection(self._get_data, "catalog-all-v2/blockchain-v2/blocks", params, client=self)

def catalog_full_blockchain_transactions_v2(
self,
assets: Optional[Union[str, List[str]]] = None,
page_size: Optional[int] = None,
paging_from: Optional[str] = None,
next_page_token: Optional[str] = None,
format: Optional[str] = "json_stream",
) -> CatalogV2DataCollection:
"""
:param assets: Comma separated list of assets. By default all assets are returned.
:type assets: Optional[Union[str, List[str]]]
:param page_size: Number of items per single page of results.
:type page_size: Optional[int]
:param paging_from: Where does the first page start, at the start of the interval or at the end.
:type paging_from: Optional[str]
:param next_page_token: Token for receiving the results from the next page of a query. Should not be used directly. To iterate through pages just use `next_page_url` response field.
:type next_page_token: Optional[str]
:param format: Default: "json_stream" (Python API Client). Format of the response. Supported values are json, json_stream. Setting format='json_stream' is generally more performant. page_size is ignored when format='json_stream'.
:type format: Optional[str]
:return: Full list of blockchain-v2/transactions assets
:rtype: CatalogV2DataCollection
"""
params: Dict[str, Any] = {
"assets": assets,
"page_size": page_size,
"paging_from": paging_from,
"next_page_token": next_page_token,
"format": format
}
return CatalogV2DataCollection(self._get_data, "catalog-all-v2/blockchain-v2/transactions", params, client=self)

def get_asset_alerts(
self,
assets: Union[List[str], str],
Expand Down
48 changes: 48 additions & 0 deletions test/test_catalogs_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,5 +605,53 @@ def test_catalogv2_index_levels() -> None:
assert all(['frequencies' in catalog for catalog in catalog_all_index_levels])


@pytest.mark.skipif(not cm_api_key_set, reason=REASON_TO_SKIP)
def test_catalogv2_blockchain_blocks() -> None:
catalog_blockchain_blocks = client.catalog_blockchain_blocks_v2()
catalog_full_blockchain_blocks = client.catalog_full_blockchain_blocks_v2()
assert all(['asset' in catalog for catalog in catalog_blockchain_blocks])
assert all(['asset' in catalog for catalog in catalog_full_blockchain_blocks])
assert all(['min_time' in catalog for catalog in catalog_blockchain_blocks])
assert all(['min_time' in catalog for catalog in catalog_full_blockchain_blocks])
assert all(['max_time' in catalog for catalog in catalog_blockchain_blocks])
assert all(['max_time' in catalog for catalog in catalog_full_blockchain_blocks])


@pytest.mark.skipif(not cm_api_key_set, reason=REASON_TO_SKIP)
def test_catalogv2_blockchain_accounts() -> None:
catalog_blockchain_accounts = client.catalog_blockchain_accounts_v2()
catalog_full_blockchain_accounts = client.catalog_full_blockchain_accounts_v2()
assert all(['asset' in catalog for catalog in catalog_blockchain_accounts])
assert all(['asset' in catalog for catalog in catalog_full_blockchain_accounts])
assert all(['min_time' in catalog for catalog in catalog_blockchain_accounts])
assert all(['min_time' in catalog for catalog in catalog_full_blockchain_accounts])
assert all(['max_time' in catalog for catalog in catalog_blockchain_accounts])
assert all(['max_time' in catalog for catalog in catalog_full_blockchain_accounts])


@pytest.mark.skipif(not cm_api_key_set, reason=REASON_TO_SKIP)
def test_catalogv2_blockchain_balance_updates() -> None:
catalog_blockchain_balance_updates = client.catalog_blockchain_balance_updates_v2()
catalog_full_blockchain_balance_updates = client.catalog_full_blockchain_balance_updates_v2()
assert all(['asset' in catalog for catalog in catalog_blockchain_balance_updates])
assert all(['asset' in catalog for catalog in catalog_full_blockchain_balance_updates])
assert all(['min_time' in catalog for catalog in catalog_blockchain_balance_updates])
assert all(['min_time' in catalog for catalog in catalog_full_blockchain_balance_updates])
assert all(['max_time' in catalog for catalog in catalog_blockchain_balance_updates])
assert all(['max_time' in catalog for catalog in catalog_full_blockchain_balance_updates])


@pytest.mark.skipif(not cm_api_key_set, reason=REASON_TO_SKIP)
def test_catalogv2_blockchain_transactions() -> None:
catalog_blockchain_transactions = client.catalog_blockchain_transactions_v2()
catalog_full_blockchain_transactions = client.catalog_full_blockchain_transactions_v2()
assert all(['asset' in catalog for catalog in catalog_blockchain_transactions])
assert all(['asset' in catalog for catalog in catalog_full_blockchain_transactions])
assert all(['min_time' in catalog for catalog in catalog_blockchain_transactions])
assert all(['min_time' in catalog for catalog in catalog_full_blockchain_transactions])
assert all(['max_time' in catalog for catalog in catalog_blockchain_transactions])
assert all(['max_time' in catalog for catalog in catalog_full_blockchain_transactions])


if __name__ == '__main__':
pytest.main()

0 comments on commit 35e0177

Please sign in to comment.