MarketData SDK

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

$apiStatusData  : ApiStatusData
$client  : Client

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.

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
APIYes

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
link

API Documentation

see
getServiceStatus()

Check status of a specific service

example

$status = $client->utilities->api_status(); echo "30-day uptime: " . $status->uptime_30d . "%\n";

throws
GuzzleException|ApiException
Return values
ApiStatus

The current API status and historical uptime information.

clearApiStatusCache()

Clear the API status cache (useful for testing).

public static clearApiStatusCache() : void

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
throws
GuzzleException|ApiException
Return values
ApiStatusResult

The status result (ONLINE, OFFLINE, or UNKNOWN)

headers()

Retrieve the headers sent by the application.

public headers() : Headers
APIYes

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
link

API Documentation

example

$headers = $client->utilities->headers(); print_r($headers->headers);

throws
GuzzleException|ApiException
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
throws
GuzzleException|ApiException
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
APIYes

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
link

API Documentation

example

$user = $client->utilities->user(); echo "Remaining: " . $user->remaining . " / " . $user->limit . " credits\n";

throws
GuzzleException|ApiException
Return values
User

The user/rate limit information.


        
On this page

Search results