> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wistx.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Search Costs

> Search cost data using semantic search

> Search cost data using semantic search

<CodeGroup>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.wistx.ai/v1/cost/search \
    --header 'Content-Type: application/json' \
    --data '{
      "query": "EC2 instance pricing in us-east-1",
      "providers": ["aws"],
      "service_categories": ["compute"],
      "regions": ["us-east-1"],
      "max_price": 100.00,
      "min_price": 0.10,
      "max_results": 20
    }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.wistx.ai/v1/cost/search"

  response = requests.post(
      url,
      headers={"Content-Type": "application/json"},
      json={
          "query": "EC2 instance pricing in us-east-1",
          "providers": ["aws"],
          "service_categories": ["compute"],
          "regions": ["us-east-1"],
          "max_price": 100.00,
          "min_price": 0.10,
          "max_results": 20
      }
  )

  data = response.json()
  print(f"Found {data['total']} cost results")
  ```

  ```javascript JavaScript theme={null}
  const url = "https://api.wistx.ai/v1/cost/search";

  const response = await fetch(url, {
    method: "POST",
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      query: "EC2 instance pricing in us-east-1",
      providers: ["aws"],
      service_categories: ["compute"],
      regions: ["us-east-1"],
      max_price: 100.00,
      min_price: 0.10,
      max_results: 20
    })
  });

  const data = await response.json();
  console.log(`Found ${data.total} cost results`);
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "net/http"
  )

  func main() {
      url := "https://api.wistx.ai/v1/cost/search"

      payload := map[string]interface{}{
          "query": "EC2 instance pricing in us-east-1",
          "providers": []string{"aws"},
          "service_categories": []string{"compute"},
          "regions": []string{"us-east-1"},
          "max_price": 100.00,
          "min_price": 0.10,
          "max_results": 20,
      }

      jsonData, _ := json.Marshal(payload)
      req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
      req.Header.Set("Content-Type", "application/json")

      client := &http.Client{}
      resp, _ := client.Do(req)
      defer resp.Body.Close()

      var result map[string]interface{}
      json.NewDecoder(resp.Body).Decode(&result)
      fmt.Printf("Found %v cost results\n", result["total"])
  }
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'json'
  require 'uri'

  url = URI("https://api.wistx.ai/v1/cost/search")

  http = Net::HTTP.new(url.host, url.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(url)
  request["Content-Type"] = "application/json"
  request.body = {
    query: "EC2 instance pricing in us-east-1",
    providers: ["aws"],
    service_categories: ["compute"],
    regions: ["us-east-1"],
    max_price: 100.00,
    min_price: 0.10,
    max_results: 20
  }.to_json

  response = http.request(request)
  data = JSON.parse(response.body)
  puts "Found #{data['total']} cost results"
  ```

  ```php PHP theme={null}
  <?php

  $url = "https://api.wistx.ai/v1/cost/search";

  $data = [
      "query" => "EC2 instance pricing in us-east-1",
      "providers" => ["aws"],
      "service_categories" => ["compute"],
      "regions" => ["us-east-1"],
      "max_price" => 100.00,
      "min_price" => 0.10,
      "max_results" => 20
  ];

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      "Content-Type: application/json"
  ]);

  $response = curl_exec($ch);
  curl_close($ch);

  $data = json_decode($response, true);
  echo "Found " . $data['total'] . " cost results";
  ```

  ```java Java theme={null}
  import java.net.HttpURLConnection;
  import java.net.URL;
  import java.io.OutputStream;
  import java.io.BufferedReader;
  import java.io.InputStreamReader;
  import com.google.gson.Gson;
  import com.google.gson.JsonObject;

  public class SearchCosts {
      public static void main(String[] args) throws Exception {
          URL url = new URL("https://api.wistx.ai/v1/cost/search");
          
          HttpURLConnection conn = (HttpURLConnection) url.openConnection();
          conn.setRequestMethod("POST");
          conn.setRequestProperty("Content-Type", "application/json");
          conn.setDoOutput(true);
          
          JsonObject payload = new JsonObject();
          payload.addProperty("query", "EC2 instance pricing in us-east-1");
          payload.addProperty("max_price", 100.00);
          payload.addProperty("min_price", 0.10);
          payload.addProperty("max_results", 20);
          
          Gson gson = new Gson();
          String[] providers = {"aws"};
          String[] serviceCategories = {"compute"};
          String[] regions = {"us-east-1"};
          payload.add("providers", gson.toJsonTree(providers));
          payload.add("service_categories", gson.toJsonTree(serviceCategories));
          payload.add("regions", gson.toJsonTree(regions));
          
          try (OutputStream os = conn.getOutputStream()) {
              byte[] input = gson.toJson(payload).getBytes("utf-8");
              os.write(input, 0, input.length);
          }
          
          BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"));
          StringBuilder response = new StringBuilder();
          String responseLine;
          while ((responseLine = br.readLine()) != null) {
              response.append(responseLine.trim());
          }
          System.out.println(response.toString());
      }
  }
  ```
</CodeGroup>

## Request Parameters

<ParamField body="query" type="string" required>
  Search query describing the cost data you're looking for.
</ParamField>

<ParamField body="providers" type="array[string]">
  Filter by cloud providers.

  **Options:** `aws`, `gcp`, `azure`, `oracle`, `alibaba`
</ParamField>

<ParamField body="service_categories" type="array[string]">
  Filter by service categories (e.g., `compute`, `storage`, `networking`).
</ParamField>

<ParamField body="regions" type="array[string]">
  Filter by regions (e.g., `us-east-1`, `eu-west-1`).
</ParamField>

<ParamField body="pricing_categories" type="array[string]">
  Filter by pricing categories.
</ParamField>

<ParamField body="max_price" type="number">
  Maximum price filter (decimal).
</ParamField>

<ParamField body="min_price" type="number">
  Minimum price filter (decimal).
</ParamField>

<ParamField body="max_results" type="integer">
  Maximum number of results to return.

  **Minimum:** 1\
  **Maximum:** 100\
  **Default:** 20
</ParamField>

## Response

<ResponseExample>
  ```json 200 Success theme={null}
  {
    "results": [
      {
        "provider": "aws",
        "service": "EC2",
        "instance_type": "t3.micro",
        "region": "us-east-1",
        "list_unit_price": 0.0104,
        "currency": "USD",
        "pricing_category": "on-demand",
        "service_category": "compute",
        "lookup_key": "aws-ec2-t3.micro-us-east-1-on-demand"
      }
    ],
    "total": 1,
    "query": "EC2 instance pricing in us-east-1",
    "filters": {
      "providers": ["aws"],
      "service_categories": ["compute"],
      "regions": ["us-east-1"],
      "pricing_categories": null,
      "max_price": 100.00,
      "min_price": 0.10
    }
  }
  ```

  ```json 400 Bad Request theme={null}
  {
    "error": {
      "code": "VALIDATION_ERROR",
      "message": "Invalid request parameters",
      "details": "query is required"
    },
    "metadata": {
      "request_id": "req_abc123",
      "timestamp": 1704067200.0
    }
  }
  ```

  ```json 500 Internal Server Error theme={null}
  {
    "detail": "Search failed: Failed to generate query embedding"
  }
  ```

  ```json 500 Internal Server Error theme={null}
  {
    "detail": "Pinecone API key not configured"
  }
  ```
</ResponseExample>

## Related Endpoints

* [Get Costs by Provider](/api-reference/cost-search/by-provider) - Get costs by provider
* [Compare Costs](/api-reference/cost-search/compare) - Compare costs
* [Get Optimization Opportunities](/api-reference/cost-search/optimization-opportunities) - Find optimization opportunities


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.