Информация об учётной записи

Возвращает информацию об аккаунте, включая баланс кредитов

POST https://pixflow.ru/api/v1/account/info

HEADER Authorization: Bearer {ваш токен}

Ответы
Код Ответ
200

{
  "type": "success",
  "credits": 100,
}
200

{
    "type":"error",
    "errors":[
        "Неизвестная ошибка"
    ]
}

//Ссылка
$api_url = 'https://pixflow.ru/api/v1/account/info';

//Токен авторизации из личного кабинета: https://pixflow.ru/user/api
$api_token = "jgcJkV7fSV2KzHyzmdIV4pS5VHshgbsOsRg26wQRd5AxRGIpJF";

//Заголовки
$headers = [
    'Authorization: Bearer '.$api_token
];

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $api_url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$response   = curl_exec($curl);
$http_code  = curl_getinfo($curl, CURLINFO_HTTP_CODE);

curl_close($curl);

if($http_code !== 200)
    exit('['.$http_code.'] Ошибка запроса');

if(!$json = json_decode($response))
    exit('Ошибка декодирования данных');

if($json->type == 'error'){

    foreach($json->errors as $error)
        echo $error.PHP_EOL;

    exit;

}

echo 'Баланс кредитов: '.$json->credits.PHP_EOL;


import requests
import json
import sys

# Ссылка
api_url = "https://pixflow.ru/api/v1/account/info"

# Токен авторизации из личного кабинета: https://pixflow.ru/user/api
api_token = "jgcJkV7fSV2KzHyzmdIV4pS5VHshgbsOsRg26wQRd5AxRGIpJF"

# Заголовки запроса
headers = {
    "Authorization": f"Bearer {api_token}",
}

# Отправляем запрос
try:
    response = requests.post(api_url, headers=headers)
    http_code = response.status_code
    resp_text = response.text
except Exception as e:
    print("Ошибка при выполнении запроса: ", e)
    sys.exit()

if http_code != 200:
    print(f"[{http_code}] Ошибка запроса")
    sys.exit()

try:
    json_resp = response.json()
except json.JSONDecodeError:
    print("Ошибка декодирования ответа")
    sys.exit()

if json_resp.get("type") == "error":
    for err in json_resp.get("errors", []):
        print(err)
    sys.exit()

my_credits = json_resp.get("credits")
print(f"Баланс кредитов: {my_credits}")


const axios = require("axios");

//Ссылка
const api_url = "https://pixflow.ru/api/v1/account/info";

//Токен авторизации из личного кабинета: https://pixflow.ru/user/api
const api_token = "jgcJkV7fSV2KzHyzmdIV4pS5VHshgbsOsRg26wQRd5AxRGIpJF";

(async() => {

	try{

		const response = await axios.post(api_url, {}, {
			headers: {
				Authorization: `Bearer ${api_token}`,
			},
		});

		if(response.data.type === "error") {
			console.error("Ошибка:");
        	response.data.errors.forEach(err => console.error(" -", err));
			return;
		}

		const credits = response.data.credits;
		console.log(`Баланс кредитов: ${credits}`);

	} catch(err){

		if(err.response){
			console.error("[" + err.response.status + "] Ошибка запроса");
		} else {
			console.error("Ошибка: ", err.message);
		}

	}

})();


#Информация об учётной записи
curl -k -X POST 'https://pixflow.ru/api/v1/account/info' \
-H 'Authorization: Bearer jgcJkV7fSV2KzHyzmdIV4pS5VHshgbsOsRg26wQRd5AxRGIpJF'

Наверх