ClientBase
in package
Abstract base class for Market Data API client.
This class provides core functionality for API communication, including parallel execution, async requests, and response handling.
Table of Contents
Constants
- API_HOST = "api.marketdata.app"
- The host for the Market Data API.
- API_URL = "https://api.marketdata.app/"
- The base URL for the Market Data API.
Properties
Methods
- __construct() : mixed
- ClientBase constructor.
- execute() : object
- Execute a single API request.
- execute_in_parallel() : array<string|int, mixed>
- Execute multiple API calls in parallel.
- setGuzzle() : void
- Set a custom Guzzle client.
- async() : PromiseInterface
- Perform an asynchronous API request.
- headers() : array<string|int, mixed>
- Generate headers for API requests.
Constants
API_HOST
The host for the Market Data API.
public
mixed
API_HOST
= "api.marketdata.app"
API_URL
The base URL for the Market Data API.
public
mixed
API_URL
= "https://api.marketdata.app/"
Properties
$guzzle
protected
Client
$guzzle
The Guzzle HTTP client instance.
$token
protected
string
$token
The API token for authentication.
Methods
__construct()
ClientBase constructor.
public
__construct(string $token) : mixed
Parameters
- $token : string
-
The API token for authentication.
execute()
Execute a single API request.
public
execute(string $method[, array<string|int, mixed> $arguments = [] ]) : object
Parameters
- $method : string
-
The API method to call.
- $arguments : array<string|int, mixed> = []
-
The arguments for the API call.
Tags
Return values
object —The API response as an object.
execute_in_parallel()
Execute multiple API calls in parallel.
public
execute_in_parallel(array<string|int, mixed> $calls) : array<string|int, mixed>
Parameters
- $calls : array<string|int, mixed>
-
An array of method calls, each containing the method name and arguments.
Tags
Return values
array<string|int, mixed> —An array of decoded JSON responses.
setGuzzle()
Set a custom Guzzle client.
public
setGuzzle(Client $guzzleClient) : void
Parameters
- $guzzleClient : Client
-
The Guzzle client to use.
async()
Perform an asynchronous API request.
protected
async(string $method[, array<string|int, mixed> $arguments = [] ]) : PromiseInterface
Parameters
- $method : string
-
The API method to call.
- $arguments : array<string|int, mixed> = []
-
The arguments for the API call.
Return values
PromiseInterfaceheaders()
Generate headers for API requests.
protected
headers([string $format = 'json' ]) : array<string|int, mixed>
Parameters
- $format : string = 'json'
-
The desired response format (json, csv, or html).
Return values
array<string|int, mixed> —An array of headers.