# Exchange Module

Exchange module handles operations related to exchange data retrieval.

To learn more about how to use the AI Agent SDK to interact with the wallet module, please visit [AI Agent SDK Crypto.com Exchange](/crypto.com-ai-agent-sdk/core-concepts-overview/blockchain-functions/crypto.com-exchange.md).

#### 8.1 Get All Tickers

Retrieves all available tickers from the Crypto.com Exchange (Chain agnostic).

{% tabs %}
{% tab title="Python" %}
Function Name

```python
get_all_tickers
```

{% tabs %}
{% tab title="Query" %}

* Example Code

  ```python
  from crypto_com_developer_platform_client import Exchange

  tickers = Exchange.get_all_tickers()
  print(tickers)
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```python
  A list of all available tickers and their information.
  ```
* Errors

  ```python
  ValueError: If the Exchange class is not initialized with a Client instance.
  ```
* Example Return

  ```python
  {'status': 'Success', 'data': [{'instrumentName': 'example-intrument-name', 'high': example-high, 'low': example-low, 'lastPrice': example-last-price, 'volume': example-volume, 'volumeValue': example-volume-value, 'priceChange': example-price-change, 'bestBid': example-best-bid, 'bestAsk': example-best-ask, 'openInterest': example-open-interest, 'timestamp': example-timestamp}, ...]}
  ```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="TypeScript" %}
Function Name

```typescript
getAllTickers
```

{% tabs %}
{% tab title="Query" %}

* Example Code

  ```typescript
  import { Exchange } from '@crypto.com/developer-platform-client';

  try {
    const tickers = await Exchange.getAllTickers();
    console.log(tickers);
  }
    catch(err) {
    console.log(err);
  }
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```typescript
  {Promise<ApiResponse<TickerResponse>>}: A promise that resolves to all available tickers.
  ```
* Errors

  ```typescript
  {Error}: Throws an error if the request fails.
  ```
* Example Return

  ```typescript
  {
    status: 'Success',
    data: [
      {
        instrumentName: example-name,
        high: example-high,
        low: example-low,
        lastPrice: example-last-price,
        volume: example-volume,
        volumeValue: example-volume-value,
        priceChange: example-price-change,
        bestBid: example-best-bit,
        bestAsk: example-best-ask,
        openInterest: example-open-interest,
        timestamp: example-timestamp
      }
      ...
    ]
  }
  ```

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}

#### 8.2 Get Ticker By Instrument

Retrieves ticker information for a specific trading instrument from the Crypto.com Exchange (Chain agnostic).

{% tabs %}
{% tab title="Python" %}
Function Name

```python
get_ticker_by_instrument
```

{% tabs %}
{% tab title="Query" %}

* Arguments

  ```python
  instrument_name (str): The name of the instrument to get ticker information for.
  ```
* Example Code

  ```python
  from crypto_com_developer_platform_client import Exchange

  ticker = Exchange.get_ticker_by_instrument('example-instrument')
  print(ticker)
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```python
  Ticker information for the specified instrument.
  ```
* Errors

  ```python
  ValueError: If instrument_name is None or empty.
  ```
* Example Return

  ```python
  {'status': 'Success', 'data': {'instrumentName': 'example-intrument-name', 'high': example-high, 'low': example-low, 'lastPrice': example-last-price, 'volume': example-volume, 'volumeValue': example-volume-value, 'priceChange': example-price-change, 'bestBid': example-best-bid, 'bestAsk': example-best-ask, 'openInterest': example-open-interest, 'timestamp': example-timestamp}}
  ```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="TypeScript" %}
Function Name

```typescript
getTickerByInstrument
```

{% tabs %}
{% tab title="Query" %}

* Arguments

  ```typescript
  {string} instrumentName: The name of the trading instrument (e.g., 'BTC_USDT')
  ```
* Example Code

  ```typescript
  import { Exchange } from '@crypto.com/developer-platform-client';

  try {
    const btcTicker = await Exchange.getTickerByInstrument('BTC_USDT');
    console.log(btcTicker);
  }
    catch(err) {
    console.log(err);
  }
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```typescript
  {Promise<ApiResponse<TickerData>>}: A promise that resolves to the ticker information.
  ```
* Errors

  ```typescript
  {Error}: Throws an error if the request fails.
  ```
* Example Return

  ```typescript
  {
    status: 'Success',
    data: {
      instrumentName: example-name,
      high: example-high,
      low: example-low,
      lastPrice: example-last-price,
      volume: example-volume,
      volumeValue: example-volume-value,
      priceChange: example-price-change,
      bestBid: example-best-bid,
      bestAsk: example-best-ask,
      openInterest: example-open-interest,
      timestamp: example-timestamp
    }
  }
  ```

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ai-agent-sdk-docs.crypto.com/crypto.com-developer-platform/on-chain-developer-platform-client-sdk/exchange-module.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
