> For the complete documentation index, see [llms.txt](https://apidocs-ga092.stockhero.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs-ga092.stockhero.ai/bot-execution/template-list.md).

# Template List

This endpoint allows you to retrieve a list of rental bot templates that are available to users in the Bots Marketplace.

**Get List of Bots**

<mark style="color:green;">**`GET`**</mark> **`https://api.aitrade.com/api/templates`**

#### Query Params

<table><thead><tr><th>Name</th><th>Type</th><th width="108" data-type="checkbox">Required</th><th>Description</th></tr></thead><tbody><tr><td>page_size</td><td>integer</td><td>false</td><td>maximum number of items returned per request</td></tr><tr><td>page</td><td>integer</td><td>false</td><td>Current page number for pagination</td></tr><tr><td>sort</td><td>string</td><td>false</td><td>Sort the list by <code>apy</code> or <code>wl_ratio</code>.</td></tr><tr><td>order</td><td>string</td><td>false</td><td>Order of sorting, either <code>desc</code> for descending or <code>asc</code> for ascending</td></tr><tr><td>strategy</td><td>string</td><td>false</td><td>Filter the list by strategy, options are <code>Long</code> or <code>Short</code></td></tr></tbody></table>

**Response**

This endpoint supports pagination and allows filtering and sorting to help integrate and display bots data efficiently in your applications.

The response includes status code indicating the outcome. A successful request (`code: 200`) returns bot templates' details including the id, status, title, description, performance metrics, and more. An unsuccessful attempt due to authentication issues returns `code: 401` with a message indicating the user is unauthenticated.

{% tabs %}
{% tab title="Sample Request" %}

```javascript
//sample javascript code
const axios = require('axios');

const fetchBotTemplates = async () => {
  try {
    const response = await axios.get('https://api.stockhero.ai/api/templates', {
      params: {
        page: 1, // Specify the page number
        per_page: 8, // Specify number of items per page
        sort: 'apy', // Field to sort by
        direction: 'desc' // Sorting direction: asc or desc
      },
      headers: {
        'Authorization': 'Bearer YOUR_ACCESS_TOKEN' // Replace YOUR_ACCESS_TOKEN with your actual token
      }
    });
    console.log(response.data);
  } catch (error) {
    console.error(error.response.data);
  }
};

fetchBotTemplates();
```

{% endtab %}

{% tab title="200  successfully returned" %}

```javascript
{
    "code": 200,
    "message": "Success",
    "templates": {
        "current_page": 1,
        "data": [
            {
                "id": 3,
                "owner_id": 19,
                "bot_id": 18,
                "status": "approved",
                "title": "Market Neutral, BEST BOT AWARD",
                "description": "This bot trades in up, down and range bound market to deliver consistent returns. Please ensure that you have at least 7x the price of the stock that you want to trade,  allocated for this bot. For e.g., if a stock price is $1, you need $7 for fund.",
                "apy": 22.62,
                "performance": 85.81,
                "wl_ratio": 100,
                "total_deal": 17,
                "avg_monthly_deal": 3.29,
                "total_profit": 0,
                "total_sub": 413,
                "current_renter": 270,
                "created_at": "2022-10-01 06:11:44",
                "updated_at": "2024-03-26 14:49:09",
                "image": "https://yourdomain/path_to_image_file.jpg",
                "view_count": 8518,
                "strategy": "Long",
                "total_thumbs_up": 67,
                "real_performances": {
                    "id": 31283,
                    "template_id": 3,
                    "total_deal": 871,
                    "avg_wl": 88.05,
                    "total_deal_3_months": 455,
                    "avg_wl_3_months": 85.49,
                    "win_rate": 92,
                    "track_record": 90,
                    "bot_activity": 50,
                    "created_at": "2023-04-18 08:29:49",
                    "updated_at": "2024-03-24 00:01:15"
                }
            }
        ],
        "first_page_url": "https://api.stockhero.ai/api/templates?page=1",
        "from": 1,
        "last_page": 2,
        "last_page_url": "https://api.stockhero.ai/api/templates?page=2",
        "next_page_url": "https://api.stockhero.ai/api/templates?page=2",
        "path": "https://api.stockhero.ai/api/templates",
        "per_page": 8,
        "prev_page_url": null,
        "to": 8,
        "total": 11
    }
}
```

{% endtab %}

{% tab title="401 Unauthenticated" %}

```
{
  "code": 401,
  "success": false,
  "message": "Unauthenticated."
}
```

{% endtab %}
{% endtabs %}
