Skip to content

Quick Start

Igor Sazonov edited this page Jan 31, 2026 · 3 revisions

Quick Start

This guide provides a quick overview of how to start using the bybit-php library. We will cover making your first API call in both a standalone PHP project and a Laravel application.

Standalone PHP Usage

In a non-Laravel project, you can use the library by instantiating the BybitClient directly.

<?php

require_once __DIR__ . 

use Tigusigalpa\ByBit\BybitClient;

$apiKey = 
$apiSecret = 

$client = new BybitClient(
    apiKey: $apiKey,
    apiSecret: $apiSecret,
    testnet: true
);

// Get the server time
$serverTime = $client->getServerTime();

// Get the tickers for the BTC-USDT linear contract
$tickers = $client->getTickers([
    
    
]);

Laravel Usage

In a Laravel application, you can use the Bybit facade or dependency injection for a more convenient and testable approach.

Using the Facade

The facade provides a simple, static-like interface to the BybitClient.

use Tigusigalpa\ByBit\Facades\Bybit;

// Get the server time
$time = Bybit::getServerTime();

// Get the tickers for the BTC-USDT linear contract
$tickers = Bybit::getTickers([
    
    
]);

Using Dependency Injection

For better code organization and testability, you can inject the BybitClient into your controllers or services.

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Tigusigalpa\ByBit\BybitClient;

class TradingController extends Controller
{
    private BybitClient $bybit;

    public function __construct(BybitClient $bybit)
    {
        $this->bybit = $bybit;
    }

    public function getTickers()
    {
        $tickers = $this->bybit->getTickers([
            
            
        ]);
        return response()->json($tickers);
    }
}

Next Steps

Now that you have made your first API call, you are ready to explore the full capabilities of the library. Dive into the API Methods for a complete overview of all available methods.

Clone this wiki locally