-
Notifications
You must be signed in to change notification settings - Fork 0
Installation and Configuration
This guide will walk you through installing the CoinQuant PHP SDK and configuring it for use in your PHP applications.
Before installing the SDK, ensure your environment meets the following requirements:
- PHP: Version 8.1 or higher.
- Composer: The standard package manager for PHP.
The package automatically requires guzzlehttp/guzzle (^7.8) as its underlying HTTP client [1].
You can install the package via Composer. Run the following command in your terminal at the root of your project:
composer require tigusigalpa/coinquant-phpCoinQuant uses a JWT bearer token for authentication. To obtain your token:
- Log in to the CoinQuant web app.
- Navigate to Settings → Service Accounts.
- Click on New key.
- Copy the generated
access_token. Note: This token is shown only once.
Tokens are valid for 30 days and grant access to almost all endpoints (excluding human-profile surfaces like /v1/me and billing).
Security Warning: Never commit your API token to version control. Always use environment variables to store sensitive credentials.
Set your token as an environment variable:
export COINQUANT_TOKEN="your_access_token_here"To use the SDK in a standalone PHP script, simply instantiate the CoinQuantClient with your token:
<?php
require __DIR__ . '/vendor/autoload.php';
use CoinQuant\CoinQuantClient;
$token = getenv('COINQUANT_TOKEN') ?: '';
$client = new CoinQuantClient($token);
// Test the connection
$health = $client->health();
echo "API Status: {$health['status']}\n";
// Check your credit balance
$credits = $client->getCredits();
echo "Available credits: {$credits['available_credits_total']}\n";The SDK uses Guzzle under the hood. If you need to configure advanced HTTP options—such as setting custom timeouts, adding a proxy, or injecting middleware for logging and retries—you can pass a pre-configured GuzzleHttp\Client instance to the constructor [1].
use GuzzleHttp\Client as GuzzleClient;
use CoinQuant\CoinQuantClient;
$http = new GuzzleClient([
'timeout' => 60.0,
'proxy' => 'tcp://localhost:8125',
'headers' => [
'Authorization' => 'Bearer ' . getenv('COINQUANT_TOKEN'),
'Accept' => 'application/json',
],
]);
$client = new CoinQuantClient(getenv('COINQUANT_TOKEN'), $http);You can also update the client later using the setHttpClient() method:
$client->setHttpClient($newGuzzleClient);If you are using the Laravel framework, proceed to the Laravel Integration guide to learn how to utilize the auto-discovered service provider and facade. Otherwise, check out Core Concepts & Streaming to start building strategies.