Log in
curl --request POST \
--url https://api.4casters.io/user/login \
--header 'Content-Type: application/json' \
--data '
{
"username": "your_username",
"password": "your_password"
}
'import requests
url = "https://api.4casters.io/user/login"
payload = {
"username": "your_username",
"password": "your_password"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({username: 'your_username', password: 'your_password'})
};
fetch('https://api.4casters.io/user/login', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.4casters.io/user/login",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'username' => 'your_username',
'password' => 'your_password'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.4casters.io/user/login"
payload := strings.NewReader("{\n \"username\": \"your_username\",\n \"password\": \"your_password\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.4casters.io/user/login")
.header("Content-Type", "application/json")
.body("{\n \"username\": \"your_username\",\n \"password\": \"your_password\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.4casters.io/user/login")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"username\": \"your_username\",\n \"password\": \"your_password\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"user": {
"id": "<string>",
"username": "<string>",
"type": "free",
"oddsFormat": "american",
"displayBalance": 123,
"creditLimit": 123,
"liability": 123,
"commissionCharged": 123,
"maxLiability": 123,
"matchedVolume": {},
"openInterest": {},
"isAdmin": true,
"hasMarketMakerAccess": true,
"isPro": true,
"isDeposit": true,
"isAlphaUser": true,
"sportsbookDefault": true,
"defaultRotationNumbers": true,
"displayRotationNumbers": true,
"viewOddsWithCommission": true,
"defaultExpiry": 123,
"defaultOffer": 123,
"defaultSendOrderMessage": true,
"sportsbookMinimumDisplay": 123,
"showChatLastMessage": true,
"yesNoSummary": true,
"accessCode": "<string>",
"code": "<string>",
"p2pCode": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"emailConfirmation": true,
"auth": "<string>",
"email": "[email protected]",
"passwordSecurityChecks": {}
}
}
}{
"error": "<string>"
}入門
認證
登入併為請求授權
POST
/
user
/
login
Log in
curl --request POST \
--url https://api.4casters.io/user/login \
--header 'Content-Type: application/json' \
--data '
{
"username": "your_username",
"password": "your_password"
}
'import requests
url = "https://api.4casters.io/user/login"
payload = {
"username": "your_username",
"password": "your_password"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({username: 'your_username', password: 'your_password'})
};
fetch('https://api.4casters.io/user/login', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.4casters.io/user/login",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'username' => 'your_username',
'password' => 'your_password'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.4casters.io/user/login"
payload := strings.NewReader("{\n \"username\": \"your_username\",\n \"password\": \"your_password\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.4casters.io/user/login")
.header("Content-Type", "application/json")
.body("{\n \"username\": \"your_username\",\n \"password\": \"your_password\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.4casters.io/user/login")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"username\": \"your_username\",\n \"password\": \"your_password\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"user": {
"id": "<string>",
"username": "<string>",
"type": "free",
"oddsFormat": "american",
"displayBalance": 123,
"creditLimit": 123,
"liability": 123,
"commissionCharged": 123,
"maxLiability": 123,
"matchedVolume": {},
"openInterest": {},
"isAdmin": true,
"hasMarketMakerAccess": true,
"isPro": true,
"isDeposit": true,
"isAlphaUser": true,
"sportsbookDefault": true,
"defaultRotationNumbers": true,
"displayRotationNumbers": true,
"viewOddsWithCommission": true,
"defaultExpiry": 123,
"defaultOffer": 123,
"defaultSendOrderMessage": true,
"sportsbookMinimumDisplay": 123,
"showChatLastMessage": true,
"yesNoSummary": true,
"accessCode": "<string>",
"code": "<string>",
"p2pCode": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"emailConfirmation": true,
"auth": "<string>",
"email": "[email protected]",
"passwordSecurityChecks": {}
}
}
}{
"error": "<string>"
}**沒有 API 金鑰。**4casters 目前還不發放 API 金鑰。使用你帳戶的使用者名稱和密碼登入,就像在網站上一樣,然後使用回傳的令牌。令牌如何在三套 API 中使用、以及如何處理它 30 天的有效期,見 認證概述。
登入
POST /user/login
curl -X POST https://api.4casters.io/user/login \
-H "Content-Type: application/json" \
-d '{"username": "your_username", "password": "your_password"}'
{
"username": "your_username",
"password": "your_password"
}
請求
string
必填
帳戶使用者名稱(或電子郵件)。
string
必填
帳戶密碼。
回應
令牌會同時作為data.user.auth 以及簽名 auth Cookie(Set-Cookie)回傳。對於大多數伺服器端整合,你應捕獲 data.user.auth 並丟棄 Cookie。
{
"data": {
"user": {
"id": "5fe37acbb5a23600123662c1",
"username": "your_username",
"auth": "5cd551d6...",
"type": "p2p",
"oddsFormat": "american",
"displayBalance": 1250.50,
"creditLimit": 500,
"liability": -125.00,
"commissionCharged": 0.01,
"hasMarketMakerAccess": false,
"isPro": false,
"createdAt": "2020-12-23T17:14:09.000Z"
}
}
}
User。
錯誤回應
| 狀態 | 含義 |
|---|---|
400 | username 和 password 為必填。 |
401 | 使用者名稱或密碼不正確。 |
403 | 帳戶被封禁、鎖定或已關閉。 |
429 | 超出登入速率限制。 |
為請求授權
在後續每個請求中傳遞來自data.user.auth 的令牌。按以下優先順序接受三種請求標頭 / 酬載格式:
- Authorization 請求標頭(推薦)
- Cookie
- 請求主體欄位(僅 POST)
curl https://api.4casters.io/user/getMe \
-H "Authorization: Bearer 5cd551d6..."
Bearer 前綴是可選的 — 直接傳遞裸令牌也可以。/user/login 設定的簽名 auth Cookie 在同一用戶端重複使用時,會在每個端點上自動生效。{ "token": "5cd551d6...", "...": "..." }
401 InvalidCredentials。
令牌輪換
使用超過 30 天的令牌發起的已認證請求會自動輪換為新令牌。發生時,新令牌會在X-Auth-Token 回應標頭中回傳(並作為更新後的簽名 auth Cookie)。舊令牌立即失效;觸發輪換的那次請求仍會成功,但之後任何使用舊值的請求都會回傳 401。長期執行的整合應監聽此回應標頭並持久化新值,或者乾脆在遇到任何 401 時重新登入。
登出
POST /user/logout 會使發起該呼叫所用的令牌失效。之後使用該令牌的請求回傳 401;同一帳戶持有的其他令牌不受影響。
雙重認證
雙重認證保護的是提款,而不是登入。無論帳戶的 2FA 設定如何,POST /user/login 都不會要求驗證碼。這個頁面有幫助嗎?