# Client API

### General information

TraderEvolution provides a comprehensive REST API and a robust WebSocket API intended for real-time data streaming. So, all market and user data are available instantly, with continuous live updates.

The APIs are open and fully integrated, offering developers access to build a front-end application that connects to TraderEvolution's back end.

The API provides a request-response model. Using a browser, an external app can request info (list of orders and positions, balance info, etc.) from the TraderEvolution server. The periodicity of sending requests is defined in the `/config` endpoint.

Communication between the front-end and TraderEvolution Server is organized via a dedicated server which includes several components, see diagram.&#x20;

<figure><img src="/files/uhLEHcJGaZ4o17KLghWJ" alt=""><figcaption><p>Communication diagram</p></figcaption></figure>

The following components are included in the Client API cluster:

* The role of the *Converter Server* is to convert REST API and Websocket requests for trading and accounting into TE proprietary protocol (next - PFIX) and vice versa.&#x20;
* The *Quote node* is used for quotes/bars streaming in Websocket.
* *Balancer* - manages connection balancing, thereby ensuring optimal loads on the server.&#x20;

Each trader establishes an individual trade connection. All connections can be monitored in TraderEvolution Backoffice system.

For market data connections, the client API cluster establishes an information link with the TraderEvolution Server using a technical user account. All connected users receive market data through this single established connection, which optimizes the architecture by minimizing the number of subscriptions to the same instrument. Thus, the guide below is based on the individual connection concept.

{% hint style="success" %}
You can try the Swagger for this API at <https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#>
{% endhint %}

All API calls are grouped into sections corresponding to system entities, you can find them structured as a tree in the left part of the page. Each section contains a set of endpoints for interacting with a particular object. It is supplied with a brief manual to facilitate understanding and help manage the API. You can find examples of API requests and responses in the documentation.

### Getting started

STEP 1. To build integration, the Client API must be deployed and configured. TE team will assist at this stage.

STEP 2. Registration of the client app with TraderEvolution. *Client ID* and *Client Secret* will be issued by TraderEvolution while the Client API cluster deploying. They will be required during the Authentication process. There is also an opportunity to brand your login page using a unique Logo and background color, but the data required for this must be provided in advance.

STEP 3. Implement TraderEvolution REST API.

### Error Codes and Messages

`200 OK` this return code is used for successful requests.

`201 Created` return code is used for the successful creation of a new entity (e.g. placing an order).

`204 No content` return code is used when there is no content (e.g. entity is deleted).

`401 Unauthorized` return code is used when the user is *unauthorized*.

`403 Forbidden`return code is used when this *action is not allowed* for the user.&#x20;

`404 Not found` return code is used when the requested entity is *not available*.

### Response columns

A separate method <mark style="color:blue;">`GET`</mark> `/traderevolution/v1/config` should be used in order to understand the data structure that will be returned in AccountStateResponse, ExecutionsResponse, OrdersResponse, OrdersHistory model, and PositionsResponse. It is important because specified response models don't contain parameters' names, but simply an array of values. The names of returned values and their sequence are defined in config objects: accountDetailsConfig, filledOrdersConfig, ordersConfig, ordersHistoryConfig, positionsConfig.

You can use the following CURL:

{% code overflow="wrap" %}

```json
curl -X GET "https://sandbox-api.traderevolution.com/traderevolution/v1/config" -H "accept: application/json" -H "Authorization: Bearer eyJraWQiOiI3NDhlZjYwZS1mYTNlLTRmYjAtOWQyYy1kYzBhNGE3ZjZjZmEiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJpcnluYW0iLCJhdW...Ah7EGY9zayrCR7g"
```

{% endcode %}


---

# 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://guide.traderevolution.com/traderevolution-api/traderevolution-apis/client-api.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.
