Account Info
The GET /account/info and POST /account/info endpoints return
comprehensive account details and real-time usage statistics for your BBRE (Browser-Backed
Request Engine) account. Unlike the simpler balance endpoint that only returns your current
credit, the account info endpoint provides a complete picture of your account state,
including your username, email address, account status, current balance, account creation
date, and a full set of usage statistics covering total requests, daily request counts,
completed and failed request breakdowns, success rate percentages, and active session
counts. All statistics are calculated in real time at the moment of the request, so the
values you receive always reflect the most current state of your account. This makes the
account info endpoint the single most useful endpoint for building monitoring dashboards,
generating usage reports, tracking API consumption patterns, and diagnosing performance
issues. The endpoint requires no request body parameters and supports both GET and POST
HTTP methods, returning identical responses regardless of which method you use. Whether
you are building an internal admin panel that displays account health metrics, implementing
automated alerting based on success rate drops, or simply want to verify your account
configuration, this endpoint provides all the data you need in a single API call. This
page covers the endpoint definition, authentication requirements, response format with
detailed field descriptions for both the account object and the statistics object, working
code examples in JavaScript, Python, and cURL, statistics interpretation guidance,
dashboard integration patterns, SDK usage, error handling, and best practices for
effective account monitoring in production systems.
The account info endpoint combines two types of data in a single response: static account
details (username, email, status, creation date) and dynamic usage statistics (request
counts, success rates, active sessions). The static fields change only when you update
your account settings, while the statistics are recalculated on every request. The
todayRequests counter resets at midnight UTC each day. The
activeSessions count reflects only sessions that are currently active and
have not expired, so this number decreases automatically as sessions reach their
expiration time. Both GET and POST methods are supported and return identical responses.
No request body or query parameters are needed.
Endpoint
The account info endpoint supports both GET and POST HTTP methods. Both methods behave identically and return the same response structure containing your account details and usage statistics. This dual-method support exists for convenience: some HTTP client libraries, proxy configurations, and corporate firewalls handle GET and POST requests differently, so supporting both methods ensures you can always retrieve your account information regardless of your infrastructure constraints. The endpoint performs a database lookup for your account details and then calculates usage statistics by querying your request and session records in real time.
Authentication
All requests to the BBRE API require authentication via an API key. You must include your
API key in the HTTP headers of every request, including account info queries. The API
accepts the key through either the x-api-key header or the apikey
header. Both header names are supported and functionally identical. The API key is used to
identify your account and retrieve the corresponding account details and statistics. If no
API key is provided, the API returns a 401 error with the
API_KEY_REQUIRED error code. If the provided key is invalid or belongs to a
suspended or inactive account, the API returns a 403 error with the
appropriate error code (INVALID_API_KEY, ACCOUNT_SUSPENDED, or
ACCOUNT_INACTIVE).
| Header | Type | Required | Description |
|---|---|---|---|
x-api-key |
string | required | Your BBRE API key. You can find this in your MyDisct Solver dashboard. |
The account info endpoint does not require a Content-Type header when using
the GET method because there is no request body. If you use the POST method, you can
optionally include Content-Type: application/json but it is not required
since the endpoint ignores the request body entirely. The API key alone is sufficient
to identify your account and return all associated information.
Request Parameters
The account info endpoint does not accept any request parameters. There is no request body, no query parameters, and no URL parameters. The only requirement is a valid API key in the request headers. This makes the account info endpoint straightforward to integrate into any application. When using the GET method, simply send a GET request with your API key header. When using the POST method, you can send an empty body or no body at all. The endpoint identifies your account entirely through the API key and returns the full account details and statistics associated with that account.
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters required. The endpoint uses your API key to identify your account. | |||
Response Format
The account info endpoint returns a JSON response containing two main objects: the
account object with your account details and the statistics
object with your real-time usage metrics. On success, the response includes the standard
BBRE success fields plus these two nested objects. The statistics are calculated at the
moment of the request by querying your task and session records, so the values always
reflect the current state of your account.
Success Response (200)
A successful account info query returns the following structure. The account
object contains your profile information and current balance. The statistics
object contains computed usage metrics based on your request history and active sessions.
The service field always contains "MyDisct Solver BBRE" to
identify which service processed the request.
{
"success": true,
"service": "MyDisct Solver BBRE",
"account": {
"username": "john_doe",
"email": "[email protected]",
"status": "active",
"balance": 125.50,
"createdAt": "2024-01-15T10:30:00.000Z"
},
"statistics": {
"totalRequests": 15420,
"todayRequests": 342,
"completedRequests": 14890,
"failedRequests": 530,
"successRate": 96.56,
"activeSessions": 3
}
}
Account Object Fields
The account object contains your core account information. These fields
represent the current state of your account profile and are updated only when you modify
your account settings through the MyDisct Solver dashboard.
| Field | Type | Description |
|---|---|---|
username |
string | Your account username as registered in the MyDisct Solver system. This is the display name associated with your account. |
email |
string | The email address associated with your account. This is the email you used during registration and is used for account notifications and recovery. |
status |
string | Your current account status. Possible values are "active", "inactive", and "suspended". Only active accounts can make API requests that incur charges. |
balance |
number | Your current account balance as a floating-point number in USD. This is the same value returned by the /account/balance endpoint and reflects all charges processed up to the moment of the request. |
createdAt |
string | The ISO 8601 timestamp of when your account was created. This value never changes and represents the exact moment your account was registered in the system. |
Statistics Object Fields
The statistics object contains real-time usage metrics calculated at the
moment of the request. These values are not cached or pre-computed; they are derived
from your actual request and session records every time you call the endpoint. This
ensures you always receive the most accurate and up-to-date statistics.
| Field | Type | Description |
|---|---|---|
totalRequests |
number | The total number of BBRE tasks ever created for your account. This includes all requests regardless of their current status (processing, completed, failed, or timed out). This counter only increases over time. |
todayRequests |
number | The number of BBRE tasks created today, counted from midnight UTC. This counter resets to zero at the start of each new UTC day. Use this to track your daily consumption rate. |
completedRequests |
number | The total number of BBRE tasks that completed successfully with a "completed" status. This represents all requests that returned a valid response from the target server. |
failedRequests |
number | The total number of BBRE tasks that ended with a "failed" status. Failed requests include timeouts, target server errors, blocked requests, and other failure scenarios. |
successRate |
number | The percentage of completed requests out of total requests, calculated as (completedRequests / totalRequests * 100) and rounded to two decimal places. Returns 0 if no requests have been made. A healthy account typically has a success rate above 90%. |
activeSessions |
number | The number of currently active sessions. A session is counted as active only if its status is "active" and its expiration time has not passed. Sessions that have expired or been closed are not included in this count. The maximum allowed active sessions is 10. |
Error Response Examples
When the account info query fails, the API returns an error response with the appropriate HTTP status code, error code, and a descriptive message. The most common error scenarios for this endpoint are authentication-related, since the endpoint itself has no parameters that could be invalid.
401 - API Key Required
{
"success": false,
"service": "MyDisct Solver BBRE",
"error": {
"code": "API_KEY_REQUIRED",
"message": "API key is required. Please provide your API key in the x-api-key or apikey header."
}
}
403 - Invalid API Key
{
"success": false,
"service": "MyDisct Solver BBRE",
"error": {
"code": "INVALID_API_KEY",
"message": "The provided API key is invalid or does not exist."
}
}
403 - Account Suspended
{
"success": false,
"service": "MyDisct Solver BBRE",
"error": {
"code": "ACCOUNT_SUSPENDED",
"message": "Your account has been suspended. Please contact support for more information."
}
}
500 - Service Error
{
"success": false,
"service": "MyDisct Solver BBRE",
"error": {
"code": "SERVICE_ERROR",
"message": "An internal server error occurred. Please try again later."
}
}
Code Examples
The following examples demonstrate how to retrieve your account information and usage
statistics using different programming languages and HTTP methods. Since the account info
endpoint supports both GET and POST, examples are provided for both methods where
applicable. All examples show complete, working code that you can copy and run directly.
Remember to replace YOUR_API_KEY with your actual BBRE API key.
GET Request with JavaScript (fetch)
The simplest way to retrieve your account information using the native fetch
API. Since this is a GET request with no body, you only need to include the authentication
header. The response contains both the account details and the statistics object.
const API_BASE = "https://bbre-solver-api.mydisct.com";
const API_KEY = "YOUR_API_KEY";
async function getAccountInfo() {
const response = await fetch(API_BASE + "/account/info", {
method: "GET",
headers: {
"x-api-key": API_KEY
}
});
const data = await response.json();
if (data.success) {
console.log("Username:", data.account.username);
console.log("Email:", data.account.email);
console.log("Status:", data.account.status);
console.log("Balance: $" + data.account.balance.toFixed(2));
console.log("Total Requests:", data.statistics.totalRequests);
console.log("Today Requests:", data.statistics.todayRequests);
console.log("Success Rate:", data.statistics.successRate + "%");
console.log("Active Sessions:", data.statistics.activeSessions);
} else {
console.log("Error:", data.error.code, data.error.message);
}
return data;
}
getAccountInfo();
POST Request with JavaScript (fetch)
If your application already uses POST for all BBRE API calls, you can use POST for the account info endpoint as well. The response is identical to the GET method. This is useful when your HTTP client wrapper or middleware is configured to send all requests as POST.
const API_BASE = "https://bbre-solver-api.mydisct.com";
const API_KEY = "YOUR_API_KEY";
async function getAccountInfoPost() {
const response = await fetch(API_BASE + "/account/info", {
method: "POST",
headers: {
"x-api-key": API_KEY
}
});
const data = await response.json();
if (data.success) {
console.log("Account:", data.account.username);
console.log("Balance: $" + data.account.balance.toFixed(2));
console.log("Success Rate:", data.statistics.successRate + "%");
}
return data;
}
getAccountInfoPost();
Python (requests library)
Retrieving your account information with Python using the popular requests
library. The example demonstrates how to access both the account details and the
statistics from the response.
import requests
API_BASE = "https://bbre-solver-api.mydisct.com"
API_KEY = "YOUR_API_KEY"
headers = {
"x-api-key": API_KEY
}
response = requests.get(
API_BASE + "/account/info",
headers=headers
)
data = response.json()
if data["success"]:
account = data["account"]
stats = data["statistics"]
print(f"Username: {account['username']}")
print(f"Email: {account['email']}")
print(f"Status: {account['status']}")
print(f"Balance: ${account['balance']:.2f}")
print(f"Created: {account['createdAt']}")
print(f"Total Requests: {stats['totalRequests']}")
print(f"Today Requests: {stats['todayRequests']}")
print(f"Completed: {stats['completedRequests']}")
print(f"Failed: {stats['failedRequests']}")
print(f"Success Rate: {stats['successRate']}%")
print(f"Active Sessions: {stats['activeSessions']}")
else:
print(f"Error: {data['error']['code']}")
import requests
API_BASE = "https://bbre-solver-api.mydisct.com"
API_KEY = "YOUR_API_KEY"
headers = {
"x-api-key": API_KEY
}
response = requests.post(
API_BASE + "/account/info",
headers=headers
)
data = response.json()
if data["success"]:
print(f"Account: {data['account']['username']}")
print(f"Balance: ${data['account']['balance']:.2f}")
print(f"Success Rate: {data['statistics']['successRate']}%")
cURL
Quick account info retrieval from the command line using cURL. The GET method is the natural choice for cURL since it requires no body. You can pipe the output through a JSON formatter for easier reading.
curl https://bbre-solver-api.mydisct.com/account/info \
-H "x-api-key: YOUR_API_KEY"
curl -X POST https://bbre-solver-api.mydisct.com/account/info \
-H "x-api-key: YOUR_API_KEY"
Statistics Interpretation
The statistics object in the account info response provides six metrics that together give you a complete picture of your API usage patterns and account health. Understanding what each metric means and how to use it effectively is essential for building reliable monitoring systems and making informed decisions about your BBRE integration. The following breakdown explains each statistic in detail, including how it is calculated, what values are normal, and what actions you should take based on the values you observe.
totalRequests
This is the lifetime count of all BBRE tasks ever created for your account. It includes every request regardless of its outcome: completed, failed, timed out, or still processing. This number only increases over time and never resets. It is calculated by counting all BBRETask records associated with your user account. Use this metric to understand your overall API consumption volume. If you are on a plan with a monthly request limit, compare this value against your limit to track usage. A rapidly increasing totalRequests count combined with a low success rate may indicate that your integration is retrying failed requests aggressively, which wastes both balance and API capacity.
todayRequests
This counter tracks the number of BBRE tasks created since midnight UTC on the current day. It resets to zero at the start of each new UTC day (00:00:00 UTC). This metric is useful for monitoring your daily consumption rate and detecting unusual spikes in usage. If your typical daily usage is around 500 requests and you suddenly see 2000 requests by midday, it could indicate a runaway script, an unexpected traffic spike, or a misconfigured retry loop. Compare todayRequests against your historical daily averages to establish baselines and set alert thresholds.
completedRequests
The total number of BBRE tasks that finished successfully with a "completed"
status. A completed request means the BBRE engine successfully processed the request and
returned a valid response from the target server. This count includes all successful
requests from the lifetime of your account. The difference between totalRequests and
(completedRequests + failedRequests) represents requests that are still in a processing
or pending state.
failedRequests
The total number of BBRE tasks that ended with a "failed" status. Failures
can occur for various reasons: the target server returned an error, the request timed out,
the target blocked the request, or an internal processing error occurred. A high number of
failed requests relative to total requests indicates potential issues with your target URLs,
request configuration, or the target servers themselves. Review the
Usage History endpoint to see the specific
error details for each failed request and identify patterns.
successRate
The percentage of completed requests out of total requests, calculated as
(completedRequests / totalRequests * 100) and rounded to two decimal places.
If no requests have been made (totalRequests is 0), the success rate is 0.
A healthy BBRE integration typically maintains a success rate above 90%. If your success
rate drops below 85%, investigate the causes by checking the usage history for common
failure patterns. Common causes of low success rates include targeting servers with
aggressive bot detection, using insufficient sensibility levels for protected targets,
network connectivity issues, and requesting URLs that frequently return server errors.
Switching from passive mode to adaptive mode or increasing the sensibility level can
often improve success rates for difficult targets.
activeSessions
The number of sessions that are currently active and have not expired. A session is
counted as active only if its status field is "active" and its expiration
timestamp (expires_at) is in the future. Sessions that have been explicitly
closed or have passed their expiration time are not included. The BBRE API enforces a
maximum of 10 active sessions per account. If you see this number approaching 10, you
should close unused sessions to free up capacity. If activeSessions is consistently at
or near the limit, consider restructuring your workflow to reuse sessions more efficiently
or close sessions promptly when they are no longer needed.
Dashboard Integration Patterns
The account info endpoint is the foundation for building monitoring dashboards that display your BBRE API usage in real time. Because the endpoint returns both account details and usage statistics in a single call, you can build a comprehensive dashboard with minimal API overhead. The following patterns demonstrate common approaches to dashboard integration that you can adapt to your specific monitoring needs.
Real-Time Dashboard Data Fetcher
This pattern fetches account info at regular intervals and formats the data for display in a dashboard. The fetcher runs on a configurable interval and emits structured data that your frontend can consume directly. The interval should be set based on how frequently your statistics change; for most applications, a 30-60 second interval provides a good balance between freshness and API efficiency.
const API_BASE = "https://bbre-solver-api.mydisct.com";
const API_KEY = "YOUR_API_KEY";
const REFRESH_INTERVAL_MS = 30000;
async function fetchDashboardData() {
const response = await fetch(API_BASE + "/account/info", {
headers: { "x-api-key": API_KEY }
});
const data = await response.json();
if (!data.success) {
return { error: data.error.code };
}
return {
account: {
username: data.account.username,
status: data.account.status,
balance: data.account.balance
},
metrics: {
totalRequests: data.statistics.totalRequests,
todayRequests: data.statistics.todayRequests,
successRate: data.statistics.successRate,
activeSessions: data.statistics.activeSessions,
failedRequests: data.statistics.failedRequests,
completedRequests: data.statistics.completedRequests
},
health: {
balanceOk: data.account.balance > 5.00,
successRateOk: data.statistics.successRate > 85,
sessionsOk: data.statistics.activeSessions < 8
},
timestamp: new Date().toISOString()
};
}
async function startDashboardRefresh() {
const update = async () => {
const dashboardData = await fetchDashboardData();
console.log("Dashboard update:", JSON.stringify(dashboardData, null, 2));
};
await update();
setInterval(update, REFRESH_INTERVAL_MS);
}
startDashboardRefresh();
Success Rate Monitoring with Alerts
This pattern monitors your success rate over time and triggers alerts when it drops below a configurable threshold. A sudden drop in success rate often indicates a problem with your target servers, your request configuration, or the BBRE service itself. By detecting these drops early, you can investigate and resolve issues before they affect your production workflows significantly.
const API_BASE = "https://bbre-solver-api.mydisct.com";
const API_KEY = "YOUR_API_KEY";
const SUCCESS_RATE_THRESHOLD = 85;
const CHECK_INTERVAL_MS = 60000;
let previousSuccessRate = null;
async function monitorSuccessRate() {
try {
const response = await fetch(API_BASE + "/account/info", {
headers: { "x-api-key": API_KEY }
});
const data = await response.json();
if (!data.success) {
console.log("Failed to fetch account info:", data.error.code);
return;
}
const currentRate = data.statistics.successRate;
const timestamp = new Date().toISOString();
console.log("[" + timestamp + "] Success rate: " + currentRate + "%");
if (currentRate < SUCCESS_RATE_THRESHOLD) {
console.log("[ALERT] Success rate below threshold!");
console.log("Current: " + currentRate + "%, Threshold: " + SUCCESS_RATE_THRESHOLD + "%");
console.log("Failed requests: " + data.statistics.failedRequests);
console.log("Total requests: " + data.statistics.totalRequests);
}
if (previousSuccessRate !== null) {
const drop = previousSuccessRate - currentRate;
if (drop > 5) {
console.log("[WARNING] Success rate dropped by " + drop.toFixed(2) + "% since last check");
}
}
previousSuccessRate = currentRate;
} catch (error) {
console.log("Monitoring error:", error.message);
}
}
setInterval(monitorSuccessRate, CHECK_INTERVAL_MS);
monitorSuccessRate();
Python Dashboard Data Collector
A Python implementation for collecting account info data and storing it for dashboard visualization. This pattern is useful when your monitoring infrastructure is built with Python-based tools or when you want to store historical metrics for trend analysis.
import requests
import json
from datetime import datetime
API_BASE = "https://bbre-solver-api.mydisct.com"
API_KEY = "YOUR_API_KEY"
headers = {
"x-api-key": API_KEY
}
def collect_account_metrics():
response = requests.get(
API_BASE + "/account/info",
headers=headers
)
data = response.json()
if not data["success"]:
return {"error": data["error"]["code"]}
account = data["account"]
stats = data["statistics"]
metrics = {
"timestamp": datetime.utcnow().isoformat(),
"balance": account["balance"],
"status": account["status"],
"total_requests": stats["totalRequests"],
"today_requests": stats["todayRequests"],
"completed": stats["completedRequests"],
"failed": stats["failedRequests"],
"success_rate": stats["successRate"],
"active_sessions": stats["activeSessions"]
}
return metrics
metrics = collect_account_metrics()
print(json.dumps(metrics, indent=2))
Node.js SDK Usage
The mydisctsolver-bbre Node.js SDK provides a convenient
getAccountInfo() method on the BBREClient class that wraps the
GET /account/info endpoint. The SDK handles authentication headers and
response parsing automatically, returning an object with account and
statistics properties directly instead of the full response wrapper. This
means you do not need to check the success field or extract nested objects
from the response; the SDK does that for you and throws an error if the request fails.
Basic Account Info Retrieval
const { BBREClient } = require("mydisctsolver-bbre");
const client = new BBREClient({ apiKey: "YOUR_API_KEY" });
async function getInfo() {
const info = await client.getAccountInfo();
console.log(info.account);
console.log(info.statistics);
return info;
}
getInfo();
SDK Account Info with Detailed Logging
Access individual fields from the account and statistics objects returned by the SDK.
The SDK returns { account, statistics } directly, so you can destructure
the result and access each field without navigating through the full API response
structure.
const { BBREClient } = require("mydisctsolver-bbre");
const client = new BBREClient({ apiKey: "YOUR_API_KEY" });
async function logAccountDetails() {
const { account, statistics } = await client.getAccountInfo();
console.log("Account Details:");
console.log(" Username: " + account.username);
console.log(" Email: " + account.email);
console.log(" Status: " + account.status);
console.log(" Balance: $" + account.balance.toFixed(2));
console.log(" Created: " + account.createdAt);
console.log("Usage Statistics:");
console.log(" Total Requests: " + statistics.totalRequests);
console.log(" Today Requests: " + statistics.todayRequests);
console.log(" Completed: " + statistics.completedRequests);
console.log(" Failed: " + statistics.failedRequests);
console.log(" Success Rate: " + statistics.successRate + "%");
console.log(" Active Sessions: " + statistics.activeSessions);
}
logAccountDetails();
SDK Health Check Before Operations
Use the SDK getAccountInfo() method to perform a comprehensive health check
before starting a batch operation. This pattern verifies your account status, balance,
success rate, and session availability in a single API call, giving you confidence that
your workflow will complete successfully.
const { BBREClient } = require("mydisctsolver-bbre");
const client = new BBREClient({
apiKey: "YOUR_API_KEY",
mode: "passive",
sensibility: "medium"
});
async function preFlightCheck(requiredBalance) {
const { account, statistics } = await client.getAccountInfo();
if (account.status !== "active") {
throw new Error("Account is not active: " + account.status);
}
if (account.balance < requiredBalance) {
throw new Error("Insufficient balance: $" + account.balance.toFixed(2) + " (need $" + requiredBalance.toFixed(2) + ")");
}
if (statistics.successRate < 50 && statistics.totalRequests > 100) {
console.log("Warning: Low success rate (" + statistics.successRate + "%). Check your request configuration.");
}
if (statistics.activeSessions >= 9) {
console.log("Warning: " + statistics.activeSessions + " active sessions. Close unused sessions before creating new ones.");
}
console.log("Pre-flight check passed.");
console.log("Balance: $" + account.balance.toFixed(2));
console.log("Success Rate: " + statistics.successRate + "%");
console.log("Active Sessions: " + statistics.activeSessions + "/10");
return true;
}
preFlightCheck(10.00);
The SDK getAccountInfo() method internally sends a GET request to
/account/info and extracts the account and
statistics fields from the response. If the request fails, the method
throws an error with the error message from the API response. For more details on the
SDK, see the Node.js SDK Overview and the
Account Methods documentation.
Error Codes
The following table lists all error codes that can be returned by the account info endpoint, along with their HTTP status codes, descriptions, and recommended solutions. Because the account info endpoint has no request parameters, the only possible errors are authentication-related errors and server-side errors. Implementing proper error handling for these codes ensures your account monitoring logic degrades gracefully when issues occur.
| HTTP Status | Error Code | Description | Solution |
|---|---|---|---|
401 |
API_KEY_REQUIRED |
No API key was provided in the request headers. The account info endpoint requires authentication like all other BBRE endpoints. | Include your API key in the x-api-key or apikey header. Verify that your HTTP client is sending the header correctly and that it is not being stripped by a proxy or middleware. |
403 |
INVALID_API_KEY |
The provided API key is not valid or does not exist in the system. | Verify your API key in the MyDisct Solver dashboard. Ensure you are copying the complete key without extra spaces or line breaks. If you recently regenerated your key, update it in your application configuration. |
403 |
ACCOUNT_SUSPENDED |
Your account has been suspended. Suspended accounts cannot access any BBRE API endpoints, including the account info endpoint. | Contact MyDisct Solver support for information about your account suspension and steps to resolve it. |
403 |
ACCOUNT_INACTIVE |
Your account is inactive. Inactive accounts need to be activated before they can use the BBRE API. | Activate your account through the MyDisct Solver dashboard or contact support for assistance. |
500 |
SERVICE_ERROR |
An internal server error occurred while processing the account info request. This can happen if the statistics calculation encounters a database issue. | Retry the request after a short delay (2-5 seconds). If the error persists, contact support. The account details portion may still be available through the simpler /account/balance endpoint while the issue is being resolved. |
Error Handling Example
The following example demonstrates robust error handling for the account info endpoint. In production systems, your account info retrieval should never crash your application. Instead, handle each error code appropriately and fall back to a safe default behavior when the account information cannot be determined.
const API_BASE = "https://bbre-solver-api.mydisct.com";
const API_KEY = "YOUR_API_KEY";
async function getAccountInfoSafe() {
try {
const response = await fetch(API_BASE + "/account/info", {
headers: { "x-api-key": API_KEY }
});
const data = await response.json();
if (data.success) {
return {
account: data.account,
statistics: data.statistics,
error: null
};
}
const errorCode = data.error.code;
if (errorCode === "API_KEY_REQUIRED" || errorCode === "INVALID_API_KEY") {
return { account: null, statistics: null, error: "Authentication failed: " + errorCode };
}
if (errorCode === "ACCOUNT_SUSPENDED" || errorCode === "ACCOUNT_INACTIVE") {
return { account: null, statistics: null, error: "Account issue: " + errorCode };
}
return { account: null, statistics: null, error: "Unexpected error: " + errorCode };
} catch (networkError) {
return { account: null, statistics: null, error: "Network error: " + networkError.message };
}
}
async function main() {
const result = await getAccountInfoSafe();
if (result.error) {
console.log("Could not fetch account info:", result.error);
return;
}
console.log("Account: " + result.account.username);
console.log("Balance: $" + result.account.balance.toFixed(2));
console.log("Success Rate: " + result.statistics.successRate + "%");
}
main();
Best Practices
Instead of calling the balance endpoint separately, use the account info endpoint for
pre-flight checks before batch operations. A single call to /account/info
gives you the balance, account status, success rate, and active session count all at
once. This lets you verify that your account is active, has sufficient funds, is
performing well, and has available session capacity before committing to an expensive
operation. One API call replaces what would otherwise require multiple separate
endpoint calls.
Store the success rate value from each account info call and track it over time to identify trends. A gradually declining success rate may indicate that your target servers are increasing their bot detection measures, requiring you to adjust your mode or sensibility settings. A sudden drop usually indicates a specific issue such as a target server outage, a configuration change, or a network problem. Set up alerts for both gradual declines (more than 5% drop over a week) and sudden drops (more than 10% drop between consecutive checks) to catch issues early.
Use the todayRequests field to track your daily consumption patterns.
Record this value at the end of each day (just before midnight UTC) to build a
historical dataset of daily request volumes. This data is invaluable for capacity
planning, budget forecasting, and detecting anomalies. If your daily request count
suddenly doubles without a corresponding change in your application logic, it may
indicate a bug in your retry logic, an unexpected traffic spike, or unauthorized
use of your API key.
Monitor the activeSessions count and proactively close sessions that
are no longer needed. The BBRE API enforces a maximum of 10 active sessions per
account. If your application creates sessions but does not always close them
explicitly, you may eventually hit this limit and be unable to create new sessions.
Implement a cleanup routine that checks for idle sessions and closes them. Use the
Account Sessions endpoint to list
all active sessions and identify which ones can be safely closed.
If your dashboard refreshes frequently or has multiple components that need account data, cache the account info response for 15-30 seconds to avoid making redundant API calls. The statistics change only when new requests are processed or sessions are created or closed, so a cached value from a few seconds ago is accurate enough for display purposes. Invalidate the cache after any operation that you know will affect the statistics, such as creating a request, closing a session, or completing a batch operation.
Common Issues
Issue 1: Success Rate Shows Zero Despite Successful Requests
You have been making requests that return successful responses, but the
successRate field in the account info response shows 0
or a very low value that does not match your experience.
Solution: The success rate is calculated based on the
completedRequests and totalRequests counts. If you are using
asynchronous requests (via /request/create), the tasks may still be in a
processing state when you check the account info. Tasks that are still processing are
counted in totalRequests but not in completedRequests, which
lowers the apparent success rate. Wait for your requests to finish processing and then
check the account info again. If you are using synchronous requests (via
/request/execute), the success rate should update immediately after each
request completes. Also verify that you are not confusing the HTTP response status
(which indicates the API call succeeded) with the task status (which indicates whether
the target server returned a valid response).
Issue 2: todayRequests Does Not Reset at Midnight
The todayRequests counter appears to carry over from the previous day
or does not reset when you expect it to. Your daily tracking shows inconsistent
numbers.
Solution: The todayRequests counter resets at midnight UTC,
not at midnight in your local timezone. If you are in a timezone that is significantly
offset from UTC, the reset time will differ from your local midnight. For example, if
you are in UTC-8 (Pacific Time), the counter resets at 4:00 PM local time. Adjust your
monitoring and reporting logic to account for the UTC-based reset. If you need daily
counts based on your local timezone, use the
Usage History endpoint with date filters
to calculate daily totals in your preferred timezone.
Issue 3: activeSessions Count Seems Too High
The activeSessions count is higher than expected. You believe you have
closed all your sessions, but the count still shows active sessions remaining.
Solution: Sessions remain active until they are explicitly closed via
the /session/close endpoint or until their expiration time passes. If your
application crashes or loses network connectivity before closing a session, that session
remains active until it expires naturally. Check the
Account Sessions endpoint to see which
sessions are still active and their expiration times. You can close any unwanted sessions
manually using the /session/close endpoint. To prevent this issue in the
future, implement session cleanup logic in your application that closes sessions in a
try-finally block or uses a shutdown hook to close sessions when the application exits.