vittominacori/changelly-php

Changelly API 的 PHP 封装

v1.1 2020-04-28 15:15 UTC

This package is auto-updated.

Last update: 2024-08-29 01:26:10 UTC


README

Changelly API 的 PHP 封装

安装

composer require vittominacori/changelly-php

生成 API 密钥和密钥

在这里生成密钥和密钥 here.

使用方法

准备需求

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

use Changelly\Changelly;

创建客户端

$changelly = new Changelly('yourApiKey', 'yourApiSecret');

调用 API

getCurrencies

描述

  • 返回一个包含启用货币的扁平数组。
$changelly->getCurrencies();

结果

[
  "btc",
  "eth",
  "etc",
  "exp",
  "xem",
  "lsk",
  "xmr",
  "strat",
  "rep",
  "lbc",
  "maid",
  "ltc",
  "bcn",
  "xrp",
  "doge",
  "amp",
  "nxt",
  "dash",
  "xdn",
  "nbt",
  "nav",
  "pot",
  "gnt",
  "waves",
  "usdt",
  "swt",
  "mln",
  "pivx",
  "trst",
  "edg",
  "rlc",
  "gno",
  "dcr",
  "gup",
  "lun",
  "str",
  "bat",
  "ant",
  "bnt",
  "cvc",
  "eos",
  "pay",
  "bch",
  "omg",
  "mco",
  "adx",
  "zrx",
  "qtum",
  "ptoy",
  "storj",
  "cfi",
  "hmq",
  "nmr",
  "salt",
  "btg",
  "dgb",
  "dnt",
  "vib",
  "rcn",
  "zcl",
  "stx",
  "kmd",
  "brd",
  "dcn",
  "ngc",
  "xmo",
  "noah",
  "zen"
]

getCurrenciesFull

描述

  • 返回一个包含所有货币的完整列表,每个对象都有一个 "enabled" 字段,显示货币的当前可用性。
$changelly->getCurrenciesFull();

结果

[
  {
    "name": "btc",
    "fullName": "Bitcoin",
    "enabled": true,
    "image": "https://changelly.com/coins/btc.svg"
  },
  {
    "name": "eth",
    "fullName": "Ethereum",
    "enabled": true,
    "image": "https://changelly.com/coins/eth.svg"
  },
  {
    "name": "etc",
    "fullName": "Ethereum Classic",
    "enabled": true,
    "image": "https://changelly.com/coins/etc.svg"
  },
  (...)
  {
    "name": "zen",
    "fullName": "Zencash",
    "enabled": true,
    "image": "https://changelly.com/coins/zen.svg"
  }
]

getMinAmount

描述

  • 返回一个货币对所需的最小允许支付金额。小于最小金额的交易很可能会失败。
$changelly->getMinAmount('btc', 'eth');

结果

"0.00150457"

getExchangeAmount

描述

  • 返回包括您与 API 合作伙伴的费用在内的估算交换价值。
$changelly->getExchangeAmount('btc', 'eth', '1');

结果

"12.10716"

createTransaction

描述

  • 创建一个新的交易,生成一个支付地址,并返回一个包含 ID 字段的 Transaction 对象以跟踪交易状态。
$changelly->createTransaction('btc', 'eth', '0x123123...123', 0.3);

结果

{
  "id": "854e8d7dc9ef",
  "apiExtraFee": "0",
  "changellyFee": "0.5",
  "payinExtraId": null,
  "status": "new",
  "currencyFrom": "btc",
  "currencyTo": "eth",
  "amountTo": 0,
  "payinAddress": "36P9TNYPbZrGs8Udn84F9uAY95VYM2Xk4K",
  "payoutAddress": "0x123123...123",
  "createdAt": "2018-05-04T15:15:02.000Z"
}

getStatus

描述

  • 使用提供的交易 ID 返回给定交易的状态。
$changelly->getStatus('854e8d7dc9ef');

结果

"waiting"

getTransactions

描述

  • 返回所有交易或过滤后的交易列表。
$changelly->getTransactions();

结果

[
  {
    "id": "854e8d7dc9ef",
    "createdAt": 1525446902,
    "payinConfirmations": "0",
    "status": "waiting",
    "currencyFrom": "btc",
    "currencyTo": "eth",
    "payinAddress": "36P9TNYPbZrGs8Udn84F9uAY95VYM2Xk4K",
    "payinExtraId": null,
    "payinHash": null,
    "payoutAddress": "0x123123...123",
    "payoutExtraId": null,
    "payoutHash": null,
    "amountFrom": "",
    "amountTo": "0",
    "networkFee": null,
    "changellyFee": "0.5",
    "apiExtraFee": "0"
  },
  (...)
]