zhouaini528 / bybit-php

Bybit API Like the official document interface, Support for arbitrary extension.
MIT License
24 stars 12 forks source link

429 error #23

Open DmitriiRabeckii opened 8 months ago

DmitriiRabeckii commented 8 months ago
<?php
/**
 * @author lin <465382251@qq.com>
 * */
use \Lin\Bybit\BybitSpot;

require __DIR__ .'../../../vendor/autoload.php';

include __DIR__ .'../../../vendor/key_secret.php';

$bybit=new BybitSpot($key,$secret);

//You can set special needs
$bybit->setOptions([
    //Set the request timeout to 60 seconds by default
    'timeout'=>10,
]);

try {
    $result=$bybit->privates()->getAccount();
    print_r($result);
}catch (\Exception $e){
    print_r($e->getMessage());
}

I get error {"_message":"Client error: GET https:\/\/api.bybit.com\/spot\/v1\/account? resulted in a 429 Too Many Requests response","_httpcode":429}

zhouaini528 commented 7 months ago
<?php
/**
 * @author lin <465382251@qq.com>
 * */
use \Lin\Bybit\BybitSpot;

require __DIR__ .'../../../vendor/autoload.php';

include __DIR__ .'../../../vendor/key_secret.php';

$bybit=new BybitSpot($key,$secret);

//You can set special needs
$bybit->setOptions([
    //Set the request timeout to 60 seconds by default
    'timeout'=>10,
]);

try {
    $result=$bybit->privates()->getAccount();
    print_r($result);
}catch (\Exception $e){
    print_r($e->getMessage());
}

I get error {"_message":"Client error: GET https:\/\/api.bybit.com\/spot\/v1\/account? resulted in a 429 Too Many Requests response","_httpcode":429}

Please use v5 https://github.com/zhouaini528/bybit-php/tree/master/src/Api/V5

$bybit=new BybitV5($key,$secret);

try {
    $result=$bybit->order()->postCreate([
        'category'=>'spot',
        'symbol'=>'BTCUSDT',
        'side'=>'buy',
        'orderType'=>'limit',
        'qty'=>'1',
        'price'=>'1000',

        //'orderLinkId'=>'xxxxxxxxxxx',
    ]);
    print_r($result);
}catch (\Exception $e){
    print_r($e->getMessage());
}