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,
"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,
"hasMarketMakerAccess": true,
"auth": "<string>",
"email": "[email protected]",
"passwordSecurityChecks": {}
}
}
}{
"error": "<string>"
}Primeiros passos
Autenticação
Faça login e autorize requisições
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,
"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,
"hasMarketMakerAccess": true,
"auth": "<string>",
"email": "[email protected]",
"passwordSecurityChecks": {}
}
}
}{
"error": "<string>"
}Sem chaves de API. A 4casters ainda não emite chaves de API. Faça login com o nome de usuário e a senha da sua conta, exatamente como faria no site, e use o token retornado. Consulte a visão geral de autenticação para ver como o token é usado nas três APIs e como lidar com seu tempo de vida de 30 dias.
Entrar
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"
}
Requisição
Resposta
O token é retornado tanto emdata.user.auth quanto em um cookie auth assinado (Set-Cookie). Na maioria das integrações de servidor você vai querer capturar data.user.auth e descartar o 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 no esquema OpenAPI para todos os campos.
Respostas de erro
| Status | Significado |
|---|---|
400 | username e password são obrigatórios. |
401 | O nome de usuário ou a senha está incorreto. |
403 | Conta banida, bloqueada ou encerrada. |
429 | Limite de taxa de login excedido. |
Autorizar requisições
Passe o token dedata.user.auth em cada requisição seguinte. Três formatos de cabeçalho / payload são aceitos, nesta ordem de preferência:
- Cabeçalho Authorization (recomendado)
- Cookie
- Campo do corpo (somente POST)
curl https://api.4casters.io/user/getMe \
-H "Authorization: Bearer 5cd551d6..."
Bearer é opcional: você também pode enviar o token sem prefixo.O cookie
auth assinado que /user/login define é honrado automaticamente em cada endpoint quando reutilizado no mesmo cliente.{ "token": "5cd551d6...", "...": "..." }
401 InvalidCredentials.
Rotação de token
As requisições autenticadas com tokens de mais de 30 dias rotacionam automaticamente para um token novo. Quando isso ocorre, o token novo é retornado no cabeçalho de respostaX-Auth-Token (e como cookie auth assinado atualizado). O token antigo para de funcionar imediatamente; a requisição que provocou a rotação ainda tem sucesso, mas cada requisição seguinte com o valor antigo retorna 401. As integrações de longa duração devem ficar atentas a esse cabeçalho e persistir o valor novo, ou simplesmente fazer login novamente em qualquer 401.
Sair
POST /user/logout invalida o token usado para fazer a chamada. As requisições seguintes com esse token retornam 401; os demais tokens da mesma conta não são afetados.
Autenticação de dois fatores
A autenticação de dois fatores protege os saques, não o login.POST /user/login nunca exige um código, seja qual for a configuração de 2FA da conta.Esta página foi útil?