Skip to content

Commit

Permalink
ExchangeInfo added
Browse files Browse the repository at this point in the history
  • Loading branch information
wilianmaique committed May 12, 2024
1 parent 45cd9e7 commit 46130fa
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 12 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# DISCORD
```shell
wilianmaique
```

# MEXC-API PHP
lib mexc api simple, for detail account, balance spot, withdraw
info token, etc...
Expand Down
16 changes: 9 additions & 7 deletions examples/index.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
<?php

const MEXC_CONFIG = [
'MEXC_URL_API' => 'https://api.mexc.com/api/v3',
'MEXC_API_ACCESS_KEY' => 'mx0vglDTfAPSDCof1m',
'MEXC_API_SECRET' => '7cf68dd323074ba3b21554091290b607'
'MEXC_URL_API' => 'https://api.mexc.com/api/v3',
'MEXC_API_ACCESS_KEY' => 'mx0vgleBCS3z3msSyq',
'MEXC_API_SECRET' => 'f7d42e5beb7948e083b3d44d2beb4876'
];

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

use WilianMaique\Mexc\Mexc\Account;
use WilianMaique\Mexc\Mexc\ExchangeInfo;
use WilianMaique\Mexc\Mexc\InfoToken;
use WilianMaique\Mexc\Mexc\PriceTicker;

dd([
'InfoToken' => InfoToken::get('WEMIX'),
'Account' => Account::get(),
'PriceTicker' => PriceTicker::get(),
]);
'ExchangeInfo' => ExchangeInfo::get(['MXUSDT', 'BTCUSDT']),
'InfoToken' => InfoToken::get('WEMIX'),
'Account' => Account::get(),
'PriceTicker' => PriceTicker::get('WEMIXUSDT'),
]);
39 changes: 39 additions & 0 deletions src/Mexc/ExchangeInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace WilianMaique\Mexc\Mexc;

class ExchangeInfo
{
/*
*
* get current exchange trading rules and symbol information, symbol by name or null to get all list
* https://mexcdevelop.github.io/apidocs/spot_v3_en/#exchange-information
*/
public static function get(?array $symbols = ['MXUSDT']): array|bool
{
if (!empty($symbols)) {
$upperCaseSymbols = array_map('strtoupper', $symbols);
$symbols = implode(',', $upperCaseSymbols);
} else $symbols = '';

$url = MEXC_CONFIG['MEXC_URL_API'] . '/exchangeInfo?symbols=' . $symbols;
$ch = curl_init($url);

curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => true,
]);

$res = curl_exec($ch);

if (!$res) {
curl_close($ch);
return false;
}

curl_close($ch);

return json_decode($res, true);
}
}

0 comments on commit 46130fa

Please sign in to comment.