Utilities
in package
Utilities class for Market Data API.
This class provides utility methods for checking API status and retrieving request headers.
Table of Contents
Properties
Methods
- __construct() : mixed
- Utilities constructor.
- api_status() : ApiStatus
- Check the current status of Market Data services.
- clearApiStatusCache() : void
- Clear the API status cache (useful for testing).
- getApiStatusData() : ApiStatusData
- Get the singleton ApiStatusData instance.
- getServiceStatus() : ApiStatusResult
- Get the status of a specific service.
- headers() : Headers
- Retrieve the headers sent by the application.
- refreshApiStatus() : bool
- Manually refresh the API status cache.
- user() : User
- Retrieve rate limit information for the current user.
Properties
$apiStatusData
private
static ApiStatusData
$apiStatusData
= null
Static singleton instance for API status caching.
$client
private
Client
$client
The Market Data API client instance.
Methods
__construct()
Utilities constructor.
public
__construct(Client $client) : mixed
Parameters
- $client : Client
-
The Market Data API client instance.
api_status()
Check the current status of Market Data services.
public
api_status() : ApiStatus
Check the current status of Market Data services and historical uptime. The status of the Market Data API is updated every 5 minutes. Historical uptime is available for the last 30 and 90 days.
TIP: This endpoint will continue to respond with the current status of the Market Data API, even if the API is offline. This endpoint is public and does not require a token.
Uses smart caching:
- If cache is fresh (< 4min30sec): Return cached data immediately, no async update
- If cache is in refresh window (4min30sec - 5min): Return cached data immediately AND trigger async refresh
- If cache is stale (> 5min): Block and fetch fresh data
Tags
Return values
ApiStatus —The current API status and historical uptime information.
clearApiStatusCache()
Clear the API status cache (useful for testing).
public
static clearApiStatusCache() : void
getApiStatusData()
Get the singleton ApiStatusData instance.
public
static getApiStatusData() : ApiStatusData
Return values
ApiStatusData —The singleton instance
getServiceStatus()
Get the status of a specific service.
public
getServiceStatus(string $service) : ApiStatusResult
Checks if a specific service (e.g., "/v1/stocks/quotes/") is online, offline, or unknown. Uses the same smart caching logic as api_status().
Parameters
- $service : string
-
The service path to check (e.g., "/v1/stocks/quotes/").
Tags
Return values
ApiStatusResult —The status result (ONLINE, OFFLINE, or UNKNOWN)
headers()
Retrieve the headers sent by the application.
public
headers() : Headers
This endpoint allows users to retrieve a JSON response of the headers their application is sending, aiding in troubleshooting authentication issues, particularly with the Authorization header.
TIP: The values in sensitive headers such as Authorization are partially redacted in the response for security purposes.
Tags
Return values
Headers —The headers sent in the request.
refreshApiStatus()
Manually refresh the API status cache.
public
refreshApiStatus([bool $blocking = false ]) : bool
Parameters
- $blocking : bool = false
-
Whether to wait for response (true) or trigger async refresh (false).
Tags
Return values
bool —True on success, false on failure (only meaningful for blocking mode)
user()
Retrieve rate limit information for the current user.
public
user() : User
This endpoint returns rate limit information from response headers, including:
- The maximum number of credits permitted (per day for Free/Starter/Trader plans or per minute for Prime users)
- The number of credits remaining in the current rate period
- The quantity of credits consumed in the current request (not cumulative)
- When the current rate limit window resets (UTC epoch seconds)
Note: Rate limits track credits, not requests. Most requests consume 1 credit, but bulk requests or options requests may consume multiple credits.
Tags
Return values
User —The user/rate limit information.