General
一般操作(简介、订单、参考数据)
创建订单并付款
https://user-api.shardx.com/user/api/orders/purchase按产品名称、地点和周期购买。 数据中心/ISP 必须提供 location。 标准住宅代理(Standart Residential Proxy)无需 location。
请发送 Idempotency-Key 标头以确保重试安全:否则超时后的重试可能会重复扣款并重复发放代理。
Bearer authentication header of the form Bearer <token>.
可选。逻辑操作的唯一标识符(1–128 个 [A-Za-z0-9_.:-] 字符),例如 UUID。
重试结果未知的请求(超时、连接中断)时,请发送相同的键:已完成的请求不会再次执行,而是返回其原始响应。
本 API 的所有修改类端点(POST/PUT/PATCH/DELETE)都接受此标头:购买、续订、追加流量、组件以及今后新增的端点;涉及扣款的端点会明确列出。
除子用户操作外的所有端点:保存的响应会在 7 天内带 `Idempotency-Replayed: true` 标头重放。`409`:使用此键的请求仍在执行(`idempotency_state: in_progress`),或未完成且需要人工核实结果(`idempotency_state: unknown`;不会再次执行)。`422`:该键已用于另一个请求。限流返回的 `429` 不会消耗该键,请使用同一个键重试。
子用户端点(创建、data/add、data/subtract):该键会转发给代理提供商,24 小时内重试不会两次修改配额。409:操作仍在进行,或该键已用于不同的数据。
不带此标头时,请求照常执行,但没有上述保障。
200成功的application/json
400验证/余额错误/库存不足application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
401未经授权application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
403您的账户无法使用此计费周期application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
409使用此 Idempotency-Key 的请求仍在执行(idempotency_state: in_progress),或未完成且需要人工核实结果(idempotency_state: unknown)application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
422该 Idempotency-Key 已用于另一个请求application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
429同一账户 3 秒内超过 1 次请求。响应体为纯文本(Too many requests, retry in <N>s),x-ratelimit-after 标头给出需要等待的秒数。Idempotency-Key 不会被消耗:请使用同一个键重试。text/plain
500内部错误。当订单(或所需的其他记录)不存在或不属于您的账户时,API 同样返回 500;具体原因见 message,例如 Order not found。application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
502库存检查失败,或付款后未能发放代理;此时 order_id 和 refunded 表明款项是否已退回application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
/user/api/orders/purchasePOST /user/api/orders/purchase HTTP/1.1
Host: user-api.shardx.com
Authorization: Bearer YOUR_SECRET_TOKEN
Idempotency-Key: text
Content-Type: application/json
Accept: */*
{
"product": "Datacenter Proxy",
"location": "text",
"cycle": "text",
"quantity": 1,
"promo_code": "text",
"auto_renewal": false,
"addons": [
{
"addon_key": "p0f_slots",
"qty": 1
}
]
}curl -X POST 'https://user-api.shardx.com/user/api/orders/purchase' \
-H 'Authorization: Bearer YOUR_SECRET_TOKEN' \
-H 'Idempotency-Key: text' \
-H 'Content-Type: application/json' \
-d '{"product":"Datacenter Proxy","location":"text","cycle":"text","quantity":1,"promo_code":"text","auto_renewal":false,"addons":[{"addon_key":"p0f_slots","qty":1}]}'import requests
# API token — see Authorizations above.
token = "YOUR_SECRET_TOKEN"
url = "https://user-api.shardx.com/user/api/orders/purchase"
headers = {
"Authorization": f"Bearer {token}",
"Idempotency-Key": "text",
}
payload = {
"product": "Datacenter Proxy",
"location": "text",
"cycle": "text",
"quantity": 1,
"promo_code": "text",
"auto_renewal": False,
"addons": [
{
"addon_key": "p0f_slots",
"qty": 1,
},
],
}
response = requests.post(url, headers=headers, json=payload, timeout=30)
response.raise_for_status()
print(response.status_code)
print(response.text)// API token — see Authorizations above.
const token = "YOUR_SECRET_TOKEN";
const url = "https://user-api.shardx.com/user/api/orders/purchase";
const payload = {
"product": "Datacenter Proxy",
"location": "text",
"cycle": "text",
"quantity": 1,
"promo_code": "text",
"auto_renewal": false,
"addons": [
{
"addon_key": "p0f_slots",
"qty": 1
}
]
};
const response = await fetch(url, {
method: "POST",
headers: {
"Authorization": `Bearer ${token}`,
"Idempotency-Key": "text",
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});
console.log(response.status);
console.log(await response.text());package main
import (
"bytes"
"fmt"
"io"
"log"
"net/http"
)
func main() {
// API token — see Authorizations above.
token := "YOUR_SECRET_TOKEN"
url := "https://user-api.shardx.com/user/api/orders/purchase"
body := bytes.NewBufferString(`{
"product": "Datacenter Proxy",
"location": "text",
"cycle": "text",
"quantity": 1,
"promo_code": "text",
"auto_renewal": false,
"addons": [
{
"addon_key": "p0f_slots",
"qty": 1
}
]
}`)
req, err := http.NewRequest("POST", url, body)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+token)
req.Header.Set("Idempotency-Key", "text")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
out, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(resp.Status)
fmt.Println(string(out))
}// Cargo.toml: reqwest = { version = "0.12", features = ["json"] }, tokio = { version = "1", features = ["full"] }, serde_json = "1"
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// API token — see Authorizations above.
let token = "YOUR_SECRET_TOKEN";
let client = reqwest::Client::new();
let response = client
.post("https://user-api.shardx.com/user/api/orders/purchase")
.header("Authorization", format!("Bearer {token}"))
.header("Idempotency-Key", "text")
.json(&serde_json::json!({
"product": "Datacenter Proxy",
"location": "text",
"cycle": "text",
"quantity": 1,
"promo_code": "text",
"auto_renewal": false,
"addons": [
{
"addon_key": "p0f_slots",
"qty": 1
}
]
}))
.send()
.await?;
println!("{}", response.status());
println!("{}", response.text().await?);
Ok(())
}using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
// API token — see Authorizations above.
var token = "YOUR_SECRET_TOKEN";
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var request = new HttpRequestMessage(HttpMethod.Post, "https://user-api.shardx.com/user/api/orders/purchase");
request.Headers.Add("Idempotency-Key", "text");
request.Content = new StringContent("""
{
"product": "Datacenter Proxy",
"location": "text",
"cycle": "text",
"quantity": 1,
"promo_code": "text",
"auto_renewal": false,
"addons": [
{
"addon_key": "p0f_slots",
"qty": 1
}
]
}
""", Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}// build: c++ -std=c++17 main.cpp -lcurl
#include <curl/curl.h>
#include <iostream>
#include <string>
static size_t write_cb(char *ptr, size_t size, size_t nmemb, void *userdata) {
static_cast<std::string *>(userdata)->append(ptr, size * nmemb);
return size * nmemb;
}
int main() {
// API token — see Authorizations above.
const std::string token = "YOUR_SECRET_TOKEN";
curl_global_init(CURL_GLOBAL_DEFAULT);
CURL *curl = curl_easy_init();
if (!curl) {
std::cerr << "curl_easy_init failed\n";
curl_global_cleanup();
return 1;
}
struct curl_slist *headers = nullptr;
headers = curl_slist_append(headers, ("Authorization: Bearer " + token).c_str());
headers = curl_slist_append(headers, "Idempotency-Key: text");
headers = curl_slist_append(headers, "Content-Type: application/json");
const std::string body = R"json({
"product": "Datacenter Proxy",
"location": "text",
"cycle": "text",
"quantity": 1,
"promo_code": "text",
"auto_renewal": false,
"addons": [
{
"addon_key": "p0f_slots",
"qty": 1
}
]
})json";
std::string response;
curl_easy_setopt(curl, CURLOPT_URL, "https://user-api.shardx.com/user/api/orders/purchase");
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str());
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, static_cast<long>(body.size()));
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
const CURLcode rc = curl_easy_perform(curl);
if (rc != CURLE_OK) {
std::cerr << curl_easy_strerror(rc) << "\n";
} else {
long status = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status);
std::cout << status << "\n" << response << "\n";
}
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
curl_global_cleanup();
return rc == CURLE_OK ? 0 : 1;
}{
"success": true,
"message": "text",
"order_id": 1
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}"Too many requests, retry in 2s"{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}计算订单成本
https://user-api.shardx.com/user/api/orders/calculate按产品名称、周期名称和数量计算价格。使用与购买相同的验证规则(允许的计费周期、促销规则)。
Bearer authentication header of the form Bearer <token>.
URL 编码的 JSON 组件数组,例如 [{"addon_key":"p0f_slots","qty":5}]
200成功application/json
附加组件总数,次要单位
最终价格 + 插件价格
400验证错误application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
401未经授权application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
403您的账户无法使用此计费周期application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
500内部错误。当订单(或所需的其他记录)不存在或不属于您的账户时,API 同样返回 500;具体原因见 message,例如 Order not found。application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
/user/api/orders/calculate?product=textGET /user/api/orders/calculate?product=text HTTP/1.1
Host: user-api.shardx.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*curl -X GET 'https://user-api.shardx.com/user/api/orders/calculate?product=text' \
-H 'Authorization: Bearer YOUR_SECRET_TOKEN'import requests
# API token — see Authorizations above.
token = "YOUR_SECRET_TOKEN"
url = "https://user-api.shardx.com/user/api/orders/calculate"
params = {
"product": "text",
}
headers = {
"Authorization": f"Bearer {token}",
}
response = requests.get(url, params=params, headers=headers, timeout=30)
response.raise_for_status()
print(response.status_code)
print(response.text)// API token — see Authorizations above.
const token = "YOUR_SECRET_TOKEN";
const url = "https://user-api.shardx.com/user/api/orders/calculate?product=text";
const response = await fetch(url, {
method: "GET",
headers: {
"Authorization": `Bearer ${token}`,
},
});
console.log(response.status);
console.log(await response.text());package main
import (
"fmt"
"io"
"log"
"net/http"
)
func main() {
// API token — see Authorizations above.
token := "YOUR_SECRET_TOKEN"
url := "https://user-api.shardx.com/user/api/orders/calculate?product=text"
req, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
out, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(resp.Status)
fmt.Println(string(out))
}// Cargo.toml: reqwest = { version = "0.12", features = ["json"] }, tokio = { version = "1", features = ["full"] }
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// API token — see Authorizations above.
let token = "YOUR_SECRET_TOKEN";
let client = reqwest::Client::new();
let response = client
.get("https://user-api.shardx.com/user/api/orders/calculate?product=text")
.header("Authorization", format!("Bearer {token}"))
.send()
.await?;
println!("{}", response.status());
println!("{}", response.text().await?);
Ok(())
}using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
// API token — see Authorizations above.
var token = "YOUR_SECRET_TOKEN";
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var request = new HttpRequestMessage(HttpMethod.Get, "https://user-api.shardx.com/user/api/orders/calculate?product=text");
var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}// build: c++ -std=c++17 main.cpp -lcurl
#include <curl/curl.h>
#include <iostream>
#include <string>
static size_t write_cb(char *ptr, size_t size, size_t nmemb, void *userdata) {
static_cast<std::string *>(userdata)->append(ptr, size * nmemb);
return size * nmemb;
}
int main() {
// API token — see Authorizations above.
const std::string token = "YOUR_SECRET_TOKEN";
curl_global_init(CURL_GLOBAL_DEFAULT);
CURL *curl = curl_easy_init();
if (!curl) {
std::cerr << "curl_easy_init failed\n";
curl_global_cleanup();
return 1;
}
struct curl_slist *headers = nullptr;
headers = curl_slist_append(headers, ("Authorization: Bearer " + token).c_str());
std::string response;
curl_easy_setopt(curl, CURLOPT_URL, "https://user-api.shardx.com/user/api/orders/calculate?product=text");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
const CURLcode rc = curl_easy_perform(curl);
if (rc != CURLE_OK) {
std::cerr << curl_easy_strerror(rc) << "\n";
} else {
long status = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status);
std::cout << status << "\n" << response << "\n";
}
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
curl_global_cleanup();
return rc == CURLE_OK ? 0 : 1;
}{
"original_price": 1,
"final_price": 1,
"discount_percent": 1,
"addons_price": 1,
"total_with_addons": 1
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}更改订单结算周期
https://user-api.shardx.com/user/api/orders/change-billing-cycle/{order_id}按周期名称更改计费周期。仅适用于数据中心和 ISP 代理。 如果促销代码在所选周期内不可用,将自动重置。
Bearer authentication header of the form Bearer <token>.
200成功的application/json
400无效的产品或周期application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
401未经授权application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
403该用户无法使用循环application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
500内部错误。当订单(或所需的其他记录)不存在或不属于您的账户时,API 同样返回 500;具体原因见 message,例如 Order not found。application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
/user/api/orders/change-billing-cycle/1POST /user/api/orders/change-billing-cycle/1 HTTP/1.1
Host: user-api.shardx.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
{
"cycle": "text"
}curl -X POST 'https://user-api.shardx.com/user/api/orders/change-billing-cycle/1' \
-H 'Authorization: Bearer YOUR_SECRET_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"cycle":"text"}'import requests
# API token — see Authorizations above.
token = "YOUR_SECRET_TOKEN"
url = "https://user-api.shardx.com/user/api/orders/change-billing-cycle/1"
headers = {
"Authorization": f"Bearer {token}",
}
payload = {
"cycle": "text",
}
response = requests.post(url, headers=headers, json=payload, timeout=30)
response.raise_for_status()
print(response.status_code)
print(response.text)// API token — see Authorizations above.
const token = "YOUR_SECRET_TOKEN";
const url = "https://user-api.shardx.com/user/api/orders/change-billing-cycle/1";
const payload = {
"cycle": "text"
};
const response = await fetch(url, {
method: "POST",
headers: {
"Authorization": `Bearer ${token}`,
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});
console.log(response.status);
console.log(await response.text());package main
import (
"bytes"
"fmt"
"io"
"log"
"net/http"
)
func main() {
// API token — see Authorizations above.
token := "YOUR_SECRET_TOKEN"
url := "https://user-api.shardx.com/user/api/orders/change-billing-cycle/1"
body := bytes.NewBufferString(`{
"cycle": "text"
}`)
req, err := http.NewRequest("POST", url, body)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+token)
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
out, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(resp.Status)
fmt.Println(string(out))
}// Cargo.toml: reqwest = { version = "0.12", features = ["json"] }, tokio = { version = "1", features = ["full"] }, serde_json = "1"
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// API token — see Authorizations above.
let token = "YOUR_SECRET_TOKEN";
let client = reqwest::Client::new();
let response = client
.post("https://user-api.shardx.com/user/api/orders/change-billing-cycle/1")
.header("Authorization", format!("Bearer {token}"))
.json(&serde_json::json!({
"cycle": "text"
}))
.send()
.await?;
println!("{}", response.status());
println!("{}", response.text().await?);
Ok(())
}using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
// API token — see Authorizations above.
var token = "YOUR_SECRET_TOKEN";
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var request = new HttpRequestMessage(HttpMethod.Post, "https://user-api.shardx.com/user/api/orders/change-billing-cycle/1");
request.Content = new StringContent("""
{
"cycle": "text"
}
""", Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}// build: c++ -std=c++17 main.cpp -lcurl
#include <curl/curl.h>
#include <iostream>
#include <string>
static size_t write_cb(char *ptr, size_t size, size_t nmemb, void *userdata) {
static_cast<std::string *>(userdata)->append(ptr, size * nmemb);
return size * nmemb;
}
int main() {
// API token — see Authorizations above.
const std::string token = "YOUR_SECRET_TOKEN";
curl_global_init(CURL_GLOBAL_DEFAULT);
CURL *curl = curl_easy_init();
if (!curl) {
std::cerr << "curl_easy_init failed\n";
curl_global_cleanup();
return 1;
}
struct curl_slist *headers = nullptr;
headers = curl_slist_append(headers, ("Authorization: Bearer " + token).c_str());
headers = curl_slist_append(headers, "Content-Type: application/json");
const std::string body = R"json({
"cycle": "text"
})json";
std::string response;
curl_easy_setopt(curl, CURLOPT_URL, "https://user-api.shardx.com/user/api/orders/change-billing-cycle/1");
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str());
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, static_cast<long>(body.size()));
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
const CURLcode rc = curl_easy_perform(curl);
if (rc != CURLE_OK) {
std::cerr << curl_easy_strerror(rc) << "\n";
} else {
long status = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status);
std::cout << status << "\n" << response << "\n";
}
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
curl_global_cleanup();
return rc == CURLE_OK ? 0 : 1;
}{
"success": true,
"message": "text",
"order_id": 1,
"original_price": 1,
"final_price": 1,
"discount_percent": 1
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}变更订单自动续订
https://user-api.shardx.com/user/api/orders/edit-auto-renewal/{order_id}启用/禁用自动续订。仅适用于数据中心和 ISP 代理。
Bearer authentication header of the form Bearer <token>.
200成功的application/json
400此操作的产品无效application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
401未经授权application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
500内部错误。当订单(或所需的其他记录)不存在或不属于您的账户时,API 同样返回 500;具体原因见 message,例如 Order not found。application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
/user/api/orders/edit-auto-renewal/1?auto_renewal=truePOST /user/api/orders/edit-auto-renewal/1?auto_renewal=true HTTP/1.1
Host: user-api.shardx.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*curl -X POST 'https://user-api.shardx.com/user/api/orders/edit-auto-renewal/1?auto_renewal=true' \
-H 'Authorization: Bearer YOUR_SECRET_TOKEN'import requests
# API token — see Authorizations above.
token = "YOUR_SECRET_TOKEN"
url = "https://user-api.shardx.com/user/api/orders/edit-auto-renewal/1"
params = {
"auto_renewal": "true",
}
headers = {
"Authorization": f"Bearer {token}",
}
response = requests.post(url, params=params, headers=headers, timeout=30)
response.raise_for_status()
print(response.status_code)
print(response.text)// API token — see Authorizations above.
const token = "YOUR_SECRET_TOKEN";
const url = "https://user-api.shardx.com/user/api/orders/edit-auto-renewal/1?auto_renewal=true";
const response = await fetch(url, {
method: "POST",
headers: {
"Authorization": `Bearer ${token}`,
},
});
console.log(response.status);
console.log(await response.text());package main
import (
"fmt"
"io"
"log"
"net/http"
)
func main() {
// API token — see Authorizations above.
token := "YOUR_SECRET_TOKEN"
url := "https://user-api.shardx.com/user/api/orders/edit-auto-renewal/1?auto_renewal=true"
req, err := http.NewRequest("POST", url, nil)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
out, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(resp.Status)
fmt.Println(string(out))
}// Cargo.toml: reqwest = { version = "0.12", features = ["json"] }, tokio = { version = "1", features = ["full"] }
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// API token — see Authorizations above.
let token = "YOUR_SECRET_TOKEN";
let client = reqwest::Client::new();
let response = client
.post("https://user-api.shardx.com/user/api/orders/edit-auto-renewal/1?auto_renewal=true")
.header("Authorization", format!("Bearer {token}"))
.send()
.await?;
println!("{}", response.status());
println!("{}", response.text().await?);
Ok(())
}using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
// API token — see Authorizations above.
var token = "YOUR_SECRET_TOKEN";
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var request = new HttpRequestMessage(HttpMethod.Post, "https://user-api.shardx.com/user/api/orders/edit-auto-renewal/1?auto_renewal=true");
var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}// build: c++ -std=c++17 main.cpp -lcurl
#include <curl/curl.h>
#include <iostream>
#include <string>
static size_t write_cb(char *ptr, size_t size, size_t nmemb, void *userdata) {
static_cast<std::string *>(userdata)->append(ptr, size * nmemb);
return size * nmemb;
}
int main() {
// API token — see Authorizations above.
const std::string token = "YOUR_SECRET_TOKEN";
curl_global_init(CURL_GLOBAL_DEFAULT);
CURL *curl = curl_easy_init();
if (!curl) {
std::cerr << "curl_easy_init failed\n";
curl_global_cleanup();
return 1;
}
struct curl_slist *headers = nullptr;
headers = curl_slist_append(headers, ("Authorization: Bearer " + token).c_str());
std::string response;
curl_easy_setopt(curl, CURLOPT_URL, "https://user-api.shardx.com/user/api/orders/edit-auto-renewal/1?auto_renewal=true");
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
const CURLcode rc = curl_easy_perform(curl);
if (rc != CURLE_OK) {
std::cerr << curl_easy_strerror(rc) << "\n";
} else {
long status = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status);
std::cout << status << "\n" << response << "\n";
}
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
curl_global_cleanup();
return rc == CURLE_OK ? 0 : 1;
}{
"success": true,
"message": "text"
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}获取产品及其周期
https://user-api.shardx.com/user/api/proxies/products返回具有可用循环名称的 API 产品。
Bearer authentication header of the form Bearer <token>.
200产品列表application/json
productsobject · ProductWithCycles[]requiredShow propertiesHide properties
401缺少 API 密钥或密钥无效:Missing or invalid Authorization header、Invalid API key、API key mismatchapplication/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
/user/api/proxies/productsGET /user/api/proxies/products HTTP/1.1
Host: user-api.shardx.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*curl -X GET 'https://user-api.shardx.com/user/api/proxies/products' \
-H 'Authorization: Bearer YOUR_SECRET_TOKEN'import requests
# API token — see Authorizations above.
token = "YOUR_SECRET_TOKEN"
url = "https://user-api.shardx.com/user/api/proxies/products"
headers = {
"Authorization": f"Bearer {token}",
}
response = requests.get(url, headers=headers, timeout=30)
response.raise_for_status()
print(response.status_code)
print(response.text)// API token — see Authorizations above.
const token = "YOUR_SECRET_TOKEN";
const url = "https://user-api.shardx.com/user/api/proxies/products";
const response = await fetch(url, {
method: "GET",
headers: {
"Authorization": `Bearer ${token}`,
},
});
console.log(response.status);
console.log(await response.text());package main
import (
"fmt"
"io"
"log"
"net/http"
)
func main() {
// API token — see Authorizations above.
token := "YOUR_SECRET_TOKEN"
url := "https://user-api.shardx.com/user/api/proxies/products"
req, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
out, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(resp.Status)
fmt.Println(string(out))
}// Cargo.toml: reqwest = { version = "0.12", features = ["json"] }, tokio = { version = "1", features = ["full"] }
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// API token — see Authorizations above.
let token = "YOUR_SECRET_TOKEN";
let client = reqwest::Client::new();
let response = client
.get("https://user-api.shardx.com/user/api/proxies/products")
.header("Authorization", format!("Bearer {token}"))
.send()
.await?;
println!("{}", response.status());
println!("{}", response.text().await?);
Ok(())
}using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
// API token — see Authorizations above.
var token = "YOUR_SECRET_TOKEN";
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var request = new HttpRequestMessage(HttpMethod.Get, "https://user-api.shardx.com/user/api/proxies/products");
var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}// build: c++ -std=c++17 main.cpp -lcurl
#include <curl/curl.h>
#include <iostream>
#include <string>
static size_t write_cb(char *ptr, size_t size, size_t nmemb, void *userdata) {
static_cast<std::string *>(userdata)->append(ptr, size * nmemb);
return size * nmemb;
}
int main() {
// API token — see Authorizations above.
const std::string token = "YOUR_SECRET_TOKEN";
curl_global_init(CURL_GLOBAL_DEFAULT);
CURL *curl = curl_easy_init();
if (!curl) {
std::cerr << "curl_easy_init failed\n";
curl_global_cleanup();
return 1;
}
struct curl_slist *headers = nullptr;
headers = curl_slist_append(headers, ("Authorization: Bearer " + token).c_str());
std::string response;
curl_easy_setopt(curl, CURLOPT_URL, "https://user-api.shardx.com/user/api/proxies/products");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
const CURLcode rc = curl_easy_perform(curl);
if (rc != CURLE_OK) {
std::cerr << curl_easy_strerror(rc) << "\n";
} else {
long status = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status);
std::cout << status << "\n" << response << "\n";
}
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
curl_global_cleanup();
return rc == CURLE_OK ? 0 : 1;
}{
"success": true,
"products": [
{
"name": "text",
"description": "text",
"location": "text",
"cycles": [
"text"
]
}
]
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}获取可用代理数量
https://user-api.shardx.com/user/api/proxies/available-count返回所有产品的总可用数量。
Bearer authentication header of the form Bearer <token>.
200成功的application/json
401缺少 API 密钥或密钥无效:Missing or invalid Authorization header、Invalid API key、API key mismatchapplication/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
502代理提供商不可用或返回错误(Upstream error: <status>)application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
/user/api/proxies/available-countGET /user/api/proxies/available-count HTTP/1.1
Host: user-api.shardx.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*curl -X GET 'https://user-api.shardx.com/user/api/proxies/available-count' \
-H 'Authorization: Bearer YOUR_SECRET_TOKEN'import requests
# API token — see Authorizations above.
token = "YOUR_SECRET_TOKEN"
url = "https://user-api.shardx.com/user/api/proxies/available-count"
headers = {
"Authorization": f"Bearer {token}",
}
response = requests.get(url, headers=headers, timeout=30)
response.raise_for_status()
print(response.status_code)
print(response.text)// API token — see Authorizations above.
const token = "YOUR_SECRET_TOKEN";
const url = "https://user-api.shardx.com/user/api/proxies/available-count";
const response = await fetch(url, {
method: "GET",
headers: {
"Authorization": `Bearer ${token}`,
},
});
console.log(response.status);
console.log(await response.text());package main
import (
"fmt"
"io"
"log"
"net/http"
)
func main() {
// API token — see Authorizations above.
token := "YOUR_SECRET_TOKEN"
url := "https://user-api.shardx.com/user/api/proxies/available-count"
req, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
out, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(resp.Status)
fmt.Println(string(out))
}// Cargo.toml: reqwest = { version = "0.12", features = ["json"] }, tokio = { version = "1", features = ["full"] }
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// API token — see Authorizations above.
let token = "YOUR_SECRET_TOKEN";
let client = reqwest::Client::new();
let response = client
.get("https://user-api.shardx.com/user/api/proxies/available-count")
.header("Authorization", format!("Bearer {token}"))
.send()
.await?;
println!("{}", response.status());
println!("{}", response.text().await?);
Ok(())
}using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
// API token — see Authorizations above.
var token = "YOUR_SECRET_TOKEN";
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var request = new HttpRequestMessage(HttpMethod.Get, "https://user-api.shardx.com/user/api/proxies/available-count");
var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}// build: c++ -std=c++17 main.cpp -lcurl
#include <curl/curl.h>
#include <iostream>
#include <string>
static size_t write_cb(char *ptr, size_t size, size_t nmemb, void *userdata) {
static_cast<std::string *>(userdata)->append(ptr, size * nmemb);
return size * nmemb;
}
int main() {
// API token — see Authorizations above.
const std::string token = "YOUR_SECRET_TOKEN";
curl_global_init(CURL_GLOBAL_DEFAULT);
CURL *curl = curl_easy_init();
if (!curl) {
std::cerr << "curl_easy_init failed\n";
curl_global_cleanup();
return 1;
}
struct curl_slist *headers = nullptr;
headers = curl_slist_append(headers, ("Authorization: Bearer " + token).c_str());
std::string response;
curl_easy_setopt(curl, CURLOPT_URL, "https://user-api.shardx.com/user/api/proxies/available-count");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
const CURLcode rc = curl_easy_perform(curl);
if (rc != CURLE_OK) {
std::cerr << curl_easy_strerror(rc) << "\n";
} else {
long status = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status);
std::cout << status << "\n" << response << "\n";
}
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
curl_global_cleanup();
return rc == CURLE_OK ? 0 : 1;
}[
{
"country": "text",
"product": "text",
"amount": 1
}
]{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}用户信息
https://user-api.shardx.com/user/api/meBearer authentication header of the form Bearer <token>.
200个人资料数据application/json
以美分为单位
401缺少 API 密钥或密钥无效:Missing or invalid Authorization header、Invalid API key、API key mismatchapplication/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
500内部错误。当订单(或所需的其他记录)不存在或不属于您的账户时,API 同样返回 500;具体原因见 message,例如 Order not found。application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
/user/api/meGET /user/api/me HTTP/1.1
Host: user-api.shardx.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*curl -X GET 'https://user-api.shardx.com/user/api/me' \
-H 'Authorization: Bearer YOUR_SECRET_TOKEN'import requests
# API token — see Authorizations above.
token = "YOUR_SECRET_TOKEN"
url = "https://user-api.shardx.com/user/api/me"
headers = {
"Authorization": f"Bearer {token}",
}
response = requests.get(url, headers=headers, timeout=30)
response.raise_for_status()
print(response.status_code)
print(response.text)// API token — see Authorizations above.
const token = "YOUR_SECRET_TOKEN";
const url = "https://user-api.shardx.com/user/api/me";
const response = await fetch(url, {
method: "GET",
headers: {
"Authorization": `Bearer ${token}`,
},
});
console.log(response.status);
console.log(await response.text());package main
import (
"fmt"
"io"
"log"
"net/http"
)
func main() {
// API token — see Authorizations above.
token := "YOUR_SECRET_TOKEN"
url := "https://user-api.shardx.com/user/api/me"
req, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
out, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(resp.Status)
fmt.Println(string(out))
}// Cargo.toml: reqwest = { version = "0.12", features = ["json"] }, tokio = { version = "1", features = ["full"] }
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// API token — see Authorizations above.
let token = "YOUR_SECRET_TOKEN";
let client = reqwest::Client::new();
let response = client
.get("https://user-api.shardx.com/user/api/me")
.header("Authorization", format!("Bearer {token}"))
.send()
.await?;
println!("{}", response.status());
println!("{}", response.text().await?);
Ok(())
}using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
// API token — see Authorizations above.
var token = "YOUR_SECRET_TOKEN";
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var request = new HttpRequestMessage(HttpMethod.Get, "https://user-api.shardx.com/user/api/me");
var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}// build: c++ -std=c++17 main.cpp -lcurl
#include <curl/curl.h>
#include <iostream>
#include <string>
static size_t write_cb(char *ptr, size_t size, size_t nmemb, void *userdata) {
static_cast<std::string *>(userdata)->append(ptr, size * nmemb);
return size * nmemb;
}
int main() {
// API token — see Authorizations above.
const std::string token = "YOUR_SECRET_TOKEN";
curl_global_init(CURL_GLOBAL_DEFAULT);
CURL *curl = curl_easy_init();
if (!curl) {
std::cerr << "curl_easy_init failed\n";
curl_global_cleanup();
return 1;
}
struct curl_slist *headers = nullptr;
headers = curl_slist_append(headers, ("Authorization: Bearer " + token).c_str());
std::string response;
curl_easy_setopt(curl, CURLOPT_URL, "https://user-api.shardx.com/user/api/me");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
const CURLcode rc = curl_easy_perform(curl);
if (rc != CURLE_OK) {
std::cerr << curl_easy_strerror(rc) << "\n";
} else {
long status = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status);
std::cout << status << "\n" << response << "\n";
}
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
curl_global_cleanup();
return rc == CURLE_OK ? 0 : 1;
}{
"email": "text",
"active_orders": 1,
"wallet_balance": 1
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}订单清单
https://user-api.shardx.com/user/api/ordersBearer authentication header of the form Bearer <token>.
活跃 |等待 |取消 |全部
选择偏移量(默认 0)
页面大小(1..100,默认 20)
200订单清单application/json
ordersobject[]requiredShow propertiesHide properties
ISO8601有效期
当前选择的订单数量
上一页 URI
下一页 URI
401缺少 API 密钥或密钥无效:Missing or invalid Authorization header、Invalid API key、API key mismatchapplication/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
500内部错误。当订单(或所需的其他记录)不存在或不属于您的账户时,API 同样返回 500;具体原因见 message,例如 Order not found。application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
/user/api/orders?status=textGET /user/api/orders?status=text HTTP/1.1
Host: user-api.shardx.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*curl -X GET 'https://user-api.shardx.com/user/api/orders?status=text' \
-H 'Authorization: Bearer YOUR_SECRET_TOKEN'import requests
# API token — see Authorizations above.
token = "YOUR_SECRET_TOKEN"
url = "https://user-api.shardx.com/user/api/orders"
params = {
"status": "text",
}
headers = {
"Authorization": f"Bearer {token}",
}
response = requests.get(url, params=params, headers=headers, timeout=30)
response.raise_for_status()
print(response.status_code)
print(response.text)// API token — see Authorizations above.
const token = "YOUR_SECRET_TOKEN";
const url = "https://user-api.shardx.com/user/api/orders?status=text";
const response = await fetch(url, {
method: "GET",
headers: {
"Authorization": `Bearer ${token}`,
},
});
console.log(response.status);
console.log(await response.text());package main
import (
"fmt"
"io"
"log"
"net/http"
)
func main() {
// API token — see Authorizations above.
token := "YOUR_SECRET_TOKEN"
url := "https://user-api.shardx.com/user/api/orders?status=text"
req, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
out, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(resp.Status)
fmt.Println(string(out))
}// Cargo.toml: reqwest = { version = "0.12", features = ["json"] }, tokio = { version = "1", features = ["full"] }
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// API token — see Authorizations above.
let token = "YOUR_SECRET_TOKEN";
let client = reqwest::Client::new();
let response = client
.get("https://user-api.shardx.com/user/api/orders?status=text")
.header("Authorization", format!("Bearer {token}"))
.send()
.await?;
println!("{}", response.status());
println!("{}", response.text().await?);
Ok(())
}using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
// API token — see Authorizations above.
var token = "YOUR_SECRET_TOKEN";
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var request = new HttpRequestMessage(HttpMethod.Get, "https://user-api.shardx.com/user/api/orders?status=text");
var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}// build: c++ -std=c++17 main.cpp -lcurl
#include <curl/curl.h>
#include <iostream>
#include <string>
static size_t write_cb(char *ptr, size_t size, size_t nmemb, void *userdata) {
static_cast<std::string *>(userdata)->append(ptr, size * nmemb);
return size * nmemb;
}
int main() {
// API token — see Authorizations above.
const std::string token = "YOUR_SECRET_TOKEN";
curl_global_init(CURL_GLOBAL_DEFAULT);
CURL *curl = curl_easy_init();
if (!curl) {
std::cerr << "curl_easy_init failed\n";
curl_global_cleanup();
return 1;
}
struct curl_slist *headers = nullptr;
headers = curl_slist_append(headers, ("Authorization: Bearer " + token).c_str());
std::string response;
curl_easy_setopt(curl, CURLOPT_URL, "https://user-api.shardx.com/user/api/orders?status=text");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
const CURLcode rc = curl_easy_perform(curl);
if (rc != CURLE_OK) {
std::cerr << curl_easy_strerror(rc) << "\n";
} else {
long status = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status);
std::cout << status << "\n" << response << "\n";
}
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
curl_global_cleanup();
return rc == CURLE_OK ? 0 : 1;
}{
"success": true,
"orders": [
{
"order_id": 1,
"product_id": 1,
"product_name": "text",
"cycle_id": 1,
"cycle_name": "text",
"expires_at": "text",
"auto_renewal": true,
"tag": "text"
}
],
"count": 1,
"prev": "text",
"next": "text"
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}获取订单信息
https://user-api.shardx.com/user/api/orders/{id}Bearer authentication header of the form Bearer <token>.
200订单信息application/json
orderobjectrequiredShow propertiesHide properties
基本订阅价格(以美分为单位)
总附加成本(以美分为单位)
addonsobject · AddonLine[]optional附加到此订单的附加行
Show propertiesHide properties
附加到此订单的附加行
当期活跃单位
购买时的单价(以美分为单位)
pendingobject· nullableoptional更改计划下次续订,或 null
Show propertiesHide properties
更改计划下次续订,或 null
canceldowngrade降级后目标数量
活跃的 p0f 签名槽(来自附加组件)
目前已被签名代理占用的槽位
下次续订后生效的槽位(不超过 renewal_quantity)
下一周期的代理数量(如有代理标记了 del-np,则少于 quantity)
下次续订将扣除的金额,以美分为单位(renewal_base_price + renewal_addons_price)
下次续订中代理部分的费用,以美分为单位(price_paid 的相应比例)
下次续订中组件部分的费用,以美分为单位(已计入计划中的更改)
401缺少 API 密钥或密钥无效:Missing or invalid Authorization header、Invalid API key、API key mismatchapplication/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
500内部错误。当订单(或所需的其他记录)不存在或不属于您的账户时,API 同样返回 500;具体原因见 message,例如 Order not found。application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
/user/api/orders/1GET /user/api/orders/1 HTTP/1.1
Host: user-api.shardx.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*curl -X GET 'https://user-api.shardx.com/user/api/orders/1' \
-H 'Authorization: Bearer YOUR_SECRET_TOKEN'import requests
# API token — see Authorizations above.
token = "YOUR_SECRET_TOKEN"
url = "https://user-api.shardx.com/user/api/orders/1"
headers = {
"Authorization": f"Bearer {token}",
}
response = requests.get(url, headers=headers, timeout=30)
response.raise_for_status()
print(response.status_code)
print(response.text)// API token — see Authorizations above.
const token = "YOUR_SECRET_TOKEN";
const url = "https://user-api.shardx.com/user/api/orders/1";
const response = await fetch(url, {
method: "GET",
headers: {
"Authorization": `Bearer ${token}`,
},
});
console.log(response.status);
console.log(await response.text());package main
import (
"fmt"
"io"
"log"
"net/http"
)
func main() {
// API token — see Authorizations above.
token := "YOUR_SECRET_TOKEN"
url := "https://user-api.shardx.com/user/api/orders/1"
req, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
out, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(resp.Status)
fmt.Println(string(out))
}// Cargo.toml: reqwest = { version = "0.12", features = ["json"] }, tokio = { version = "1", features = ["full"] }
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// API token — see Authorizations above.
let token = "YOUR_SECRET_TOKEN";
let client = reqwest::Client::new();
let response = client
.get("https://user-api.shardx.com/user/api/orders/1")
.header("Authorization", format!("Bearer {token}"))
.send()
.await?;
println!("{}", response.status());
println!("{}", response.text().await?);
Ok(())
}using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
// API token — see Authorizations above.
var token = "YOUR_SECRET_TOKEN";
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var request = new HttpRequestMessage(HttpMethod.Get, "https://user-api.shardx.com/user/api/orders/1");
var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}// build: c++ -std=c++17 main.cpp -lcurl
#include <curl/curl.h>
#include <iostream>
#include <string>
static size_t write_cb(char *ptr, size_t size, size_t nmemb, void *userdata) {
static_cast<std::string *>(userdata)->append(ptr, size * nmemb);
return size * nmemb;
}
int main() {
// API token — see Authorizations above.
const std::string token = "YOUR_SECRET_TOKEN";
curl_global_init(CURL_GLOBAL_DEFAULT);
CURL *curl = curl_easy_init();
if (!curl) {
std::cerr << "curl_easy_init failed\n";
curl_global_cleanup();
return 1;
}
struct curl_slist *headers = nullptr;
headers = curl_slist_append(headers, ("Authorization: Bearer " + token).c_str());
std::string response;
curl_easy_setopt(curl, CURLOPT_URL, "https://user-api.shardx.com/user/api/orders/1");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
const CURLcode rc = curl_easy_perform(curl);
if (rc != CURLE_OK) {
std::cerr << curl_easy_strerror(rc) << "\n";
} else {
long status = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status);
std::cout << status << "\n" << response << "\n";
}
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
curl_global_cleanup();
return rc == CURLE_OK ? 0 : 1;
}{
"success": true,
"order": {
"order_id": 1,
"product_name": "text",
"cycle_name": "text",
"quantity": 1,
"price_paid": 1,
"addons_price_paid": 1,
"addons": [
{
"addon_key": "text",
"catalog_id": 1,
"qty": 1,
"price_per_unit": 1,
"pending": {
"action": "cancel",
"next_qty": 1
}
}
],
"p0f_slots_available": 1,
"p0f_slots_used": 1,
"p0f_slots_next": 1,
"renewal_quantity": 1,
"renewal_price": 1,
"renewal_base_price": 1,
"renewal_addons_price": 1,
"status": "text",
"created_at": "text",
"expires_at": "text",
"promo_code": "text",
"auto_renewal": true,
"tag": "text"
}
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}续订订单
https://user-api.shardx.com/user/api/orders/{id}/renew仅当订单状态为 on-hold 时才可以续订。
对已续订的订单重复请求时返回 200 和 Order already renewed。
请发送 Idempotency-Key 标头,确保重试安全(会扣款)。
Bearer authentication header of the form Bearer <token>.
可选。逻辑操作的唯一标识符(1–128 个 [A-Za-z0-9_.:-] 字符),例如 UUID。
重试结果未知的请求(超时、连接中断)时,请发送相同的键:已完成的请求不会再次执行,而是返回其原始响应。
本 API 的所有修改类端点(POST/PUT/PATCH/DELETE)都接受此标头:购买、续订、追加流量、组件以及今后新增的端点;涉及扣款的端点会明确列出。
除子用户操作外的所有端点:保存的响应会在 7 天内带 `Idempotency-Replayed: true` 标头重放。`409`:使用此键的请求仍在执行(`idempotency_state: in_progress`),或未完成且需要人工核实结果(`idempotency_state: unknown`;不会再次执行)。`422`:该键已用于另一个请求。限流返回的 `429` 不会消耗该键,请使用同一个键重试。
子用户端点(创建、data/add、data/subtract):该键会转发给代理提供商,24 小时内重试不会两次修改配额。409:操作仍在进行,或该键已用于不同的数据。
不带此标头时,请求照常执行,但没有上述保障。
200成功的application/json
400余额不足/验证错误application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
401缺少 API 密钥或密钥无效:Missing or invalid Authorization header、Invalid API key、API key mismatchapplication/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
409订单已支付当前周期、续订过程中订单发生了变化(请重试),或使用此 Idempotency-Key 的请求仍在执行application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
422该 Idempotency-Key 已用于另一个请求application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
500内部错误。当订单(或所需的其他记录)不存在或不属于您的账户时,API 同样返回 500;具体原因见 message,例如 Order not found。application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
/user/api/orders/1/renewPOST /user/api/orders/1/renew HTTP/1.1
Host: user-api.shardx.com
Authorization: Bearer YOUR_SECRET_TOKEN
Idempotency-Key: text
Accept: */*curl -X POST 'https://user-api.shardx.com/user/api/orders/1/renew' \
-H 'Authorization: Bearer YOUR_SECRET_TOKEN' \
-H 'Idempotency-Key: text'import requests
# API token — see Authorizations above.
token = "YOUR_SECRET_TOKEN"
url = "https://user-api.shardx.com/user/api/orders/1/renew"
headers = {
"Authorization": f"Bearer {token}",
"Idempotency-Key": "text",
}
response = requests.post(url, headers=headers, timeout=30)
response.raise_for_status()
print(response.status_code)
print(response.text)// API token — see Authorizations above.
const token = "YOUR_SECRET_TOKEN";
const url = "https://user-api.shardx.com/user/api/orders/1/renew";
const response = await fetch(url, {
method: "POST",
headers: {
"Authorization": `Bearer ${token}`,
"Idempotency-Key": "text",
},
});
console.log(response.status);
console.log(await response.text());package main
import (
"fmt"
"io"
"log"
"net/http"
)
func main() {
// API token — see Authorizations above.
token := "YOUR_SECRET_TOKEN"
url := "https://user-api.shardx.com/user/api/orders/1/renew"
req, err := http.NewRequest("POST", url, nil)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+token)
req.Header.Set("Idempotency-Key", "text")
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
out, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(resp.Status)
fmt.Println(string(out))
}// Cargo.toml: reqwest = { version = "0.12", features = ["json"] }, tokio = { version = "1", features = ["full"] }
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// API token — see Authorizations above.
let token = "YOUR_SECRET_TOKEN";
let client = reqwest::Client::new();
let response = client
.post("https://user-api.shardx.com/user/api/orders/1/renew")
.header("Authorization", format!("Bearer {token}"))
.header("Idempotency-Key", "text")
.send()
.await?;
println!("{}", response.status());
println!("{}", response.text().await?);
Ok(())
}using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
// API token — see Authorizations above.
var token = "YOUR_SECRET_TOKEN";
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var request = new HttpRequestMessage(HttpMethod.Post, "https://user-api.shardx.com/user/api/orders/1/renew");
request.Headers.Add("Idempotency-Key", "text");
var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}// build: c++ -std=c++17 main.cpp -lcurl
#include <curl/curl.h>
#include <iostream>
#include <string>
static size_t write_cb(char *ptr, size_t size, size_t nmemb, void *userdata) {
static_cast<std::string *>(userdata)->append(ptr, size * nmemb);
return size * nmemb;
}
int main() {
// API token — see Authorizations above.
const std::string token = "YOUR_SECRET_TOKEN";
curl_global_init(CURL_GLOBAL_DEFAULT);
CURL *curl = curl_easy_init();
if (!curl) {
std::cerr << "curl_easy_init failed\n";
curl_global_cleanup();
return 1;
}
struct curl_slist *headers = nullptr;
headers = curl_slist_append(headers, ("Authorization: Bearer " + token).c_str());
headers = curl_slist_append(headers, "Idempotency-Key: text");
std::string response;
curl_easy_setopt(curl, CURLOPT_URL, "https://user-api.shardx.com/user/api/orders/1/renew");
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
const CURLcode rc = curl_easy_perform(curl);
if (rc != CURLE_OK) {
std::cerr << curl_easy_strerror(rc) << "\n";
} else {
long status = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status);
std::cout << status << "\n" << response << "\n";
}
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
curl_global_cleanup();
return rc == CURLE_OK ? 0 : 1;
}{
"success": true,
"message": "Order renewed successfully"
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}更改订单标签
https://user-api.shardx.com/user/api/orders/{id}/tagBearer authentication header of the form Bearer <token>.
200成功的application/json
401缺少 API 密钥或密钥无效:Missing or invalid Authorization header、Invalid API key、API key mismatchapplication/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
500内部错误。当订单(或所需的其他记录)不存在或不属于您的账户时,API 同样返回 500;具体原因见 message,例如 Order not found。application/json
子用户操作:提供商拒绝了该操作且未发生任何更改时为 true
仅出现在 Idempotency-Key 校验返回的 409 中
in_progressunknown仅出现在购买和 add-bandwidth 返回的 502 中:已付款的订单
仅出现在购买和 add-bandwidth 返回的 502 中:true 表示款项已退回钱包,false 表示退款尚未完成,请联系支持
/user/api/orders/1/tagPOST /user/api/orders/1/tag HTTP/1.1
Host: user-api.shardx.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
{
"tag": "text"
}curl -X POST 'https://user-api.shardx.com/user/api/orders/1/tag' \
-H 'Authorization: Bearer YOUR_SECRET_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"tag":"text"}'import requests
# API token — see Authorizations above.
token = "YOUR_SECRET_TOKEN"
url = "https://user-api.shardx.com/user/api/orders/1/tag"
headers = {
"Authorization": f"Bearer {token}",
}
payload = {
"tag": "text",
}
response = requests.post(url, headers=headers, json=payload, timeout=30)
response.raise_for_status()
print(response.status_code)
print(response.text)// API token — see Authorizations above.
const token = "YOUR_SECRET_TOKEN";
const url = "https://user-api.shardx.com/user/api/orders/1/tag";
const payload = {
"tag": "text"
};
const response = await fetch(url, {
method: "POST",
headers: {
"Authorization": `Bearer ${token}`,
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});
console.log(response.status);
console.log(await response.text());package main
import (
"bytes"
"fmt"
"io"
"log"
"net/http"
)
func main() {
// API token — see Authorizations above.
token := "YOUR_SECRET_TOKEN"
url := "https://user-api.shardx.com/user/api/orders/1/tag"
body := bytes.NewBufferString(`{
"tag": "text"
}`)
req, err := http.NewRequest("POST", url, body)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+token)
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
out, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(resp.Status)
fmt.Println(string(out))
}// Cargo.toml: reqwest = { version = "0.12", features = ["json"] }, tokio = { version = "1", features = ["full"] }, serde_json = "1"
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// API token — see Authorizations above.
let token = "YOUR_SECRET_TOKEN";
let client = reqwest::Client::new();
let response = client
.post("https://user-api.shardx.com/user/api/orders/1/tag")
.header("Authorization", format!("Bearer {token}"))
.json(&serde_json::json!({
"tag": "text"
}))
.send()
.await?;
println!("{}", response.status());
println!("{}", response.text().await?);
Ok(())
}using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
// API token — see Authorizations above.
var token = "YOUR_SECRET_TOKEN";
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var request = new HttpRequestMessage(HttpMethod.Post, "https://user-api.shardx.com/user/api/orders/1/tag");
request.Content = new StringContent("""
{
"tag": "text"
}
""", Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}// build: c++ -std=c++17 main.cpp -lcurl
#include <curl/curl.h>
#include <iostream>
#include <string>
static size_t write_cb(char *ptr, size_t size, size_t nmemb, void *userdata) {
static_cast<std::string *>(userdata)->append(ptr, size * nmemb);
return size * nmemb;
}
int main() {
// API token — see Authorizations above.
const std::string token = "YOUR_SECRET_TOKEN";
curl_global_init(CURL_GLOBAL_DEFAULT);
CURL *curl = curl_easy_init();
if (!curl) {
std::cerr << "curl_easy_init failed\n";
curl_global_cleanup();
return 1;
}
struct curl_slist *headers = nullptr;
headers = curl_slist_append(headers, ("Authorization: Bearer " + token).c_str());
headers = curl_slist_append(headers, "Content-Type: application/json");
const std::string body = R"json({
"tag": "text"
})json";
std::string response;
curl_easy_setopt(curl, CURLOPT_URL, "https://user-api.shardx.com/user/api/orders/1/tag");
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str());
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, static_cast<long>(body.size()));
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
const CURLcode rc = curl_easy_perform(curl);
if (rc != CURLE_OK) {
std::cerr << curl_easy_strerror(rc) << "\n";
} else {
long status = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status);
std::cout << status << "\n" << response << "\n";
}
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
curl_global_cleanup();
return rc == CURLE_OK ? 0 : 1;
}{
"success": true,
"message": "Order tag updated"
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}{
"success": true,
"message": "text",
"rejected": true,
"idempotency_state": "in_progress",
"order_id": 1,
"refunded": true
}最后更新