> ## 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.

# Get Costs by Provider

> Get costs by provider with optional filters

> Get costs by provider with optional filters

### Endpoint

`GET /v1/cost/by-provider/{provider}`

<CodeGroup>
  ```bash cURL theme={null}
  curl --request GET \
    --url 'https://api.wistx.ai/v1/cost/by-provider/aws?region=us-east-1&service_category=compute&limit=100&offset=0'
  ```

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

  url = "https://api.wistx.ai/v1/cost/by-provider/aws"
  response = requests.get(
      url,
      params={
          "region": "us-east-1",
          "service_category": "compute",
          "limit": 100,
          "offset": 0
      }
  )

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

  ```javascript JavaScript theme={null}
  const url = "https://api.wistx.ai/v1/cost/by-provider/aws";
  const params = new URLSearchParams({
    region: "us-east-1",
    service_category: "compute",
    limit: "100",
    offset: "0"
  });

  const response = await fetch(`${url}?${params}`);
  const data = await response.json();
  console.log(`Found ${data.count} of ${data.total} results`);
  ```

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

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

  func main() {
      baseURL := "https://api.wistx.ai/v1/cost/by-provider/aws"
      params := url.Values{}
      params.Add("region", "us-east-1")
      params.Add("service_category", "compute")
      params.Add("limit", "100")
      params.Add("offset", "0")
      fullURL := baseURL + "?" + params.Encode()

      resp, _ := http.Get(fullURL)
      defer resp.Body.Close()

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

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

  url = URI("https://api.wistx.ai/v1/cost/by-provider/aws")
  params = {
    region: "us-east-1",
    service_category: "compute",
    limit: 100,
    offset: 0
  }
  url.query = URI.encode_www_form(params)

  response = Net::HTTP.get_response(url)
  data = JSON.parse(response.body)
  puts "Found #{data['count']} of #{data['total']} results"
  ```

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

  $url = "https://api.wistx.ai/v1/cost/by-provider/aws?" . http_build_query([
      "region" => "us-east-1",
      "service_category" => "compute",
      "limit" => 100,
      "offset" => 0
  ]);

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

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

  public class GetCostsByProvider {
      public static void main(String[] args) throws Exception {
          URL url = new URL("https://api.wistx.ai/v1/cost/by-provider/aws?region=us-east-1&service_category=compute&limit=100&offset=0");
          
          HttpURLConnection conn = (HttpURLConnection) url.openConnection();
          conn.setRequestMethod("GET");
          
          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());
          }
          
          Gson gson = new Gson();
          JsonObject data = gson.fromJson(response.toString(), JsonObject.class);
          System.out.println("Found " + data.get("count") + " of " + data.get("total") + " results");
      }
  }
  ```
</CodeGroup>

### Path Parameters

<ParamField path="provider" type="string" required>
  Cloud provider.

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

### Query Parameters

<ParamField query="region" type="string">
  Filter by region (e.g., `us-east-1`, `eu-west-1`).
</ParamField>

<ParamField query="service_category" type="string">
  Filter by service category (e.g., `compute`, `storage`, `networking`).
</ParamField>

<ParamField query="limit" type="integer">
  Maximum results to return.

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

<ParamField query="offset" type="integer">
  Pagination offset.

  **Minimum:** 0\
  **Default:** 0
</ParamField>

### Response

<ResponseExample>
  ```json 200 Success theme={null}
  {
    "provider": "aws",
    "total": 5000,
    "count": 100,
    "offset": 0,
    "limit": 100,
    "results": [
      {
        "provider": "aws",
        "service_name": "EC2",
        "resource_type": "t3.micro",
        "region_id": "us-east-1",
        "list_unit_price": 0.0104,
        "billing_currency": "USD",
        "pricing_unit": "hour",
        "pricing_category": "OnDemand"
      }
    ]
  }
  ```

  ```json 500 Internal Server Error theme={null}
  {
    "detail": "Query failed: Database connection error"
  }
  ```
</ResponseExample>

## Related Endpoints

* [Search Costs](/api-reference/cost-search/search) - Search cost data
* [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.