Skip to content

Commit

Permalink
Update README.md.
Browse files Browse the repository at this point in the history
  • Loading branch information
nessshon committed Jan 9, 2024
1 parent c880a26 commit 25827f7
Showing 1 changed file with 64 additions and 34 deletions.
98 changes: 64 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# PyTONAPI

[![PyPI](https://img.shields.io/pypi/v/pytonapi.svg)](https://pypi.python.org/pypi/pytonapi)
![Python Versions](https://img.shields.io/pypi/pyversions/pytonapi.svg)
![License](https://img.shields.io/github/license/nessshon/pytonapi)
[![TON](https://img.shields.io/badge/TON-grey?logo=TON&logoColor=40AEF0)](https://ton.org)
[![PyPI](https://img.shields.io/pypi/v/pytonapi.svg?color=FFE873&labelColor=3776AB)](https://pypi.python.org/pypi/pytonapi)
![Python Versions](https://img.shields.io/pypi/pyversions/pytonapi.svg?color=FFE873&labelColor=3776AB)
[![License](https://img.shields.io/github/license/tonkeeper/pytonapi)](https://github.com/tonkeeper/pytonapi/blob/main/LICENSE)

Python wrapper for [tonapi.io](https://tonapi.io/api-v2)\
**Note:** You need an API key to use it, get it here [tonconsole.com](https://tonconsole.com/)
![Downloads](https://pepy.tech/badge/pytonapi)
![Downloads](https://pepy.tech/badge/pytonapi/month)
![Downloads](https://pepy.tech/badge/pytonapi/week)

Python SDK for [tonapi.io](https://tonapi.io).\
Information about the API can be found in the [documentation](https://docs.tonconsole.com/tonapi/api-v2).\
To use the API **you need an API key**, you can get it here [tonconsole.com](https://tonconsole.com/).

## Features

Expand All @@ -22,40 +28,43 @@ Python wrapper for [tonapi.io](https://tonapi.io/api-v2)\
to nanotons or amounts.

- **Extensive Examples:**\
Explore a variety of examples in the [examples](examples) folder to help you get started and
Explore a variety of examples in the [examples](https://github.com/tonkeeper/pytonapi/tree/main/examples) folder to
help you get started and
understand different use cases.

## Dependencies

* [httpx](https://pypi.org/project/httpx/) - A fully featured HTTP client for Python 3, which provides sync and async
* [pydantic](https://pypi.org/project/pydantic/) - Data validation and settings management using Python type hints
* [libscrc](https://pypi.org/project/libscrc/) - Library for calculating CRC-16, CRC-CCITT, CRC-32 checksums
APIs
* [websockets](https://pypi.org/project/websockets/) - A library for building WebSocket servers and clients in Python

## Installation
## Usage

### Installation

```bash
pip install pytonapi
```

## Usage
### Examples

**Synchronous Example:**
<details>
<summary><b>Asynchronous</b></summary>

```python
from pytonapi import Tonapi
from pytonapi import AsyncTonapi


def main():
# Declare an asynchronous function for using await
async def main():
# Create a new Tonapi object with the provided API key
tonapi = Tonapi(api_key="Your API key")
tonapi = AsyncTonapi(api_key="Your API key")

# Specify the account ID
account_id = "EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess" # noqa

# Retrieve account information
account = tonapi.accounts.get_info(account_id=account_id)
# Retrieve account information asynchronously
account = await tonapi.accounts.get_info(account_id=account_id)

# Print account details
print(f"Account Address (raw): {account.address.to_raw()}")
Expand All @@ -65,26 +74,31 @@ def main():


if __name__ == '__main__':
main()
import asyncio

# Run the asynchronous function
asyncio.run(main())

```

**Asynchronous Example:**
</details>

<details>
<summary><b>Synchronous</b></summary>

```python
from pytonapi import AsyncTonapi
from pytonapi import Tonapi


# Declare an asynchronous function for using await
async def main():
def main():
# Create a new Tonapi object with the provided API key
tonapi = AsyncTonapi(api_key="Your API key")
tonapi = Tonapi(api_key="Your API key")

# Specify the account ID
account_id = "EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess" # noqa

# Retrieve account information asynchronously
account = await tonapi.accounts.get_info(account_id=account_id)
# Retrieve account information
account = tonapi.accounts.get_info(account_id=account_id)

# Print account details
print(f"Account Address (raw): {account.address.to_raw()}")
Expand All @@ -94,18 +108,34 @@ async def main():


if __name__ == '__main__':
import asyncio

# Run the asynchronous function
asyncio.run(main())
main()

```

**More Examples:**\
Additional examples can be found in the [examples](examples) folder.
</details>


<details>
<summary><b>More</b></summary>

* Additional examples can be found [examples](https://github.com/tonkeeper/pytonapi/tree/main/examples) folder.

</details>

## Contribution

We welcome your contributions! If you have ideas for improvement or have identified a bug, please create an issue or
submit a pull request.

## Donations

**TON** - `EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess`

**USDT** (TRC-20) - `TJjADKFT2i7jqNJAxkgeRm5o9uarcoLUeR`

## License

## Donations:
This repository is distributed under the [MIT License](https://github.com/tonkeeper/pytonapi/blob/main/LICENSE). Feel
free to use, modify, and distribute the code in accordance
with the terms of the license.

<a href="https://app.tonkeeper.com/transfer/EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess"><img src="https://telegra.ph//file/8e0ac22311be3fa6f772c.png" width="55"/></a>
<a href="https://tonhub.com/transfer/EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess"><img src="https://telegra.ph//file/7fa75a1b454a00816d83b.png" width="55"/></a>\
```EQC-3ilVr-W0Uc3pLrGJElwSaFxvhXXfkiQA3EwdVBHNNess```

0 comments on commit 25827f7

Please sign in to comment.