Skip to content

Glitter-Finance/changenow-api-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

JavaScript exchange API wrapper (Changenow.io)

API Key

To access the ChangeNOW API you need to generate an API key. You can get one in your personal affiliate account or by emailing us at [email protected].

Exchange flow

All API methods wrapped by only the one function cnApiWrapper. Which has three parameters callName, callPrams, callback.

callName - one of the API calls, which you want to request.
callPrams - this is an javaScript object, if the callName has required parameter, you need to pass it here. callback - (optional) this is a function that is called after the request is completed, an API response is passed to it.

How to use

Add a script link to your HTML before your main script

<body>
  <script src="changenowApi/changenowApi.js"></script>
  <script src="your-script.js"></script>
</body>  

Use cnApiWrapper function to interact with all available actions in API.
example:

  const response = await cnApiWrapper('CURRENCIES', { fixedRate: true });
  console.log(response);

or use callback:

  const callback = (response) => { console.log(response) };
  cnApiWrapper('CURRENCIES', { fixedRate: true }, callback);

Supported calls and parameters

Expected result Calls and parameters
List of all available currencies. callName - CURRENCIES
callParameters:
active - (Optional) Set true to return only active currencies (It's used for Standart flow).
fixedRate - (Optional) Set true to return only for the currencies available on a fixed-rate flow
List of available currencies for a specific currency. callName - CURRENCIES_TO
callParameters:
ticker - (Required) Currency ticker.
fixedRate - (Optional) Set true to return only for the currencies available on a fixed-rate flow
Currency info callName - CURRENCY_INFO
callParameters:
ticker - (Required) Currency ticker.
List of transactions callName - LIST_OF_TRANSACTIONS
callParameters:
apiKey - (Required) Partner public API key
from - (Optional) Set a ticker of a payin currency to filter transactions
to - (Optional) Set a ticker of a payout currency to filter transactions
status - (Optional) Set a transaction status (available statuses below) to filter transactions
limit - (Optional) Limit of transactions to return (default: 10)
offset - (Optional) Number of transactions to skip (default: 0)
dateFrom - (Optional) Sort transactions by the date of creation. This request returns all transactions created after the specified date. Format: YYYY-MM-DDTHH:mm:ss.sssZ
dateTo - (Optional) Sort transactions by the date of creation. This request returns all transactions created before the specified date. Format: YYYY-MM-DDTHH:mm:ss.sssZ
Transaction status callName - TX_STATUS
callParameters:
id - Transaction ID from Create transaction request
apiKey - (Required) Partner public API key
Estimated exchange amount callName - ESTIMATED
callParameters:
amount - Amount of funds you want to exchange.
from - Ticker of the currency you want to send
to - Ticker of the currency you want to receive
apiKey - (Required) Partner public API key
fixedRate - (Optional) Set true to return only for the currencies available on a fixed-rate flow
Create exchange transaction callName - CREATE_TX
callParameters:
apiKey - (Required) Partner public API key.
from - (Required) Ticker of a currency you want to send.
to - (Required) Ticker of a currency you want to receive.
address - (Required) Address to receive a currency.
amount - (Required) Amount you want to exchange.
extraId - (Optional) Extra ID for currencies that require it.
refundAddress - (Optional) Refund address.
refundExtraId - (Optional) Refund Extra ID.
userId - (Optional) Partner user ID.
payload - (Optional) Object that can contain up to 5 arbitrary fields up to 64 characters long.
contactEmail - (Optional) Your contact email for notification in case something goes wrong with your exchange
fixedRate - (Optional) Set true to return only for the currencies available on a fixed-rate flow
List of all available pairs callName - PAIRS
callParameters:
includePartners - Set false to return all available pairs, except pairs supported by our partners.
List of all available fixed rate pairs callName - FIXED_RATE_PAIRS
callParameters:
apiKey - (Required) Partner public API key
Minimal exchange amount callName - MIN_AMOUNT
callParameters:
from - Ticker of the currency you want to send.
to - Ticker of the currency you want to receive.

Full version of API documentation

All methods described here (API Documentation).

Any questions

If you would like to contribute code you can do so through GitHub by forking the repository and sending a pull request.

If you have any question create an issue.

License

Library are licensed under the GPL-3.0 License.

Enjoy!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published