nabikaz/coinex-api-php

Coinex digital coin exchange API for PHP

dev-main 2021-11-11 02:41 UTC

This package is auto-updated.

Last update: 2024-06-11 07:53:28 UTC


README

Coinex digital coin exchange API for PHP

Requirements

  • PHP>=5.4
  • CURL PHP module

Install

composer require NabiKAZ/Coinex-API-PHP dev-main

Acquire access_id and secret_key

Sign in to CoinEx before invoking API and get Acquire access_id/secret_key in Account > API.

access_id: To mark identity of API invoker

secret_key: Key to sign the request parameters

Setup request

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

use NabiKAZ\Coinex\CoinexAPI;

//use this variable in some functions as global
$access_id = '<ACCESS_ID>';
$secret_key = '<SECRET_KEY';

//create api object
$coinex = new CoinexAPI($access_id, $secret_key);

Set proxy

The proxy is optional.
Use proxy URL with this format: scheme://[username:password@]hostname:port
For examples:

$proxy = 'socks5://user:pass@localhost:12345';
$proxy = 'http://127.0.01:8080';

And so use this proxy when setup request:

$coinex = new CoinexAPI($access_id, $secret_key, $proxy);

Set params

//params if nedded
//IMPORTANT: no needed set access_id, tonce into params.
$params = [
];

Arguments of request

name type required default example description
$url string yes - 'market/ticker' The request URL
$params array no [] ['market'=>'BCHBTC'] The request parameters
$method string no 'get' 'get', 'post', 'delete' The request method

Send request (Method 1)

//send request
$coinex->url = $url;
$coinex->params = $params;
$coinex->method = $method;
$res = $coinex->send();

Send request (Method 2)

//send request
$res = $coinex->send($url, $params, $method);

See results

//see results
var_dump($res);

Examples

You can see more examples in the examples.php file.

Wiki

See all requests, params and responses in here official wiki.