# API

The xSwap API provides developers with access to crucial functionalities within the xSwap platform, facilitating seamless integration with external applications and services.

## API Endpoints

### Swap Operations

**1. Get Swap Route**

```
GET /swap/route
```

Calculates the optimal route for swapping tokens.Query Parameters:

* token0 (Address): Address of the initial token
* token1 (Address): Address of the target token
* amount\_in (Integer): Amount of input token (must be > 0)

Responses:

* 200: Successfully returns route information

```json
{
    "path": ["token0_address", "intermediate_token", "token1_address"],    
    "amount_out": "estimated_output_amount"  
}
```

* 404: Path not found

**2. Get Swap Execution Info**

```
GET /swap/info
```

Retrieves detailed swap execution information including estimated outputs.Query Parameters:

* token0 (Address): First token address
* token1 (Address): Second token address
* amount\_in (Integer): Input amount (must be > 0)
* to (Address): Recipient address
* slippage (Float, optional): Slippage percentage (0-1, default: 0.05)
* deadline (Integer, optional): Transaction deadline

Responces:

* **data:** Swap execution calldata as a string.
* **transferAddress:** Target address for token transfer.
* **transferValue:** Value of the transfer.
* **approvalAddress:** Address for approval if needed.
* **estimateTransferSeconds:** Estimated time for completion in seconds.
* **estimateAmount:** Expected amount from the swap.
* **hopsCount:** Number of intermediary hops in the swap.
* **fee:** Detailed information on fees.

***

### Overview Operations

**3. Get Liquidity Pairs**

```
GET /overview/pairs
```

Retrieves all token pairs with optional filtering.Query Parameters:

* filter\_by\_token (Array, optional): Filter by token address or symbol
* filter\_by\_pair (Array, optional): Filter by pair address
* blacklist (Boolean, optional): Include blacklisted pairs (default: false)

**4. Get Available Tokens**

```
GET /overview/tokens
```

Retrieves all available tokens.Query Parameters:

* filter\_by\_token (Array, optional): Filter by token address
* blacklist (Boolean, optional): Include blacklisted tokens (default: false)

**5. Get Token Price**

```
GET /overview/token/price
```

Get the USD price of a token.Query Parameters:

* address (Address): Token address

***

<br>


---

# 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://docs.xswap.ms/developers/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.
