# Quote

## Request trade quote

<mark style="color:green;">`POST`</mark> `/quote`

Retrieve trade cost, liquidation price and current price

**Headers**

| Name         | Value                                  | Description                                                                          |
| ------------ | -------------------------------------- | ------------------------------------------------------------------------------------ |
| Content-Type | `application/json`                     | Set to `application/json` to define the payload format.                              |
| `cert`       | **Python (requests):** tuple           | Path to the certificate and key file as a tuple (e.g., `(cert_path, key_path)`).     |
|              | **cURL:** `--cert` and `--key`         | Separate paths to the certificate and key (e.g., `--cert cert_path --key key_path`). |
|              | **Java (Apache HttpClient)**: KeyStore | Certificate and key loaded into `SSLContext` or `KeyStore`.                          |

**Body**

<table><thead><tr><th>Name</th><th width="220">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>apikey</code></td><td>string</td><td>Name of the user</td></tr><tr><td>network_choice</td><td>string</td><td>SOL / ETH / BASE / ARB / BSC</td></tr><tr><td>contract_address</td><td>string</td><td>Token Address</td></tr><tr><td>leverage</td><td>float </td><td>e.g. 5.0. / 5.5 / </td></tr><tr><td>initial_amount</td><td>float </td><td>In Native e.g. 0.1 / 10.0 / 100</td></tr></tbody></table>

**Response**

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

```json

{
    "current_price": "0.00000006048819407141113196658559246834951927951352",
    "liquidation_price": "0.00000004637428212141520426252324109037128430088615",
    "message": "Quote executed successfully",
    "status": "success",
    "timestamp": "2025-01-21 15:59:48",
    "trade_cost": "0.0011"
}

```

{% endtab %}

{% tab title="400" %}
{% code title="" %}

```json
    
{
    "status": "Failed",
    "message": "Missing required fields",
    "timestamp": "2025-01-21 16:00:00"
},

{
    "status": "Failed",
    "message": "No pair found for: contract_address_here",
    "timestamp": "2025-01-21 16:00:00"
},

{
    "status": "Failed",
    "message": "Error fetching token price: Details here"
    "timestamp": "2025-01-21 16:00:00"
},

{
    "status": "Failed",
    "message": "Trade cost error: Details here",
    "timestamp": "2025-01-21 16:00:00"
}

```

{% endcode %}
{% endtab %}

{% tab title="401" %}

```json
{
    "status": "Failed",
    "message": "Invalid API key",
    "timestamp": "2025-01-21 16:00:00"
}
```

{% endtab %}
{% endtabs %}

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

```javascript
const axios = require("axios");
const fs = require("fs");
const https = require("https");

const httpsAgent = new https.Agent({
  cert: fs.readFileSync("path/to/certificate.crt"),
  key: fs.readFileSync("path/to/private.key"),
});

axios.post("https://your-api-url.com/quote", {
  apikey: "your_api_key",
  network_choice: "ETH",
  contract_address: "0x03EE5026c07d85ff8ae791370DD0F4C1aE6C97fc",
  leverage: 5.0,
  initial_amount: 10.0,
}, { httpsAgent })
  .then(({ status, data }) => console.log(`${status}`, data))
  .catch(({ response, message }) => console.error(response?.data || message));


```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://your-api-url.com/quote"
headers = {"Content-Type": "application/json"}
payload = {
    "apikey": "your_api_key",
    "network_choice": "ETH",
    "contract_address": "0x03EE5026c07d85ff8ae791370DD0F4C1aE6C97fc",
    "leverage": 5.0,
    "initial_amount": 10.0
}

CERT_PATH = "path/to/certificate.crt"
KEY_PATH = "path/to/private.key"

response = requests.post(url, headers=headers, json=payload, cert=(CERT_PATH, KEY_PATH))

print(response.status_code, response.json())

```

{% endtab %}

{% tab title="Typescript" %}

```typescript
import fetch from "node-fetch";
import fs from "fs";
import https from "https";

const httpsAgent = new https.Agent({
  cert: fs.readFileSync("path/to/certificate.crt"),
  key: fs.readFileSync("path/to/private.key"),
});

fetch("https://your-api-url.com/quote", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    apikey: "your_api_key",
    network_choice: "ETH",
    contract_address: "0x03EE5026c07d85ff8ae791370DD0F4C1aE6C97fc",
    leverage: 5.0,
    initial_amount: 10.0,
  }),
  agent: httpsAgent,
})
  .then((res) => res.json())
  .then(console.log)
  .catch(console.error);

```

{% endtab %}

{% tab title="Rust" %}

```rust
use reqwest::{Client, Certificate, Identity};
use serde_json::json;
use tokio;

#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
    let client = Client::builder()
        .identity(Identity::from_pem(include_bytes!("path/to/identity.pem"))?)
        .add_root_certificate(Certificate::from_pem(include_bytes!("path/to/certificate.pem"))?)
        .build()?;

    let response = client
        .post("https://your-api-url.com/quote")
        .json(&json!({
            "apikey": "your_api_key",
            "network_choice": "ETH",
            "contract_address": "0x03EE5026c07d85ff8ae791370DD0F4C1aE6C97fc",
            "leverage": 5.0,
            "initial_amount": 10.0
        }))
        .send()
        .await?
        .text()
        .await?;

    println!("{}", response);
    Ok(())
}


```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
	"bytes"
	"crypto/tls"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
)

func main() {
	url := "https://your-api-url.com/quote"

	payload, _ := json.Marshal(map[string]interface{}{
		"apikey":          "your_api_key",
		"network_choice":  "ETH",
		"contract_address": "0x03EE5026c07d85ff8ae791370DD0F4C1aE6C97fc",
		"leverage":        5.0,
		"initial_amount":  10.0,
	})

	cert, err := tls.LoadX509KeyPair("path/to/certificate.crt", "path/to/private.key")
	if err != nil {
		fmt.Println("❌ TLS Error:", err)
		return
	}

	client := &http.Client{
		Transport: &http.Transport{
			TLSClientConfig: &tls.Config{Certificates: []tls.Certificate{cert}},
		},
	}

	resp, err := client.Post(url, "application/json", bytes.NewBuffer(payload))
	if err != nil {
		fmt.Println("❌ Request Error:", err)
		return
	}
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}

```

}
{% 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://docs.0xleverage.io/overview/leverage-api/quote.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.
