> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://documentation.sayari.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://documentation.sayari.com/_mcp/server.

# Get Usage

GET https://api.sayari.com/v1/usage

The usage endpoint provides a simple interface to retrieve information on usage made by your API account. This includes both views per API path and credits consumed. The time period for the usage query is also specified in the response and whether or not this includes total usage.

Reference: https://documentation.sayari.com/api/api-reference/info/get-usage

## Authentication

- OAuth2 — send the obtained token as `Authorization: Bearer <token>`

## Servers

- `https://api.sayari.com` (Production, default)
- `https://api.internal.sayari.com` (Dev)
- `https://api.uk.sayari.com` (Production_UK)

## Request

### Query parameters

- `from` (date, optional) — An ISO 8601 encoded date string indicating the starting time period to obtain usage stats. In the format YYYY-MM-DD
- `to` (date, optional) — An ISO 8601 encoded date string indicating the ending time period to obtain usage stats. In the format YYYY-MM-DD

## Response

### 200

OK

- `usage` (UsageInfo, required) — Usage information for each endpoint
- `from` (string, required) — The start date of the returned usage information.
- `to` (string, required) — The end date of the returned usage information.

## Errors

### 400 Bad Request

- `any`

### 401 Unauthorized

- `any`

### 404 Not Found

- `status` (integer, required)
- `message` (list of string, required)
- `success` (boolean, required)

### 429 Rate Limit Exceeded

- `any`

### 500 Internal Server Error

- `any`

## Types

### UsageInfo

- `entity` (integer, optional)
- `record` (integer, optional)
- `resolve` (integer, optional)
- `search` (integer, optional)
- `trade_traversal` (integer, optional)
- `traversal` (integer, optional)

## Examples

**Response**

```json
{
  "usage": {
    "entity": 1,
    "record": 1,
    "resolve": 1,
    "search": 1,
    "trade_traversal": 1,
    "traversal": 1
  },
  "from": "from",
  "to": "to"
}
```

**SDK Code**

```python
import requests

url = "https://api.sayari.com/v1/usage"

headers = {"Authorization": "<token>."}

response = requests.get(url, headers=headers)

print(response.json())
```

```typescript
import { SayariClient } from "sayari";

const sayari = new SayariClient({ clientId: "YOUR_CLIENT_ID", clientSecret: "YOUR_CLIENT_SECRET" });
await sayari.info.getUsage({
    from: "2023-01-15",
    to: "2023-01-15"
});

```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.sayari.com/v1/usage"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "<token>.")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.sayari.com/v1/usage")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = '<token>.'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.sayari.com/v1/usage")
  .header("Authorization", "<token>.")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.sayari.com/v1/usage', [
  'headers' => [
    'Authorization' => '<token>.',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.sayari.com/v1/usage");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "<token>.");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "<token>."]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.sayari.com/v1/usage")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```