获取 Monitoring 监控
GET/v1/watches/{id}
合同 v1 / 1.0.0 62 / 2026-10-10
本页内容
读取监控关联,而非付款历史;事件请查询 /events。
密钥权限:watches / read / monitoring。
参数
| 参数 | 转入 | 必填 | 说明 |
|---|---|---|---|
id | path | 是 | 不透明资源 ID。string minLength: 1 |
请求示例
示例会在您的账户中执行真实操作。请设置代码指定的环境变量。保持密钥私密;写请求不会自动重试。
Shell / cURL
#!/usr/bin/env bash
set -euo pipefail
: "${CRYPTANIO_RESOURCE_ID:?Set CRYPTANIO_RESOURCE_ID}"
: "${CRYPTANIO_API_KEY:?Set CRYPTANIO_API_KEY}"
urlencode() {
local LC_ALL=C text="$1" char index
for ((index=0; index<${#text}; index++)); do
char="${text:index:1}"
case "$char" in [a-zA-Z0-9.~_-]) printf '%s' "$char" ;; *) printf '%%%02X' "'$char" ;; esac
done
}
response_file="$(mktemp)"
trap 'rm -f "$response_file"' EXIT
transfer_status=0
http_status="$(curl \
--silent --show-error --max-time 30 --request GET \
--header "Authorization: Bearer $CRYPTANIO_API_KEY" \
--header 'Accept: application/json' \
"https://api.cryptanio.com/v1/watches/$(urlencode "$CRYPTANIO_RESOURCE_ID")" \
--output "$response_file" --write-out '%{http_code}')" || transfer_status=$?
if [[ "$http_status" == 2?? ]]; then
cat "$response_file"
exit "$transfer_status"
fi
printf 'HTTP %s\n' "$http_status" >&2
cat "$response_file" >&2
exit 1
Go
// Go; standard library only. Run: go run request.go
package main
import (
"fmt"
"io"
"net/http"
"net/url"
"os"
"strings"
"time"
)
func env(name string) string {
value := os.Getenv(name)
if value == "" { fmt.Fprintln(os.Stderr, "Set", name); os.Exit(1) }
return value
}
func run() error {
path := "/v1/watches/{id}"
path = strings.ReplaceAll(path, "{id}", url.PathEscape(env("CRYPTANIO_RESOURCE_ID")))
endpoint, err := url.Parse("https://api.cryptanio.com" + path)
if err != nil { return err }
query := endpoint.Query()
endpoint.RawQuery = query.Encode()
request, err := http.NewRequest("GET", endpoint.String(), nil)
if err != nil { return err }
request.Header.Set("Authorization", "Bearer " + env("CRYPTANIO_API_KEY"))
request.Header.Set("Accept", "application/json")
client := &http.Client{Timeout: 30 * time.Second, CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }}
response, err := client.Do(request)
if err != nil { return err }
defer response.Body.Close()
if response.StatusCode < 200 || response.StatusCode >= 300 {
body, err := io.ReadAll(response.Body)
if err != nil { return err }
return fmt.Errorf("HTTP %d: %s", response.StatusCode, body)
}
_, err = io.Copy(os.Stdout, response.Body)
return err
}
func main() {
if err := run(); err != nil { fmt.Fprintln(os.Stderr, err); os.Exit(1) }
}
Rust
// Cargo.toml dependencies:
// reqwest = { version = "=0.12.24", features = ["blocking", "json"] }
// serde_json = "=1.0.145"
use std::{error::Error, io, time::Duration};
use reqwest::{blocking::Client, redirect::Policy, Method, Url};
fn env(name: &str) -> Result<String, Box<dyn Error>> {
let value = std::env::var(name)?;
if value.is_empty() { return Err(format!("Set {name}").into()); }
Ok(value)
}
fn run() -> Result<(), Box<dyn Error>> {
let mut url = Url::parse("https://api.cryptanio.com")?;
{
let mut segments = url.path_segments_mut().map_err(|_| "Invalid base URL")?;
segments.clear();
segments.push("v1");
segments.push("watches");
segments.push(&env("CRYPTANIO_RESOURCE_ID")?);
}
let client = Client::builder().timeout(Duration::from_secs(30)).redirect(Policy::none()).build()?;
let request = client.request(Method::GET, url)
.header("Authorization", format!("Bearer {}", env("CRYPTANIO_API_KEY")?))
.header("Accept", "application/json".to_owned());
let mut response = request.send()?;
let status = response.status();
if !status.is_success() { return Err(format!("HTTP {}: {}", status.as_u16(), response.text()?).into()); }
io::copy(&mut response, &mut io::stdout())?;
Ok(())
}
fn main() {
if let Err(error) = run() { eprintln!("{error}"); std::process::exit(1); }
}
PHP
<?php
// PHP 8 with the cURL extension. Run this on your server.
function env(string $name): string {
$value = getenv($name);
if ($value === false || $value === '') throw new RuntimeException('Set ' . $name);
return $value;
}
try {
$path = '/v1/watches/{id}';
$path = str_replace('{id}', rawurlencode(env('CRYPTANIO_RESOURCE_ID')), $path);
$query = [
];
$url = 'https://api.cryptanio.com' . $path . ($query ? '?' . http_build_query($query, '', '&', PHP_QUERY_RFC3986) : '');
$headers = [
'Authorization: ' . 'Bearer ' . env('CRYPTANIO_API_KEY'),
'Accept: ' . 'application/json',
];
$curl = curl_init($url);
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => false,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => 30,
]);
$response = curl_exec($curl);
if ($response === false) throw new RuntimeException(curl_error($curl));
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($status < 200 || $status >= 300) throw new RuntimeException('HTTP ' . $status . ': ' . $response);
echo $response;
} catch (Throwable $error) {
fwrite(STDERR, $error->getMessage() . PHP_EOL);
exit(1);
}
Python
# Python 3; standard library only.
import json
import os
import sys
from urllib.error import HTTPError, URLError
from urllib.parse import quote, urlencode
from urllib.request import HTTPRedirectHandler, Request, build_opener
def env(name):
result = os.environ.get(name)
if not result:
raise ValueError("Set " + name)
return result
class NoRedirect(HTTPRedirectHandler):
def redirect_request(self, req, fp, code, msg, headers, newurl):
return None
try:
path = "/v1/watches/{id}"
path = path.replace("{id}", quote(env("CRYPTANIO_RESOURCE_ID"), safe=""))
query = {
}
url = "https://api.cryptanio.com" + path + ("?" + urlencode(query) if query else "")
headers = {
"Authorization": "Bearer " + env("CRYPTANIO_API_KEY"),
"Accept": "application/json",
}
data = None
request = Request(url, data=data, headers=headers, method="GET")
with build_opener(NoRedirect()).open(request, timeout=30) as response:
if not 200 <= response.status < 300:
raise ValueError("HTTP " + str(response.status))
sys.stdout.buffer.write(response.read())
except HTTPError as error:
print("HTTP " + str(error.code) + ": " + error.read().decode("utf-8", errors="replace"), file=sys.stderr)
sys.exit(1)
except (ValueError, URLError, OSError) as error:
print(str(error), file=sys.stderr)
sys.exit(1)
Node.js
// Node.js 18+. Run on your server, never in a browser.
const env = name => {
const result = process.env[name];
if (!result) throw new Error(`Set ${name}`);
return result;
};
try {
let path = "/v1/watches/{id}";
path = path.replace("{id}", encodeURIComponent(env("CRYPTANIO_RESOURCE_ID")));
const url = new URL(path, "https://api.cryptanio.com");
const headers = {
"Authorization": "Bearer " + env("CRYPTANIO_API_KEY"),
"Accept": "application/json",
};
const response = await fetch(url, {
method: "GET", headers, redirect: "manual",
signal: AbortSignal.timeout(30_000),
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
if (response.body) {
for await (const chunk of response.body) process.stdout.write(chunk);
}
} catch (error) {
console.error(error.message);
process.exitCode = 1;
}
响应与错误
200 成功响应。
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 是 | 不透明标识符;请保持为字符串。 minLength: 1 |
project_id | string | 是 | 不透明标识符;请保持为字符串。 minLength: 1 |
service | string | 是 | 项目服务。monitoring |
book_address_id | string | 是 | 匹配的地址簿地址 ID。 minLength: 1 |
status | string | 是 | 项目与地址的关联状态。active、paused、deleted |
chain | string | 是 | 网络代码。 |
address | string | 是 | 规范化地址。 |
asset | string | 是 | 响应字符串中的资产;多个资产以逗号分隔。 |
meta | object | 否 | 地址标签和备注(如已设置)。 |
watched_as | string | 否 | 网络使用时的附加地址标识。 |
sandbox | boolean | 否 | 测试监控为 true;省略时为 false。 |
watch_outgoing | boolean | 是 | 是否监控转出操作。 |
origin_kinds | string[] | 是 | 地址被加入项目的方式。 |
created_at | string | 是 | RFC 3339 格式的 UTC 日期和时间。date-time |
200 application/json
{
"id": "1008",
"project_id": "1002",
"service": "monitoring",
"book_address_id": "1007",
"status": "active",
"chain": "ethereum",
"address": "0x52908400098527886E0F7030069857D2E4169EE7",
"asset": "native",
"sandbox": true,
"watch_outgoing": false,
"origin_kinds": [
"manual"
],
"created_at": "2026-10-06T10:00:00Z"
}401 没有有效且已启用的 API 密钥(unauthorized)。
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
error | object | 是 |
401 application/json
{
"error": {
"code": "forbidden",
"message": "this API key is read-only"
}
}403 密钥不允许该操作、项目、服务或 IP;电子邮件未确认。
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
error | object | 是 |
403 application/json
{
"error": {
"code": "forbidden",
"message": "this API key is read-only"
}
}404 密钥权限范围内未找到对象(not_found)。
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
error | object | 是 |
404 application/json
{
"error": {
"code": "forbidden",
"message": "this API key is read-only"
}
}429 请求过多(rate_limited);按 Retry-After 等待后重试。
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
error | object | 是 |
429 application/json
{
"error": {
"code": "forbidden",
"message": "this API key is read-only"
}
}500 内部错误(internal)。
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
error | object | 是 |
500 application/json
{
"error": {
"code": "forbidden",
"message": "this API key is read-only"
}
}503 暂时不可用(unavailable);请退避重试。
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
error | object | 是 |
503 application/json
{
"error": {
"code": "forbidden",
"message": "this API key is read-only"
}
}嵌套对象
Watch
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
id | string | 是 | 不透明标识符;请保持为字符串。 minLength: 1 |
project_id | string | 是 | 不透明标识符;请保持为字符串。 minLength: 1 |
service | string | 是 | 项目服务。monitoring |
book_address_id | string | 是 | 匹配的地址簿地址 ID。 minLength: 1 |
status | string | 是 | 项目与地址的关联状态。active、paused、deleted |
chain | string | 是 | 网络代码。 |
address | string | 是 | 规范化地址。 |
asset | string | 是 | 响应字符串中的资产;多个资产以逗号分隔。 |
meta | object | 否 | 地址标签和备注(如已设置)。 |
watched_as | string | 否 | 网络使用时的附加地址标识。 |
sandbox | boolean | 否 | 测试监控为 true;省略时为 false。 |
watch_outgoing | boolean | 是 | 是否监控转出操作。 |
origin_kinds | string[] | 是 | 地址被加入项目的方式。 |
created_at | string | 是 | RFC 3339 格式的 UTC 日期和时间。date-time |
ID
不透明标识符。格式不保证固定;不要转换为数字。
string 不透明标识符。格式不保证固定;不要转换为数字。
StringMap
object
Error
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
error | object | 是 |