Response Headers
Every API response includes these headers:
| Header | Type | Description |
|---|---|---|
x-cost | integer | Credits deducted from your wallet for this request |
x-balance | integer | Credits remaining in your wallet after this request |
Reading Headers
Section titled “Reading Headers”# Use -i to show response headerscurl -i 'https://api.echovalue.dev/kv/default/mykey' \ -H 'x-token: mytoken'
# Output includes:# x-cost: 1# x-balance: 99fetch('https://api.echovalue.dev/kv/default/mykey', { headers: { 'x-token': 'mytoken' }}).then(response => { console.log('Cost:', response.headers.get('x-cost')); console.log('Balance:', response.headers.get('x-balance')); return response.text();});import requests
response = requests.get('https://api.echovalue.dev/kv/default/mykey', headers={'x-token': 'mytoken'})print('Cost:', response.headers.get('x-cost'))print('Balance:', response.headers.get('x-balance'))<?php$ch = curl_init('https://api.echovalue.dev/kv/default/mykey');curl_setopt($ch, CURLOPT_HTTPHEADER, ['x-token: mytoken']);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_HEADER, true);
$response = curl_exec($ch);$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);$headers = substr($response, 0, $headerSize);curl_close($ch);
// Parse x-balance from headerspreg_match('/x-balance:\s*(\d+)/i', $headers, $matches);echo 'Balance: ' . $matches[1];?>package main
import ( "fmt" "net/http")
func main() { req, _ := http.NewRequest("GET", "https://api.echovalue.dev/kv/default/mykey", nil) req.Header.Set("x-token", "mytoken")
client := &http.Client{} resp, _ := client.Do(req) defer resp.Body.Close()
fmt.Println("Cost:", resp.Header.Get("x-cost")) fmt.Println("Balance:", resp.Header.Get("x-balance"))}