Skip to content

Commit

Permalink
docs: quickstart fetcher client
Browse files Browse the repository at this point in the history
  • Loading branch information
EvolveArt committed Jul 6, 2024
1 parent 1a9d389 commit 4e781a3
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pragma-sdk/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
project = "pragma-sdk"
copyright = "2024, Pragma Labs"
author = "Pragma Labs"
release, version = get_version("Click")
release, version = get_version("pragma-sdk")


# -- General configuration ---------------------------------------------------
Expand Down
36 changes: 28 additions & 8 deletions pragma-sdk/docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,38 @@ This is a quickstart guide to get you up and running with the Pragma SDK.
Fetch data
---------------

To fetch data on 3rd parties API, one can use the `FetcherClient <pragma_sdk.common.fetchers>`.
To fetch data on 3rd parties API, one can use the `FetcherClient<pragma_sdk.common.fetchers>`.

Here is step by step example:

``` python
.. code-block:: python
```
from pragma_sdk.common.fetchers import FetcherClient
from pragma_sdk.common.fetchers.fetchers import BitstampFetcher, GateIOFetcher
# 1. Create a list of pairs that you want to fetch
pairs = [
Pair.from_tickers("BTC","USD"),
Pair.from_tickers("ETH","USD"),
]
# 2. Create your fetchers and add them to the FetcherClient
bitstamp_fetcher = BitstampFetcher(pairs, "publisher_test")
gateio_fetcher = GateIOFetcher(pairs, "publisher_test")
fetchers = [
bitstamp_fetcher,
gateio_fetcher,
]
fc = FetcherClient()
fc.add_fetchers(fetchers)
# 3. Fetch the data
entries = await fc.fetch()
.. hint::

If you are experiencing transaction failures with ``FEE_TRANSFER_FAILURE``
make sure that the address you are trying to deploy is prefunded with enough
tokens, and verify that ``max_fee`` argument in :meth:`~starknet_py.net.account.account.Account.sign_deploy_account_v1`
or ``l1_resource_bounds`` argument in :meth:`~starknet_py.net.account.account.Account.sign_deploy_account_v3` is set
to a high enough value.
If you are experiencing issues with fetching, it's most likely due to the fetcher not being able to connect to the API.
Some fetchers do require ``api_key`` keyword argument in their constructor.
Please refer to the fetcher's documentation for more information.
Also if you want to fetch data synchronously, you can use the :meth:`fetch_sync` method.
9 changes: 7 additions & 2 deletions pragma-sdk/pragma_sdk/common/fetchers/fetcher_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ class FetcherClient:
The client works by setting up fetchers that are provided the assets to fetch and the publisher name.
```python
bitstamp_fetcher = BitstampFetcher(ALL_ASSETS_CONFIGS, "publisher_test")
gateio_fetcher = GateIOFetcher(ALL_ASSETS_CONFIGS, "publisher_test")
pairs = [
Pair.from_tickers("BTC","USD"),
Pair.from_tickers("ETH","USD"),
]
bitstamp_fetcher = BitstampFetcher(pairs, "publisher_test")
gateio_fetcher = GateIOFetcher(pairs, "publisher_test")
fetchers = [
bitstamp_fetcher,
Expand Down
2 changes: 1 addition & 1 deletion pragma-sdk/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pragma-sdk"
version = "1.4.7"
version = "2.0.0.rc-0"
authors = ["0xevolve <matthias@pragma.build>"]
description = "Core package for rollup-native Pragma Oracle"
readme = "README.md"
Expand Down

0 comments on commit 4e781a3

Please sign in to comment.