Ooga-Booga-Python


NameOoga-Booga-Python JSON
Version 0.0.3 PyPI version JSON
download
home_pagehttps://github.com/1220moritz/Ooga_Booga_Python
SummaryA Python wrapper for the Ooga Booga API, providing seamless integration with Berachain liquidity for DApps and protocols.
upload_time2024-12-03 01:19:45
maintainerNone
docs_urlNone
author1220.moritz
requires_python>=3.9
licenseNone
keywords berachain dex api-wrapper blockchain ooga-booga
VCS
bugtrack_url
requirements setuptools aiohttp asyncio pydantic pytest pytest-asyncio python-dotenv web3 eth-typing colorama
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Ooga Booga Python Client

[![PyPI](https://img.shields.io/pypi/v/Ooga-Booga-Python)](https://pypi.org/project/Ooga-Booga-Python/) 
[![Downloads](https://static.pepy.tech/badge/Ooga-Booga-Python)](https://pepy.tech/project/Ooga-Booga-Python) 
[![Tests](https://github.com/1220moritz/Ooga_Booga_Python/actions/workflows/tests.yml/badge.svg)](https://github.com/1220moritz/Ooga_Booga_Python/actions/workflows/tests.yml)  

[GitHub Repository](https://github.com/1220moritz/Ooga_Booga_Python)  
[PyPI Package](https://pypi.org/project/Ooga-Booga-Python/)

The **Ooga Booga Python Client** is a wrapper for the [Ooga Booga API V1](https://docs.oogabooga.io/api/), a powerful DEX aggregation and smart order routing REST API built to integrate Berachain's liquidity into your DApp or protocol. This client allows you to interact with Berachain's liquidity sources, including AMMs, bonding curves, and order books, to execute the best trades with minimal price impact.

For more details on the API and its capabilities, refer to the official [Ooga Booga API Documentation](https://docs.oogabooga.io/api/).

## Features

- 💸 **Find the Best Rates**: Get optimal real-time prices for your trades by leveraging Ooga Booga's liquidity aggregation.
- 🚀 **Simplified Integration**: A single API integration grants access to all liquidity sources on Berachain, saving you development time.
- 📈 **Optimal Trade Execution**: Perform efficient trades with minimized price impact and maximum returns for your users.
- 🦺 **Enhanced Security**: Execute trades securely via Ooga Booga’s smart contract, which wraps each transaction.
- Asynchronous API calls using `aiohttp` for smooth, non-blocking operations.

## Features

- Fetch token lists and prices
- Approve token allowances
- Query token allowances
- Perform token swaps
- Retrieve liquidity sources
- Comprehensive error handling
- Asynchronous API calls using `aiohttp`

## Table of Contents

- [Installation](#installation)
- [Setup](#setup)
- [Usage](#usage)
- [API Reference](#api-reference)
- [Contributing](#contributing)
- [License](#license)

---

## Installation

To install the Ooga-Booga-Python package, use pip. Run the following command in your terminal:

```bash
pip install Ooga-Booga-Python
```

To upgrade the package to the latest version, run:

```bash
pip install --upgrade Ooga-Booga-Python
```

If you prefer installing directly from the GitHub repository, use:

```bash
pip install git+https://github.com/1220moritz/Ooga_Booga_Python.git
```

---


## Setup

1. Copy the `example_env.env` file to `.env`:

```bash
cp tests/example_env.env .env
```

2. Add your API key and private key:

```plaintext
OOGA_BOOGA_API_KEY="your-api-key"
PRIVATE_KEY="your-private-key"
```

3. Install dependencies:

```bash
pip install -r requirements.txt
```

---

## Usage

Here’s how to use the **Ooga Booga Python Client** in your project:

### Initialize the Client

```python
from ooga_booga_python.client import OogaBoogaClient
import asyncio
from dotenv import load_dotenv
import os

# Load environment variables from the .env file
load_dotenv()

async def main():
    client = OogaBoogaClient(
        api_key=os.getenv("OOGA_BOOGA_API_KEY"),
        private_key=os.getenv("PRIVATE_KEY")
    )
    # Example: Fetch token list
    tokens = await client.get_token_list()
    for token in tokens:
        print(f"Name: {token.name}, Symbol: {token.symbol}")

asyncio.run(main())

```

### Perform a Token Swap

```python
from ooga_booga_python.models import SwapParams

async def perform_swap(client):
    swap_params = SwapParams(
        tokenIn="0xTokenInAddress",
        amount=1000000000000000000,  # 1 token in wei
        tokenOut="0xTokenOutAddress",
        to="0xYourWalletAddress",
        slippage=0.02,
    )
    await client.swap(swap_params)

asyncio.run(perform_swap(client))
```

### Get Token Prices

```python
async def fetch_prices(client):
    prices = await client.get_token_prices()
    for price in prices:
        print(f"Token: {price.address}, Price: {price.price}")

asyncio.run(fetch_prices(client))
```

---

## API Reference

### `OogaBoogaClient`

#### Initialization

```python
client = OogaBoogaClient(api_key: str, private_key: str, rpc_url: str = "https://bartio.rpc.berachain.com/")
```

- **`api_key`**: Your API key for authentication.
- **`private_key`**: Your private key for signing transactions.
- **`rpc_url`**: (Optional) RPC URL for blockchain interaction.

#### Methods

1. **`get_token_list()`**  
   Fetches the list of available tokens.

2. **`get_token_prices()`**  
   Fetches the current prices of tokens.

3. **`get_liquidity_sources()`**  
   Fetches all available liquidity sources.

4. **`swap(swap_params: SwapParams)`**  
   Performs a token swap using the provided parameters.

5. **`approve_allowance(token: str, amount: str = MAX_INT)`**  
   Approves a token allowance for the router.

6. **`get_token_allowance(from_address: str, token: str)`**  
   Fetches the allowance of a token for a specific address.

---

## Testing

The package uses `pytest` for testing. To run the tests:

1. Install test dependencies:

```bash
pip install -r requirements.txt
```

2. Run the tests:

```bash
pytest tests/
```

---

## Contributing

Contributions are welcome! Please fork the repository and submit a pull request.

1. Fork the repository
2. Create a feature branch
3. Commit your changes
4. Push to your fork
5. Open a pull request

---

## License

This project is licensed under the [MIT License](LICENSE).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/1220moritz/Ooga_Booga_Python",
    "name": "Ooga-Booga-Python",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "berachain, dex, api-wrapper, blockchain, ooga-booga",
    "author": "1220.moritz",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/97/96/0de01cde99c988b99ee01833919c21feabab2fa62b19a56dcbdeefe6a084/ooga_booga_python-0.0.3.tar.gz",
    "platform": null,
    "description": "# Ooga Booga Python Client\r\n\r\n[![PyPI](https://img.shields.io/pypi/v/Ooga-Booga-Python)](https://pypi.org/project/Ooga-Booga-Python/) \r\n[![Downloads](https://static.pepy.tech/badge/Ooga-Booga-Python)](https://pepy.tech/project/Ooga-Booga-Python) \r\n[![Tests](https://github.com/1220moritz/Ooga_Booga_Python/actions/workflows/tests.yml/badge.svg)](https://github.com/1220moritz/Ooga_Booga_Python/actions/workflows/tests.yml)  \r\n\r\n[GitHub Repository](https://github.com/1220moritz/Ooga_Booga_Python)  \r\n[PyPI Package](https://pypi.org/project/Ooga-Booga-Python/)\r\n\r\nThe **Ooga Booga Python Client** is a wrapper for the [Ooga Booga API V1](https://docs.oogabooga.io/api/), a powerful DEX aggregation and smart order routing REST API built to integrate Berachain's liquidity into your DApp or protocol. This client allows you to interact with Berachain's liquidity sources, including AMMs, bonding curves, and order books, to execute the best trades with minimal price impact.\r\n\r\nFor more details on the API and its capabilities, refer to the official [Ooga Booga API Documentation](https://docs.oogabooga.io/api/).\r\n\r\n## Features\r\n\r\n- \u00f0\u0178\u2019\u00b8 **Find the Best Rates**: Get optimal real-time prices for your trades by leveraging Ooga Booga's liquidity aggregation.\r\n- \u00f0\u0178\u0161\u20ac **Simplified Integration**: A single API integration grants access to all liquidity sources on Berachain, saving you development time.\r\n- \u00f0\u0178\u201c\u02c6 **Optimal Trade Execution**: Perform efficient trades with minimized price impact and maximum returns for your users.\r\n- \u00f0\u0178\u00a6\u00ba **Enhanced Security**: Execute trades securely via Ooga Booga\u00e2\u20ac\u2122s smart contract, which wraps each transaction.\r\n- Asynchronous API calls using `aiohttp` for smooth, non-blocking operations.\r\n\r\n## Features\r\n\r\n- Fetch token lists and prices\r\n- Approve token allowances\r\n- Query token allowances\r\n- Perform token swaps\r\n- Retrieve liquidity sources\r\n- Comprehensive error handling\r\n- Asynchronous API calls using `aiohttp`\r\n\r\n## Table of Contents\r\n\r\n- [Installation](#installation)\r\n- [Setup](#setup)\r\n- [Usage](#usage)\r\n- [API Reference](#api-reference)\r\n- [Contributing](#contributing)\r\n- [License](#license)\r\n\r\n---\r\n\r\n## Installation\r\n\r\nTo install the Ooga-Booga-Python package, use pip. Run the following command in your terminal:\r\n\r\n```bash\r\npip install Ooga-Booga-Python\r\n```\r\n\r\nTo upgrade the package to the latest version, run:\r\n\r\n```bash\r\npip install --upgrade Ooga-Booga-Python\r\n```\r\n\r\nIf you prefer installing directly from the GitHub repository, use:\r\n\r\n```bash\r\npip install git+https://github.com/1220moritz/Ooga_Booga_Python.git\r\n```\r\n\r\n---\r\n\r\n\r\n## Setup\r\n\r\n1. Copy the `example_env.env` file to `.env`:\r\n\r\n```bash\r\ncp tests/example_env.env .env\r\n```\r\n\r\n2. Add your API key and private key:\r\n\r\n```plaintext\r\nOOGA_BOOGA_API_KEY=\"your-api-key\"\r\nPRIVATE_KEY=\"your-private-key\"\r\n```\r\n\r\n3. Install dependencies:\r\n\r\n```bash\r\npip install -r requirements.txt\r\n```\r\n\r\n---\r\n\r\n## Usage\r\n\r\nHere\u00e2\u20ac\u2122s how to use the **Ooga Booga Python Client** in your project:\r\n\r\n### Initialize the Client\r\n\r\n```python\r\nfrom ooga_booga_python.client import OogaBoogaClient\r\nimport asyncio\r\nfrom dotenv import load_dotenv\r\nimport os\r\n\r\n# Load environment variables from the .env file\r\nload_dotenv()\r\n\r\nasync def main():\r\n    client = OogaBoogaClient(\r\n        api_key=os.getenv(\"OOGA_BOOGA_API_KEY\"),\r\n        private_key=os.getenv(\"PRIVATE_KEY\")\r\n    )\r\n    # Example: Fetch token list\r\n    tokens = await client.get_token_list()\r\n    for token in tokens:\r\n        print(f\"Name: {token.name}, Symbol: {token.symbol}\")\r\n\r\nasyncio.run(main())\r\n\r\n```\r\n\r\n### Perform a Token Swap\r\n\r\n```python\r\nfrom ooga_booga_python.models import SwapParams\r\n\r\nasync def perform_swap(client):\r\n    swap_params = SwapParams(\r\n        tokenIn=\"0xTokenInAddress\",\r\n        amount=1000000000000000000,  # 1 token in wei\r\n        tokenOut=\"0xTokenOutAddress\",\r\n        to=\"0xYourWalletAddress\",\r\n        slippage=0.02,\r\n    )\r\n    await client.swap(swap_params)\r\n\r\nasyncio.run(perform_swap(client))\r\n```\r\n\r\n### Get Token Prices\r\n\r\n```python\r\nasync def fetch_prices(client):\r\n    prices = await client.get_token_prices()\r\n    for price in prices:\r\n        print(f\"Token: {price.address}, Price: {price.price}\")\r\n\r\nasyncio.run(fetch_prices(client))\r\n```\r\n\r\n---\r\n\r\n## API Reference\r\n\r\n### `OogaBoogaClient`\r\n\r\n#### Initialization\r\n\r\n```python\r\nclient = OogaBoogaClient(api_key: str, private_key: str, rpc_url: str = \"https://bartio.rpc.berachain.com/\")\r\n```\r\n\r\n- **`api_key`**: Your API key for authentication.\r\n- **`private_key`**: Your private key for signing transactions.\r\n- **`rpc_url`**: (Optional) RPC URL for blockchain interaction.\r\n\r\n#### Methods\r\n\r\n1. **`get_token_list()`**  \r\n   Fetches the list of available tokens.\r\n\r\n2. **`get_token_prices()`**  \r\n   Fetches the current prices of tokens.\r\n\r\n3. **`get_liquidity_sources()`**  \r\n   Fetches all available liquidity sources.\r\n\r\n4. **`swap(swap_params: SwapParams)`**  \r\n   Performs a token swap using the provided parameters.\r\n\r\n5. **`approve_allowance(token: str, amount: str = MAX_INT)`**  \r\n   Approves a token allowance for the router.\r\n\r\n6. **`get_token_allowance(from_address: str, token: str)`**  \r\n   Fetches the allowance of a token for a specific address.\r\n\r\n---\r\n\r\n## Testing\r\n\r\nThe package uses `pytest` for testing. To run the tests:\r\n\r\n1. Install test dependencies:\r\n\r\n```bash\r\npip install -r requirements.txt\r\n```\r\n\r\n2. Run the tests:\r\n\r\n```bash\r\npytest tests/\r\n```\r\n\r\n---\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please fork the repository and submit a pull request.\r\n\r\n1. Fork the repository\r\n2. Create a feature branch\r\n3. Commit your changes\r\n4. Push to your fork\r\n5. Open a pull request\r\n\r\n---\r\n\r\n## License\r\n\r\nThis project is licensed under the [MIT License](LICENSE).\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A Python wrapper for the Ooga Booga API, providing seamless integration with Berachain liquidity for DApps and protocols.",
    "version": "0.0.3",
    "project_urls": {
        "Homepage": "https://github.com/1220moritz/Ooga_Booga_Python"
    },
    "split_keywords": [
        "berachain",
        " dex",
        " api-wrapper",
        " blockchain",
        " ooga-booga"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c70ca610a4a98497c40aef1e5b5fdb4e11ef553378b3ab8f1d83827d9dd78832",
                "md5": "aec7506ad54d888e852038468f44e551",
                "sha256": "fbba616f1d1263568118fd3fa8af6396d394560c53df9d619f34d6a007416e56"
            },
            "downloads": -1,
            "filename": "Ooga_Booga_Python-0.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "aec7506ad54d888e852038468f44e551",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 11664,
            "upload_time": "2024-12-03T01:19:43",
            "upload_time_iso_8601": "2024-12-03T01:19:43.954352Z",
            "url": "https://files.pythonhosted.org/packages/c7/0c/a610a4a98497c40aef1e5b5fdb4e11ef553378b3ab8f1d83827d9dd78832/Ooga_Booga_Python-0.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "97960de01cde99c988b99ee01833919c21feabab2fa62b19a56dcbdeefe6a084",
                "md5": "b9624043c59c7e6dde8e26c42a4d88a5",
                "sha256": "a1e83e71bf205b86c057319831bc6504e10336de6ba3af89970b8f98f41658cc"
            },
            "downloads": -1,
            "filename": "ooga_booga_python-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "b9624043c59c7e6dde8e26c42a4d88a5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 11116,
            "upload_time": "2024-12-03T01:19:45",
            "upload_time_iso_8601": "2024-12-03T01:19:45.556965Z",
            "url": "https://files.pythonhosted.org/packages/97/96/0de01cde99c988b99ee01833919c21feabab2fa62b19a56dcbdeefe6a084/ooga_booga_python-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-03 01:19:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "1220moritz",
    "github_project": "Ooga_Booga_Python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "setuptools",
            "specs": [
                [
                    "~=",
                    "75.6.0"
                ]
            ]
        },
        {
            "name": "aiohttp",
            "specs": [
                [
                    "~=",
                    "3.11.9"
                ]
            ]
        },
        {
            "name": "asyncio",
            "specs": [
                [
                    "~=",
                    "3.4.3"
                ]
            ]
        },
        {
            "name": "pydantic",
            "specs": [
                [
                    "~=",
                    "2.10.2"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    "~=",
                    "8.3.4"
                ]
            ]
        },
        {
            "name": "pytest-asyncio",
            "specs": [
                [
                    "~=",
                    "0.24.0"
                ]
            ]
        },
        {
            "name": "python-dotenv",
            "specs": [
                [
                    "~=",
                    "1.0.1"
                ]
            ]
        },
        {
            "name": "web3",
            "specs": [
                [
                    "~=",
                    "7.6.0"
                ]
            ]
        },
        {
            "name": "eth-typing",
            "specs": [
                [
                    "~=",
                    "5.0.1"
                ]
            ]
        },
        {
            "name": "colorama",
            "specs": [
                [
                    "~=",
                    "0.4.6"
                ]
            ]
        }
    ],
    "lcname": "ooga-booga-python"
}
        
Elapsed time: 0.34837s