Skip to content

A PHP SDK for OKEX which will allow the end-user to be able to place orders, query orders and a whole host of other actions. Within this repository you can place an action against everything OKEX provide

License

Notifications You must be signed in to change notification settings

executium/okex-sdk-php-package

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

OKEX PHP SDK Package

A PHP SDK for OKEX which will allow the end-user to be able to place orders, query orders and a whole host of other actions. Within this repository you can place an action against everything OKEX provide.

What is included in this OKEX PHP Package?

Initial upload has now been made and ability provide so that the user can query anything they wish by consulting the OKEX documentation. We have provided some easy to access functions such as ticker, token details, order books, deposit address, order limit, order market, order information and cancel order.

Getting started with OKEX and PHP

In the example.php file you will find a range of predefined functions and how to get started

##/
define("OKEX_KEY","YOUR-KEY");
define("OKEX_SECRET","YOUR-SECRET");
define("OKEX_PASSPHRASE","YOUR-PASSPHRASE");
##/
$okexAPI = new okexAPI(OKEX_KEY,OKEX_SECRET,OKEX_PASSPHRASE);

You must generate API credentials via OKEX, they will require that you have some form of two-factor authentication

Placing an order with OKEX and PHP

When you place an order, OKEX will either provide an order_id or error_code, but both will be present, an example of a successful order

Array
(
    [client_oid] =>
    [error_code] =>
    [error_message] =>
    [order_id] => 3394164710385664
    [result] => 1
)

And an example of a failed order

Array
(
    [client_oid] =>
    [error_code] => 30024
    [error_message] => Parameter value filling error
    [order_id] => -1
    [result] =>
)

As far as exchanges go, OKEX is one of the better ones when it comes to providing good error feedback from our experience.

Cancelled order information

It is worth noting that if you cancel a LIMIT order with OKEX you won't be able to callback on that information even with the Order ID and Instrument ID

Array
(
    [code] => 33014
    [message] => Order does not exist
)

Adding parameters when not required will result in an error

If you use the query($path,$request=array()) function, which we recommend and envision you will need too, given that we only scratch the surface of providing useful functions in this release, you will need to take note of one important point.

The OK-ACCESS-SIGN header is generated by creating a sha256 HMAC using the base64-decoded secret key on the prehash String timestamp + method + requestPath + body (where + represents String concatenation), secretKey and base64-encode the output. For example: sign=CryptoJS.enc.Base64.Stringify(CryptoJS.HmacSHA256(timestamp + 'GET' + '/users/self/verify', secretKey))

Do not provide unnecessary parameters in the second argument if the documentation doesn't specify as it will result in a 405 code which means the METHOD got rejected by OKEX, it is a simple fix though, simply empty the array so that no parameters are present and it will work as normal.

0.1 - August 2019

The initial okex.class.php and example.php file is provided with 10 easy to access functions ranging from ordering to canceling and querying OKEX public data.

Who is this for?

This is for people looking for a PHP OKEX script, people that maybe searching without much luck for a OKEX PHP example or OKEX PHP function. The key really is to connect this script with the coders and traders that need it, as like us, when you was searching for OKEX and PHP there wasn't much in way of resources.

License

MIT License

Copyright (c) 2019 executium

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

A PHP SDK for OKEX which will allow the end-user to be able to place orders, query orders and a whole host of other actions. Within this repository you can place an action against everything OKEX provide

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages