transpose-data


Nametranspose-data JSON
Version 4.2.0 PyPI version JSON
download
home_pagehttps://github.com/TransposeData/transpose-python-sdk
SummaryWeb3 Data Made Simple. Powerful APIs for accessing human-readable blockchain data at scale: from blocks and transactions to NFTs and tokens.
upload_time2024-02-28 05:16:25
maintainer
docs_urlNone
authorMichael Calvey (michaeljohncalvey), Alex Langshur (alangshur), Jonathan Becker (jon-becker), Patrick Croke (tannishmango)
requires_python
licenseMIT
keywords web3 data ethereum web3 data ethereum data
VCS
bugtrack_url
requirements requests pandas python-dotenv
Travis-CI No Travis.
coveralls test coverage
            ![Transpose Banner](https://files.readme.io/c019281-Main_Docs_Banners_v1.png)

# Welcome to the Transpose Python SDK
![Deployment Tests](https://github.com/TransposeData/transpose-python-sdk/actions/workflows/deployment_tests.yml/badge.svg) ![PyPI version](https://badge.fury.io/py/transpose-data.svg) ![Installations](https://img.shields.io/pypi/dd/transpose-data?color=g)

A modern python wrapper for the Transpose API Suite.

## Getting an API Key

To obtain a free Transpose API key, sign up on our [website](https://www.transpose.io/). Free tier keys have a rate limit of 1 request per second and 250,000 credits per month. If you need higher rate limits for your project or business, don't hesitate to reach out on our Discord or upgrade your tier directly in the webapp!

Join our [Discord](https://discord.gg/AKguqp3U57) to ask technical questions, share what you're building, and chat with others in the community.

## Installation

**Python 3.8 or higher is recommended**

To install the python SDK, you can run the following command:
```
python3 -m pip install -U transpose-data
```

---

## Documentation
You can find specific documentation on a per-product basis below.

|  Product  | Description                                                                                                                                                                                                                  | Documentation                                                                                   |
| :-------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| Block API | The Block API provides endpoints for accessing low-level blockchain data at scale, including accounts, blocks, transactions, internal transactions, and logs.                                                                | [Block API Docs](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/block.md) |
|  ENS API  | The ENS API provides endpoints for looking up ENS names (both historical and primary), resolving ENS names and records, and monitoring ENS transfers and sales.                                                              | [ENS API Docs](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/ens.md)     |
|  NFT API  | The NFT API provides endpoints for retrieving any collection and NFT in existence, as well as NFT images, operators, owners, transfers, approvals, and much more (fully supports both ERC-721 and ERC-1155 NFTs).            | [NFT API Docs](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/nft.md)     |
| Token API | The Token API provides endpoints for retrieving any token, token balance, transfer, and symbol in existence, including full support for native token transfers and balances (fully supports both ERC-20 and ERC-777 tokens). | [Token API Docs](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/token.md) |
| SQL API | The SQL API provides direct SQL access to our entire ecosystem of indexed blockchain data. Paired with our robust indexing pipeline, SQL access gives unlimited flexibility in how you mix, aggregate, and query activity across the blockchain.  | [SQL API Docs](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/sql.md) |
| Endpoint API | The Endpoint API provides customized REST endpoints that you can create, version, and use directly in your production applications. | [Endpoint API Docs](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/endpoint.md) |

## SDK Documentation
You can learn more about the Transpose SDK and how it works below.


### SDK Classes
The Transpose SDK uses custom classes to represent API responses:

#### Error Classes
<details>
<summary>SDK Error Class Specifications</summary>
The SDK uses the following error classes to represent API errors:

- ``TransposeBadRequest``
  - Represents a 400 Bad Request error from the Transpose API.
- ``TransposeRateLimit``
  - Represents a 429 Rate Limit error from the Transpose API.
- ``TransposeInvalidAPIKey``
  - Represents a 401 Unauthorized error from the Transpose API.
- ``TransposeInternalServerError``
  - Represents a 500 Internal Server Error error from the Transpose API.
- ``TransposeResourceNotFound``
  - Represents a 404 Not Found error from the Transpose API.

These errors will be raised when the SDK encounters an error from the Transpose API.
</details>

#### Response Classes (**DEPRECATED AS OF v3.1.0**)
<details>
<summary>Response Class Specifications</summary>

The SDK will always return a list of response objects from the Transpose API. For example, calling the ``ens.records_by_date`` endpoint will return a list of ``ENSRecord`` objects.

These response objects can be accessed in the following ways:
  - ``ENSRecord[0].ens_name`` will return the first record's ens_name.
  - ``ENSRecord[i].ens_name`` retrieves the ens_name from the i-th response
  
All response objects can also be accessed as a dictionary by calling ``.to_dict()`` on them:
  - ``ENSRecord[0].to_dict()`` will return the first record as a dictionary.
  - ``ENSRecord[i].to_dict()`` retrieves the i-th record as a dictionary.
</details>

---

## SDK Options
The Transpose SDK can be configured to your liking, allowing you to change the default behavior of the SDK.

### Updating Chain ID
<details>
<summary>
Updating SDK Working Chain ID
</summary>

If you want to change the chain ID of your query, you can do so by setting the `chain_id` or `chain` properties of the `Transpose` object. For example, if you want to query the Ethereum mainnet, you can do so by running the following code:

```python
from transpose import Transpose
api = Transpose(api_key="YOUR_API_KEY", chain_id=1)
```

or
```python
from transpose import Transpose
api = Transpose(api_key="YOUR_API_KEY", chain_id="ethereum")
```

if you wish to change the chain ID of an existing `Transpose` object, you can do so by running the following code:

```python
api.set_chain("ethereum")
```

or 

```python
api.set_chain(1)
```

#### Currently supported chains
| Chain ID | Chain Name |
| :------: | :--------: |
|    1     |  Ethereum  |
|   137    |  Polygon   |
</details>

### Raw JSON Responses
<details>
<summary>
Opt-in to raw JSON Responses
</summary>
If you wish to receive responses in JSON format, you can set the `json` parameter to `True` when initializing the SDK. This will return all responses as JSON objects.

**Response classes are considered deprecated as of v3.1.0 and will be removed in v4.0.0. JSON responses will become standard in v4.0.0**

```python
from transpose_sdk import Transpose
api = Transpose(api_key="YOUR_API_KEY", json=True)
```
</details>

### Pagination
<details>
<summary>Pagination with the Transpose SDK.</summary>

Transpose endpoints will return a maximum of 500 results in a single query. To return the next page, simply call ``api.next()``. If ``api.next()`` returns ``None``, then there are no more pages.

Here is a standard pagination implementation:

```python
while True:
    data = api.next()

    # sleep to avoid rate limits
    time.sleep(1)

    # if there are no more pages, exit loop
    if data is None: break

    # otherwise, print length of data
    else: print(len(data))
```
</details>

### Bulk Requests
<details>

<summary>Bulk requesting data with the Transpose SDK</summary>
Alongside pagination, we also offer a convenience method for iterating over all pages. This method will handle pagination for you, and will return a list of all results.

#### Usage:
```python
api.bulk_request(endpoint_response, requests_per_second, results_to_fetch)
```
| Parameter           | Required | Description                                                   | Type     |
| ------------------- | -------- | ------------------------------------------------------------- | -------- |
| endpoint_response   | Yes      | The called API function, which returns a list of data models. | ``List`` |
| requests_per_second | No       | The number of requests per second to make                     | ``int``  |
| results_to_fetch    | No       | The number of results to fetch                                | ``int``  |

#### Responses
| Code | Title                 | Model                                                                                                        |
| ---- | --------------------- | ------------------------------------------------------------------------------------------------------------ |
| 200  | Success               | Data Model                                                                                                   |
| 400  | Bad Request           | [Error](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/documentation.md#Error-Classes) |
| 401  | Unauthorized          | [Error](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/documentation.md#Error-Classes) |
| 403  | Forbidden             | [Error](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/documentation.md#Error-Classes) |
| 404  | Not Found             | [Error](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/documentation.md#Error-Classes) |
| 500  | Internal Server Error | [Error](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/documentation.md#Error-Classes) |

Here is an example of how to use ``bulk_request``:

```python
recent_blocks_since = api.bulk_request(api.block.blocks_by_date(added_after='2022-01-01 00:00:00', limit=500))

print(len(recent_blocks_since))

>>> 500
```
</details>

---

## SDK Extras
The following methods are available as extras to the Transpose SDK. 

You can import extras to your project by using:
```python
from transpose.extras import <MODULE>
```

Some extras will require additional dependencies to be installed. If you are missing dependencies, the SDK will throw a `TransposeDependencyError` when you try to import the extra. This error will tell you what dependencies are missing, and give you the exact command to install them:

```shell
transpose.src.util.errors.TransposeDependencyError: Missing Dependencies. You can install these via `pip install plotly kaleido`
```

### Plotting
<details>
<summary>Transpose Plotting Specifications</summary>

The SDK natively includes a plotting library which implements [plotly](https://plot.ly/python/). Using it, you can quickly create plots of data obtained through the Transpose API.

For a plotting example, check out the [demo](https://github.com/TransposeData/transpose-python-sdk/blob/main/demo/plotting.py) file, which will graph the past hour's gas prices in a bar chart.

![chart](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/images/plotting.png?fw)

#### Usage
You'll first need to install the plotting dependencies using:
```shell
pip install plotly kaleido
```

Instantiating a new plot is as simple as importing the ``Plot`` class and instantiating it:

```python
from transpose.extras import Plot
chart = Plot(title="Hourly Gas Prices on Ethereum")
```

This will return an object on which you can call the following methods:

- ``Plot.plotly()``
  - Returns the current plot as a plotly object. From there, you can further customize the plot.
  
- ``Plot.show()``
  - Renders the current plot in the browser. This plot is interactive, and can be zoomed and panned.
  
- ``Plot.render(path, format)``
  - Inputs:
    - ``path`` -> The path to render the plot to.
    - ``format`` -> The format to render the plot as. Can be either ``png``, ``html``, ``jpg``, etc.

- ``Plot.add_data(data, type, shape, smoothing)``

  - Inputs:
    - ``data`` -> The data to add to the plot. Takes the following format:
      
      ```json
      {
        "x":       [],                   // List of data
        "y":       [],                   // List of data
        "y_axis":  "Gas Price (Gwei)",   // OPTIONAL: The name of the y-axis
        "x_axis":  "Time",               // OPTIONAL: The name of the x-axis
      }
      ```
    - ``type`` -> OPTIONAL: The method used to render the data to the plot. Can be either ``line`` or ``bar``.
    - ``shape`` -> OPTIONAL: The shape of the line. Can be either ``linear``, ``spline``, ``vh``, ``hv``, ``vhv``, or ``hvh``.
    - ``smoothing`` -> OPTIONAL: The number of points to smooth the data with.
      - For ``line``, this will calculate a moving average of the data with a period of ``smoothing``.
      - For ``bar``, this will group and average the data over ``smoothing`` points.
</details>

---

## Making a Request

To get started and make your first request, make a new `Transpose` object:

```python
from transpose import Transpose

api = Transpose('transpose_api_key')
```

From there, you can call endpoints from the `api.nft`, `api.ens`, `api.token`, and `api.block` subclasses.

### Debugging Requests

You can view the raw HTTP requests the SDK is making by setting the `debug` flag to `True` when creating a new `Transpose` object. For example: 
```python
from transpose import Transpose

api = Transpose('transpose_api_key', debug=True)
```

## Simple Demo

To show just how powerful our data is, let's get the last ENS domain that expired. All we need is one API call.
```python
from transpose import Transpose

api = Transpose('transpose_api_key')

# get the most recently expired ENS domain
last_expired = api.ens.records_by_date(type='expiration', order='desc', limit=1)
```

This returns a list of [ENS Records](https://github.com/TransposeData/transpose-python-sdk/tree/main/docs/ens.md#ENS-Record-Model), which includes data which you wouldn't be able to easily get from the ENS protocol.

```json
[
  {
    "ens_name":"game-master-dit-gm.eth",
    "ens_node":"9BFFC8C1EDE1E51E4BAE137FA37A81CC0379FC08123C4AA00A931D0D983956B7",
    "contract_address":"0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85",
    "token_id":75929000750162030430773866845127925090084516346841580577625168871716954805188,
    "meta_block_number":407909,
    "owner":"0x2aC92629c4E0E5e4868588f87DC4356606a590b6",
    "resolver":"0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41",
    "resolved_address":"0x2aC92629c4E0E5e4868588f87DC4356606a590b6",
    "registration_timestamp":"2022-01-01T05:00:36Z",
    "expiration_timestamp":"2049-12-31T23:58:12Z",
    "grace_period_ends":"2050-03-31T23:58:12Z",
    "premium_period_ends":"2050-04-21T23:58:12Z",
    "in_grace_period":false,
    "in_premium_period":false,
    "is_expired":false,
    "last_refreshed":"2022-06-01T09:51:23Z"
  }
]
```

## Links

- [SDK Examples](https://github.com/TransposeData/transpose-python-sdk/tree/main/demo)
- [Transpose Documentation](https://docs.transpose.io)
- [Official Discord Server](https://discord.gg/AKguqp3U57)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/TransposeData/transpose-python-sdk",
    "name": "transpose-data",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "web3,data,ethereum,web3 data,ethereum data",
    "author": "Michael Calvey (michaeljohncalvey), Alex Langshur (alangshur), Jonathan Becker (jon-becker), Patrick Croke (tannishmango)",
    "author_email": "michael@transpose.io, alex@transpose.io, jon@transpose.io, patrick@transpose.io",
    "download_url": "https://files.pythonhosted.org/packages/99/de/3ddda4746e9e55ec7d81eaadc9155e9b379f00f3e5263196755d972b66ac/transpose_data-4.2.0.tar.gz",
    "platform": null,
    "description": "![Transpose Banner](https://files.readme.io/c019281-Main_Docs_Banners_v1.png)\n\n# Welcome to the Transpose Python SDK\n![Deployment Tests](https://github.com/TransposeData/transpose-python-sdk/actions/workflows/deployment_tests.yml/badge.svg) ![PyPI version](https://badge.fury.io/py/transpose-data.svg) ![Installations](https://img.shields.io/pypi/dd/transpose-data?color=g)\n\nA modern python wrapper for the Transpose API Suite.\n\n## Getting an API Key\n\nTo obtain a free Transpose API key, sign up on our [website](https://www.transpose.io/). Free tier keys have a rate limit of 1 request per second and 250,000 credits per month. If you need higher rate limits for your project or business, don't hesitate to reach out on our Discord or upgrade your tier directly in the webapp!\n\nJoin our [Discord](https://discord.gg/AKguqp3U57) to ask technical questions, share what you're building, and chat with others in the community.\n\n## Installation\n\n**Python 3.8 or higher is recommended**\n\nTo install the python SDK, you can run the following command:\n```\npython3 -m pip install -U transpose-data\n```\n\n---\n\n## Documentation\nYou can find specific documentation on a per-product basis below.\n\n|  Product  | Description                                                                                                                                                                                                                  | Documentation                                                                                   |\n| :-------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |\n| Block API | The Block API provides endpoints for accessing low-level blockchain data at scale, including accounts, blocks, transactions, internal transactions, and logs.                                                                | [Block API Docs](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/block.md) |\n|  ENS API  | The ENS API provides endpoints for looking up ENS names (both historical and primary), resolving ENS names and records, and monitoring ENS transfers and sales.                                                              | [ENS API Docs](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/ens.md)     |\n|  NFT API  | The NFT API provides endpoints for retrieving any collection and NFT in existence, as well as NFT images, operators, owners, transfers, approvals, and much more (fully supports both ERC-721 and ERC-1155 NFTs).            | [NFT API Docs](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/nft.md)     |\n| Token API | The Token API provides endpoints for retrieving any token, token balance, transfer, and symbol in existence, including full support for native token transfers and balances (fully supports both ERC-20 and ERC-777 tokens). | [Token API Docs](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/token.md) |\n| SQL API | The SQL API provides direct SQL access to our entire ecosystem of indexed blockchain data. Paired with our robust indexing pipeline, SQL access gives unlimited flexibility in how you mix, aggregate, and query activity across the blockchain.  | [SQL API Docs](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/sql.md) |\n| Endpoint API | The Endpoint API provides customized REST endpoints that you can create, version, and use directly in your production applications. | [Endpoint API Docs](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/endpoint.md) |\n\n## SDK Documentation\nYou can learn more about the Transpose SDK and how it works below.\n\n\n### SDK Classes\nThe Transpose SDK uses custom classes to represent API responses:\n\n#### Error Classes\n<details>\n<summary>SDK Error Class Specifications</summary>\nThe SDK uses the following error classes to represent API errors:\n\n- ``TransposeBadRequest``\n  - Represents a 400 Bad Request error from the Transpose API.\n- ``TransposeRateLimit``\n  - Represents a 429 Rate Limit error from the Transpose API.\n- ``TransposeInvalidAPIKey``\n  - Represents a 401 Unauthorized error from the Transpose API.\n- ``TransposeInternalServerError``\n  - Represents a 500 Internal Server Error error from the Transpose API.\n- ``TransposeResourceNotFound``\n  - Represents a 404 Not Found error from the Transpose API.\n\nThese errors will be raised when the SDK encounters an error from the Transpose API.\n</details>\n\n#### Response Classes (**DEPRECATED AS OF v3.1.0**)\n<details>\n<summary>Response Class Specifications</summary>\n\nThe SDK will always return a list of response objects from the Transpose API. For example, calling the ``ens.records_by_date`` endpoint will return a list of ``ENSRecord`` objects.\n\nThese response objects can be accessed in the following ways:\n  - ``ENSRecord[0].ens_name`` will return the first record's ens_name.\n  - ``ENSRecord[i].ens_name`` retrieves the ens_name from the i-th response\n  \nAll response objects can also be accessed as a dictionary by calling ``.to_dict()`` on them:\n  - ``ENSRecord[0].to_dict()`` will return the first record as a dictionary.\n  - ``ENSRecord[i].to_dict()`` retrieves the i-th record as a dictionary.\n</details>\n\n---\n\n## SDK Options\nThe Transpose SDK can be configured to your liking, allowing you to change the default behavior of the SDK.\n\n### Updating Chain ID\n<details>\n<summary>\nUpdating SDK Working Chain ID\n</summary>\n\nIf you want to change the chain ID of your query, you can do so by setting the `chain_id` or `chain` properties of the `Transpose` object. For example, if you want to query the Ethereum mainnet, you can do so by running the following code:\n\n```python\nfrom transpose import Transpose\napi = Transpose(api_key=\"YOUR_API_KEY\", chain_id=1)\n```\n\nor\n```python\nfrom transpose import Transpose\napi = Transpose(api_key=\"YOUR_API_KEY\", chain_id=\"ethereum\")\n```\n\nif you wish to change the chain ID of an existing `Transpose` object, you can do so by running the following code:\n\n```python\napi.set_chain(\"ethereum\")\n```\n\nor \n\n```python\napi.set_chain(1)\n```\n\n#### Currently supported chains\n| Chain ID | Chain Name |\n| :------: | :--------: |\n|    1     |  Ethereum  |\n|   137    |  Polygon   |\n</details>\n\n### Raw JSON Responses\n<details>\n<summary>\nOpt-in to raw JSON Responses\n</summary>\nIf you wish to receive responses in JSON format, you can set the `json` parameter to `True` when initializing the SDK. This will return all responses as JSON objects.\n\n**Response classes are considered deprecated as of v3.1.0 and will be removed in v4.0.0. JSON responses will become standard in v4.0.0**\n\n```python\nfrom transpose_sdk import Transpose\napi = Transpose(api_key=\"YOUR_API_KEY\", json=True)\n```\n</details>\n\n### Pagination\n<details>\n<summary>Pagination with the Transpose SDK.</summary>\n\nTranspose endpoints will return a maximum of 500 results in a single query. To return the next page, simply call ``api.next()``. If ``api.next()`` returns ``None``, then there are no more pages.\n\nHere is a standard pagination implementation:\n\n```python\nwhile True:\n    data = api.next()\n\n    # sleep to avoid rate limits\n    time.sleep(1)\n\n    # if there are no more pages, exit loop\n    if data is None: break\n\n    # otherwise, print length of data\n    else: print(len(data))\n```\n</details>\n\n### Bulk Requests\n<details>\n\n<summary>Bulk requesting data with the Transpose SDK</summary>\nAlongside pagination, we also offer a convenience method for iterating over all pages. This method will handle pagination for you, and will return a list of all results.\n\n#### Usage:\n```python\napi.bulk_request(endpoint_response, requests_per_second, results_to_fetch)\n```\n| Parameter           | Required | Description                                                   | Type     |\n| ------------------- | -------- | ------------------------------------------------------------- | -------- |\n| endpoint_response   | Yes      | The called API function, which returns a list of data models. | ``List`` |\n| requests_per_second | No       | The number of requests per second to make                     | ``int``  |\n| results_to_fetch    | No       | The number of results to fetch                                | ``int``  |\n\n#### Responses\n| Code | Title                 | Model                                                                                                        |\n| ---- | --------------------- | ------------------------------------------------------------------------------------------------------------ |\n| 200  | Success               | Data Model                                                                                                   |\n| 400  | Bad Request           | [Error](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/documentation.md#Error-Classes) |\n| 401  | Unauthorized          | [Error](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/documentation.md#Error-Classes) |\n| 403  | Forbidden             | [Error](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/documentation.md#Error-Classes) |\n| 404  | Not Found             | [Error](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/documentation.md#Error-Classes) |\n| 500  | Internal Server Error | [Error](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/documentation.md#Error-Classes) |\n\nHere is an example of how to use ``bulk_request``:\n\n```python\nrecent_blocks_since = api.bulk_request(api.block.blocks_by_date(added_after='2022-01-01 00:00:00', limit=500))\n\nprint(len(recent_blocks_since))\n\n>>> 500\n```\n</details>\n\n---\n\n## SDK Extras\nThe following methods are available as extras to the Transpose SDK. \n\nYou can import extras to your project by using:\n```python\nfrom transpose.extras import <MODULE>\n```\n\nSome extras will require additional dependencies to be installed. If you are missing dependencies, the SDK will throw a `TransposeDependencyError` when you try to import the extra. This error will tell you what dependencies are missing, and give you the exact command to install them:\n\n```shell\ntranspose.src.util.errors.TransposeDependencyError: Missing Dependencies. You can install these via `pip install plotly kaleido`\n```\n\n### Plotting\n<details>\n<summary>Transpose Plotting Specifications</summary>\n\nThe SDK natively includes a plotting library which implements [plotly](https://plot.ly/python/). Using it, you can quickly create plots of data obtained through the Transpose API.\n\nFor a plotting example, check out the [demo](https://github.com/TransposeData/transpose-python-sdk/blob/main/demo/plotting.py) file, which will graph the past hour's gas prices in a bar chart.\n\n![chart](https://github.com/TransposeData/transpose-python-sdk/blob/main/docs/images/plotting.png?fw)\n\n#### Usage\nYou'll first need to install the plotting dependencies using:\n```shell\npip install plotly kaleido\n```\n\nInstantiating a new plot is as simple as importing the ``Plot`` class and instantiating it:\n\n```python\nfrom transpose.extras import Plot\nchart = Plot(title=\"Hourly Gas Prices on Ethereum\")\n```\n\nThis will return an object on which you can call the following methods:\n\n- ``Plot.plotly()``\n  - Returns the current plot as a plotly object. From there, you can further customize the plot.\n  \n- ``Plot.show()``\n  - Renders the current plot in the browser. This plot is interactive, and can be zoomed and panned.\n  \n- ``Plot.render(path, format)``\n  - Inputs:\n    - ``path`` -> The path to render the plot to.\n    - ``format`` -> The format to render the plot as. Can be either ``png``, ``html``, ``jpg``, etc.\n\n- ``Plot.add_data(data, type, shape, smoothing)``\n\n  - Inputs:\n    - ``data`` -> The data to add to the plot. Takes the following format:\n      \n      ```json\n      {\n        \"x\":       [],                   // List of data\n        \"y\":       [],                   // List of data\n        \"y_axis\":  \"Gas Price (Gwei)\",   // OPTIONAL: The name of the y-axis\n        \"x_axis\":  \"Time\",               // OPTIONAL: The name of the x-axis\n      }\n      ```\n    - ``type`` -> OPTIONAL: The method used to render the data to the plot. Can be either ``line`` or ``bar``.\n    - ``shape`` -> OPTIONAL: The shape of the line. Can be either ``linear``, ``spline``, ``vh``, ``hv``, ``vhv``, or ``hvh``.\n    - ``smoothing`` -> OPTIONAL: The number of points to smooth the data with.\n      - For ``line``, this will calculate a moving average of the data with a period of ``smoothing``.\n      - For ``bar``, this will group and average the data over ``smoothing`` points.\n</details>\n\n---\n\n## Making a Request\n\nTo get started and make your first request, make a new `Transpose` object:\n\n```python\nfrom transpose import Transpose\n\napi = Transpose('transpose_api_key')\n```\n\nFrom there, you can call endpoints from the `api.nft`, `api.ens`, `api.token`, and `api.block` subclasses.\n\n### Debugging Requests\n\nYou can view the raw HTTP requests the SDK is making by setting the `debug` flag to `True` when creating a new `Transpose` object. For example: \n```python\nfrom transpose import Transpose\n\napi = Transpose('transpose_api_key', debug=True)\n```\n\n## Simple Demo\n\nTo show just how powerful our data is, let's get the last ENS domain that expired. All we need is one API call.\n```python\nfrom transpose import Transpose\n\napi = Transpose('transpose_api_key')\n\n# get the most recently expired ENS domain\nlast_expired = api.ens.records_by_date(type='expiration', order='desc', limit=1)\n```\n\nThis returns a list of [ENS Records](https://github.com/TransposeData/transpose-python-sdk/tree/main/docs/ens.md#ENS-Record-Model), which includes data which you wouldn't be able to easily get from the ENS protocol.\n\n```json\n[\n  {\n    \"ens_name\":\"game-master-dit-gm.eth\",\n    \"ens_node\":\"9BFFC8C1EDE1E51E4BAE137FA37A81CC0379FC08123C4AA00A931D0D983956B7\",\n    \"contract_address\":\"0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85\",\n    \"token_id\":75929000750162030430773866845127925090084516346841580577625168871716954805188,\n    \"meta_block_number\":407909,\n    \"owner\":\"0x2aC92629c4E0E5e4868588f87DC4356606a590b6\",\n    \"resolver\":\"0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41\",\n    \"resolved_address\":\"0x2aC92629c4E0E5e4868588f87DC4356606a590b6\",\n    \"registration_timestamp\":\"2022-01-01T05:00:36Z\",\n    \"expiration_timestamp\":\"2049-12-31T23:58:12Z\",\n    \"grace_period_ends\":\"2050-03-31T23:58:12Z\",\n    \"premium_period_ends\":\"2050-04-21T23:58:12Z\",\n    \"in_grace_period\":false,\n    \"in_premium_period\":false,\n    \"is_expired\":false,\n    \"last_refreshed\":\"2022-06-01T09:51:23Z\"\n  }\n]\n```\n\n## Links\n\n- [SDK Examples](https://github.com/TransposeData/transpose-python-sdk/tree/main/demo)\n- [Transpose Documentation](https://docs.transpose.io)\n- [Official Discord Server](https://discord.gg/AKguqp3U57)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Web3 Data Made Simple. Powerful APIs for accessing human-readable blockchain data at scale: from blocks and transactions to NFTs and tokens.",
    "version": "4.2.0",
    "project_urls": {
        "Homepage": "https://github.com/TransposeData/transpose-python-sdk"
    },
    "split_keywords": [
        "web3",
        "data",
        "ethereum",
        "web3 data",
        "ethereum data"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a4ffabc768c41121a244f2e272c719e5c5668d4f99daa1945dc205e40567939e",
                "md5": "e8d3d331c9e0e3106dcd5b10d773348e",
                "sha256": "823e7124c2cedeb2683abe79f215a5f4105ce44cdbd33e140e2d8172d8c80d41"
            },
            "downloads": -1,
            "filename": "transpose_data-4.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e8d3d331c9e0e3106dcd5b10d773348e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 49262,
            "upload_time": "2024-02-28T05:16:23",
            "upload_time_iso_8601": "2024-02-28T05:16:23.054278Z",
            "url": "https://files.pythonhosted.org/packages/a4/ff/abc768c41121a244f2e272c719e5c5668d4f99daa1945dc205e40567939e/transpose_data-4.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "99de3ddda4746e9e55ec7d81eaadc9155e9b379f00f3e5263196755d972b66ac",
                "md5": "55b9e6889910ae13642890e90f53711c",
                "sha256": "c430794910a9f8a929424515448334ab6e6c55b99b2a3653965b22659cf378c5"
            },
            "downloads": -1,
            "filename": "transpose_data-4.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "55b9e6889910ae13642890e90f53711c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 39185,
            "upload_time": "2024-02-28T05:16:25",
            "upload_time_iso_8601": "2024-02-28T05:16:25.872628Z",
            "url": "https://files.pythonhosted.org/packages/99/de/3ddda4746e9e55ec7d81eaadc9155e9b379f00f3e5263196755d972b66ac/transpose_data-4.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-28 05:16:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "TransposeData",
    "github_project": "transpose-python-sdk",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [
        {
            "name": "requests",
            "specs": []
        },
        {
            "name": "pandas",
            "specs": []
        },
        {
            "name": "python-dotenv",
            "specs": []
        }
    ],
    "lcname": "transpose-data"
}
        
Elapsed time: 0.27364s