Token
由 Taurusx 获取 API KEY
后,您可以根据规则生成 Token 参数,再调用 Open API 接口时需要带上 Token 参数.
txt
示例:假设请求的url为"https://scaler.taurusx.com/openapi/performance_data", 那么请求的Header需要加上
access-key: 018168163a17d44907669d58ee9ad687
token: a6864d4ef31b09cdc1c5d22214cde5db
timestamp: 1697785289
示例:假设请求的url为"https://scaler.taurusx.com/openapi/performance_data", 那么请求的Header需要加上
access-key: 018168163a17d44907669d58ee9ad687
token: a6864d4ef31b09cdc1c5d22214cde5db
timestamp: 1697785289
Token 参数生成规则如下:
字段 | 类型 | 说明 | 举例 |
---|---|---|---|
access-key | string | 由 Taurusx 生成 access-key 和 api-key | "018168163a17d44907669d58ee9ad687" |
token | string | 生成方法:Md5(api-key.md5(timestamp)) | "a6864d4ef31b09cdc1c5d22214cde5db" |
timestamp | int | 时间戳(秒) | 1697785289 |
示例
Python 实例
Python
import time
import hashlib
api_key = "af6d4b1cbdb4fbe2d1ee838fabfe92fe"
timestamp = str(int(time.time()))
token = hashlib.md5((api_key + hashlib.md5(timestamp.encode()).hexdigest()).encode()).hexdigest()
print(token)
import time
import hashlib
api_key = "af6d4b1cbdb4fbe2d1ee838fabfe92fe"
timestamp = str(int(time.time()))
token = hashlib.md5((api_key + hashlib.md5(timestamp.encode()).hexdigest()).encode()).hexdigest()
print(token)
Go 实例
Go
package main
import (
"crypto/md5"
"encoding/hex"
"fmt"
"time"
)
func md5Hash(s string) string {
hash := md5.Sum([]byte(s))
return hex.EncodeToString(hash[:])
}
func main() {
apiKey := "af6d4b1cbdb4fbe2d1ee838fabfe92fe"
timestamp := fmt.Sprintf("%d", time.Now().Unix())
token := md5Hash(apiKey + md5Hash(timestamp))
fmt.Println(token)
}
package main
import (
"crypto/md5"
"encoding/hex"
"fmt"
"time"
)
func md5Hash(s string) string {
hash := md5.Sum([]byte(s))
return hex.EncodeToString(hash[:])
}
func main() {
apiKey := "af6d4b1cbdb4fbe2d1ee838fabfe92fe"
timestamp := fmt.Sprintf("%d", time.Now().Unix())
token := md5Hash(apiKey + md5Hash(timestamp))
fmt.Println(token)
}
PHP 实例
PowerShell
<?php
$api_key = 'af6d4b1cbdb4fbe2d1ee838fabfe92fe';
$timestamp = time();
$token = md5($api_key.md5($timestamp));
?>
<?php
$api_key = 'af6d4b1cbdb4fbe2d1ee838fabfe92fe';
$timestamp = time();
$token = md5($api_key.md5($timestamp));
?>