# What is Crypticorn?

Crypticorn is at the forefront of cutting-edge artificial intelligence cryptocurrency trading.
Crypticorn offers AI-based solutions for both active and passive investors, including:
 - Prediction Dashboard with trading terminal,
 - AI Agents with different strategies,
 - DEX AI Signals for newly launched tokens,
 - DEX AI Bots

Use this API Client to contribute to the so-called Hive AI, a community driven AI Meta Model for predicting the
cryptocurrency market.

## Installation

>Python 3.10+ required

You can install the latest stable version from PyPi:
```bash
pip install crypticorn
```

If you want the latest version, which could be a pre release, run:
```bash
pip install --pre crypticorn
```

## Structure

Our API is available as an asynchronous Python SDK. The main entry point you need is the `ApiClient` class, which you would import like this:
```python
from crypticorn import ApiClient
```
The ApiClient serves as the central interface for API operations. It instantiates multiple API wrappers corresponding to our microservices.

Specific imports, such as request models, should be accessed through the appropriate submodules.

Note: All symbols are re-exported at the first submodule layer for convenience.

```python
from crypticorn.trade import BotStatus
```

The `common` submodule contains shared classes not bound to a specific API.
```python
from crypticorn.common import Scope, Exchange
```

## Basic Usage

### With Async Context Protocol
```python
async with ApiClient(base_url=BaseUrl.Prod, api_key="your-api-key") as client:
        await client.pay.products.get_products()
```

### Without Async Context Protocol
Without the context you need to close the session manually.
```python
client = ApiClient(base_url=BaseUrl.Prod, api_key="your-api-key")
asyncio.run(client.pay.models.get_products())
asyncio.run(client.close())
```
...or wrapped in a function
async def main():
    await client.pay.products.get_products()

asyncio.run(main())
asyncio.run(client.close())

## Response Types

There are three different available output formats you can choose from:

### Serialized Response
You can get fully serialized responses as pydantic models. Using this, you get the full benefits of pydantic's type checking.
```python
response = await client.pay.products.get_products()
print(response)
```
The output would look like this:
```python
[ProductModel(id='67e8146e7bae32f3838fe36a', name='Awesome Product', price=5.0, scopes=None, duration=30, description='You need to buy this', is_active=True)]
```

### Serialized Response with HTTP Info
```python
await client.pay.products.get_products_with_http_info()
print(res)
```
The output would look like this:
```python
status_code=200 headers={'Date': 'Wed, 09 Apr 2025 19:15:19 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Alt-Svc': 'h3=":443"; ma=86400', 'Server': 'cloudflare', 'Cf-Cache-Status': 'DYNAMIC', 'Content-Encoding': 'gzip', 'CF-RAY': '92dc551a687bbe5e-ZRH'} data=[ProductModel(id='67e8146e7bae32f3838fe36a', name='Awesome Product', price=5.0, scopes=None, duration=30, description='You need to buy this', is_active=True)] raw_data=b'[{"id":"67e8146e7bae32f3838fe36a","name":"Awesome Product","price":5.0,"duration":30,"description":"You need to buy this","is_active":true}]'
```
You can then access the data of the response (as serialized output) with:
```python
print(res.data)
```
On top of that you get some information about the request:
```python
print(res.status_code)
print(res.raw_data)
print(res.headers)
```

### JSON Response
You can receive a classical JSON response by suffixing the function name with `_without_preload_content`
```python
response = await client.pay.products.get_products_without_preload_content()
print(await response.json())
```
The output would look like this:
```python
[{'id': '67e8146e7bae32f3838fe36a', 'name': 'Awesome Product', 'price': 5.0, 'duration': 30, 'description': 'You need to buy this', 'is_active': True}]
```

## Advanced Usage

You can override some configuration for specific services. If you just want to use the API as is, you don't need to configure anything.
This might be of use if you are testing a specific API locally.

To override e.g. the host for the Hive client to connect to http://localhost:8000 instead of the default proxy, you would do:
```python
from crypticorn.hive import Configuration as Hiveconfig
async with ApiClient(base_url=BaseUrl.DEV) as client:
        client.configure(config=HiveConfig(host="http://localhost:8000"), client=client.hive)
```