> For the complete documentation index, see [llms.txt](https://docs.circular.bot/circular-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.circular.bot/circular-docs/api/market-cache/examples.md).

# Examples

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

```javascript
// Define constants
const API_URL = 'https://pro.circular.bot/market/cache';
const API_KEY = 'your-api-key'; // Replace by your API Key

const requestOptions = {
    headers: {
        'Content-Type': 'application/json',
        'x-api-key': API_KEY,
    },
    params: {
        onlyjup: false,
        tokens: [
            "So11111111111111111111111111111111111111112",
            "BbtrrZ2ExfCTzrndFBCx5iNDFXxuVxNMdEZ14BZxpump",
            "6b7NtVRo6jDSUZ75qfhHgpy99XVkSu1kfoTFu2E3pump",
        ].join(',')
    },
};

const getFilteredMarketCache = async () => {
    try {
        const response = await axios.get(API_URL, requestOptions);

        console.log('Market-Cache: ', response?.data);
    } catch (error) {
        console.log('Error: ', error?.response?.data);
    }
};

getFilteredMarketCache();
```

{% endtab %}

{% tab title="Typescript" %}

```typescript
// Define constants
const API_URL: string = 'https://pro.circular.bot/market/cache';
const API_KEY: string = 'your-api-key'; // Replace with your API key

// Define the request options interface
interface RequestOptions {
    headers: {
        'Content-Type': string;
        'x-api-key': string;
    };
    params: {
        onlyjup: boolean;
        tokens: string; // Comma-separated string of tokens
    };
}

// Define response structure (adjust based on actual API response)
interface MarketCacheResponse {
    cached: string;
    market_cache: Array<{
        pubkey: string;
        owner: string;
        params?: Record<string, string>; // Optional additional parameters
    }>;
}

// Request options
const requestOptions: RequestOptions = {
    headers: {
        'Content-Type': 'application/json',
        'x-api-key': API_KEY,
    },
    params: {
        onlyjup: false,
        tokens: [
            "So11111111111111111111111111111111111111112",
            "BbtrrZ2ExfCTzrndFBCx5iNDFXxuVxNMdEZ14BZxpump",
            "6b7NtVRo6jDSUZ75qfhHgpy99XVkSu1kfoTFu2E3pump",
        ].join(','), // Join tokens into a comma-separated string
    },
};

// Function to fetch the filtered market cache
const getFilteredMarketCache = async (): Promise<void> => {
    try {
        const response: AxiosResponse<MarketCacheResponse> = await axios.get(API_URL, requestOptions);
        console.log('Market-Cache: ', response.data);
    } catch (error: any) {
        console.error('Error: ', error?.response?.data || error.message);
    }
};

// Execute the function
getFilteredMarketCache();
```

{% endtab %}

{% tab title="Python" %}

```python
# Define constants
API_URL = "https://pro.circular.bot/market/cache"
API_KEY = "your-api-key"  # Replace with your API key

# Request options
headers = {
    "Content-Type": "application/json",
    "x-api-key": API_KEY,
}

tokens = [
    "So11111111111111111111111111111111111111112",
    "BbtrrZ2ExfCTzrndFBCx5iNDFXxuVxNMdEZ14BZxpump",
    "6b7NtVRo6jDSUZ75qfhHgpy99XVkSu1kfoTFu2E3pump",
]

params = {
    "onlyjup": False,
    "tokens": ",".join(tokens),  # Join tokens into a comma-separated string
}

# Function to fetch filtered market cache
def get_filtered_market_cache():
    try:
        response = requests.get(API_URL, headers=headers, params=params)
        response.raise_for_status()  # Raise an exception for HTTP errors
        print("Market-Cache:", response.json())
    except requests.exceptions.RequestException as error:
        print("Error:", error.response.json() if error.response else str(error))

# Execute the function
get_filtered_market_cache()
```

{% endtab %}

{% tab title="Rust" %}

<pre class="language-rust"><code class="lang-rust">// Define constants
<strong>const API_URL: &#x26;str = "https://pro.circular.bot/market/cache";
</strong>const API_KEY: &#x26;str = "your-api-key"; // Replace with your API key

// Define the response structure
#[derive(Deserialize, Debug)]
struct MarketCacheResponse {
    cached: String,
    market_cache: Vec&#x3C;MarketCacheEntry>,
}

#[derive(Deserialize, Debug)]
struct MarketCacheEntry {
    pubkey: String,
    owner: String,
    params: Option&#x3C;std::collections::HashMap&#x3C;String, String>>, // Optional additional parameters
}

// Function to fetch the filtered market cache
async fn get_filtered_market_cache() -> Result&#x3C;(), Box&#x3C;dyn std::error::Error>> {
    // Create a client
    let client = reqwest::Client::new();

    // Set up headers
    let mut headers = HeaderMap::new();
    headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));
    headers.insert("x-api-key", HeaderValue::from_static(API_KEY));

    // Define tokens as a comma-separated string
    let tokens = vec![
        "So11111111111111111111111111111111111111112",
        "BbtrrZ2ExfCTzrndFBCx5iNDFXxuVxNMdEZ14BZxpump",
        "6b7NtVRo6jDSUZ75qfhHgpy99XVkSu1kfoTFu2E3pump",
    ]
    .join(",");

    // Set up query parameters
    let query_params = [("onlyjup", "false"), ("tokens", &#x26;tokens)];

    // Send the GET request
    let response = client
        .get(API_URL)
        .headers(headers)
        .query(&#x26;query_params)
        .send()
        .await?;

    if response.status().is_success() {
        let market_cache: MarketCacheResponse = response.json().await?;
        println!("Market-Cache: {:#?}", market_cache);
    } else {
        eprintln!(
            "Error: {}",
            response.text().await.unwrap_or_else(|_| "Unknown error".to_string())
        );
    }

    Ok(())
}

// Main function
#[tokio::main]
async fn main() {
    if let Err(err) = get_filtered_market_cache().await {
        eprintln!("An error occurred: {}", err);
    }
}
</code></pre>

{% endtab %}
{% endtabs %}
