PHP code example of zyan / stock-api

1. Go to this page and download the library: Download zyan/stock-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zyan / stock-api example snippets


StockApi::setConfig([
    'cache_path' => '/tmp/', //默认 ./runtime
]);

$stockApi = StockApi::getXueqiu(); //获取雪球api

//深圳A股
$xueQiuApi->getSzListAllToA();
//深圳B股
$xueQiuApi->getSzListAllToB();
//上海A股
$xueQiuApi->getShListAllToA();
//上海B股
$xueQiuApi->getShListAllToB();
//美股
$xueQiuApi->getUsListAll();
//港股
$xueQiuApi->getHkListAll();

(
    [count] => 2840
    [raw_count] => 2840
    [size] => 100
    [total_page] => 29
    [type] => 'sz'
    [market] => 'CN'
    [list] => Array
    (
        [0] => Array
            (
            [symbol] => SZ300043
            [net_profit_cagr] => -44.773510944738
            [north_net_inflow] =>
            [ps] => 4.4096797096154
            [type] => 11
            [percent] => 20.05
            [has_follow] =>
            [tick_size] => 0.01
            [pb_ttm] => 3.384
            [float_shares] => 1243539501
            [current] => 4.61
            [amplitude] => 24.74
            [pcf] => 38.22815900534
            [current_year_percent] => 24.26
            [float_market_capital] => 5732717100
            [north_net_inflow_time] =>
            [market_capital] => 5735754629
            [dividend_yield] =>
            [lot_size] => 100
            [roe_ttm] => -14.291383768457
            [total_percent] => 94.69
            [percent5m] => 0
            [income_cagr] => -4.5863830118018
            [amount] => 1398782578.23
            [chg] => 0.77
            [issue_date_ts] => 1263916800000
            [eps] => -0.21
            [main_net_inflows] => 148868900
            [volume] => 325274271
            [volume_ratio] => 2.23
            [pb] => 3.384
            [followers] => 29531
            [turnover_rate] => 26.16
            [mapping_quote_current] =>
            [first_percent] => 13.73
            [name] => 星辉娱乐
            [pe_ttm] =>
            [dual_counter_mapping_symbol] =>
            [total_shares] => 1244198401
            [limitup_days] => 1
        )
        ...
    )
)
 

$stockApi->list(string $market,string $type,int $currentPage,int $size)

(
    [data] => Array
        (
            [count] => 5000
            [list] => Array
            (
                [0] => Array
                    (
                    [symbol] => SZ300043
                    [net_profit_cagr] => -44.773510944738
                    [north_net_inflow] =>
                    [ps] => 4.4096797096154
                    [type] => 11
                    [percent] => 20.05
                    [has_follow] =>
                    [tick_size] => 0.01
                    [pb_ttm] => 3.384
                    [float_shares] => 1243539501
                    [current] => 4.61
                    [amplitude] => 24.74
                    [pcf] => 38.22815900534
                    [current_year_percent] => 24.26
                    [float_market_capital] => 5732717100
                    [north_net_inflow_time] =>
                    [market_capital] => 5735754629
                    [dividend_yield] =>
                    [lot_size] => 100
                    [roe_ttm] => -14.291383768457
                    [total_percent] => 94.69
                    [percent5m] => 0
                    [income_cagr] => -4.5863830118018
                    [amount] => 1398782578.23
                    [chg] => 0.77
                    [issue_date_ts] => 1263916800000
                    [eps] => -0.21
                    [main_net_inflows] => 148868900
                    [volume] => 325274271
                    [volume_ratio] => 2.23
                    [pb] => 3.384
                    [followers] => 29531
                    [turnover_rate] => 26.16
                    [mapping_quote_current] =>
                    [first_percent] => 13.73
                    [name] => 星辉娱乐
                    [pe_ttm] =>
                    [dual_counter_mapping_symbol] =>
                    [total_shares] => 1244198401
                    [limitup_days] => 1
                )
                ...
            )
        )
    )
    [error_code] => 0
    [error_msg] => 'ok'
)