Данные пользователя
GET /api/v1/user возвращает данные владельца API-ключа из учётной записи: контакты, балансы, дату регистрации и время последнего входа.
Пример запроса
SDK OpenAI
Python
cURL
PHP
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://ai.mitup.ru/api/v1",
)
user = client.get("/user", cast_to=object)
print(user)import requests
url = "https://ai.mitup.ru/api/v1/user"
api_key = "YOUR_API_KEY"
headers = {
"Authorization": f"Bearer {api_key}"
}
response = requests.get(url, headers=headers)
print(response.json())curl -X GET "https://ai.mitup.ru/api/v1/user" \
-H "Authorization: Bearer YOUR_API_KEY"<?php
$url = "https://ai.mitup.ru/api/v1/user";
$api_key = "YOUR_API_KEY";
$headers = [
"Authorization: Bearer " . $api_key,
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "mitupai-API-client");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$response = curl_exec($ch);
curl_close($ch);
$response = json_decode($response, true);
print_r($response);
?>Пример возвращаемого результата:
Успех (200)
Ошибка (4хх, 5xx)
{
"id": 123,
"object": "user",
"email": "user@example.com",
"phone": "+79990001122",
"name": "Иван",
"balance": 150.5,
"balance_referral": 0.0,
"balance_bonus": 10.0,
"balance_tariff": 0.0,
"date_register": "2024-05-01 12:00:00+00:00",
"last_auth": "2024-05-02 09:15:00+00:00"
}{
"error": {
"message": "The server had an error while processing your request. Cause: Issue on our servers. Solution: Retry your request after a brief wait and contact us if the issue persists.",
"type": "server_error",
"param": null,
"code": "server_error"
}
}