### Install Poloniex.js via Git Clone Source: https://github.com/poloniex/poloniex.js/blob/master/README.md This sequence of commands clones the poloniex.js GitHub repository, changes the current directory to the repository folder, and installs the project dependencies using npm. This is an alternative installation method for developers cloning the source. ```Shell git clone https://github.com/poloniex/poloniex.js.git cd poloniex npm install ``` -------------------------------- ### Install Poloniex.js via NPM Source: https://github.com/poloniex/poloniex.js/blob/master/README.md This command installs the poloniex.js library as a dependency in your Node.js project using the npm package manager. It's the standard way to include the library in your project. ```Shell npm install poloniex.js ``` -------------------------------- ### Fetch Order Book for a Market (Public) Source: https://github.com/poloniex/poloniex.js/blob/master/README.md Invokes the public `returnOrderBook` method for a specific market pair (NXT/BTC in this example) to retrieve the list of open asks and bids. It demonstrates fetching data for a single market. ```JavaScript poloniex.returnOrderBook('NXT', 'BTC') .then(console.log) .catch(console.error); ``` -------------------------------- ### Fetch All Markets Ticker Data (Public) Source: https://github.com/poloniex/poloniex.js/blob/master/README.md Calls the public `returnTicker` method to retrieve the latest ticker information for all currency pairs on the Poloniex exchange. The example uses the Promise interface and logs the result or any error. ```JavaScript poloniex.returnTicker() .then(console.log) .catch(console.error); ``` -------------------------------- ### Fetch 24h Volume Data (Public) Source: https://github.com/poloniex/poloniex.js/blob/master/README.md Executes the public `return24hVolume` method to get the trading volume for the past 24 hours across all markets, including total volumes for primary currencies. The result is handled via Promises. ```JavaScript poloniex.return24hVolume() .then(console.log) .catch(console.error); ``` -------------------------------- ### Fetch Public Trade History (Public) Source: https://github.com/poloniex/poloniex.js/blob/master/README.md Calls the public `returnTradeHistory` method to get recent trade data for a specified market pair (BTC/ETH). By default, it returns the past 200 trades; date ranges can be specified with start/end timestamps. ```JavaScript poloniex.returnTradeHistory('BTC', 'ETH') .then(console.log) .catch(console.error); ``` -------------------------------- ### Fetch Private Trade History with Time Range (Private) Source: https://github.com/poloniex/poloniex.js/blob/master/README.md Invokes the authenticated `returnTradeHistory` method to retrieve your personal trade history for a market (NXT/BTC) within a specified time range using UNIX timestamps. The example fetches trades from the last hour. ```JavaScript poloniex.returnTradeHistory('NXT', 'BTC', Date.now() / 1000 - 60 * 60, Date.now() / 1000) .then(console.log) .catch(console.error) ``` -------------------------------- ### Placing a Limit Buy Order (Margin Context) via Poloniex API - JavaScript Source: https://github.com/poloniex/poloniex.js/blob/master/README.md This JavaScript snippet, found within the documentation for the `marginBuy` method, demonstrates placing a standard limit buy order using the `poloniex.buy` method. It specifies the currency pair, rate, and amount, using promise chaining (`.then`, `.catch`) to log the result or any errors from the API call. ```JavaScript poloniex.buy('NXT', 'BTC', 0.1, 100) .then(console.log) .catch(console.error) ``` -------------------------------- ### Placing a Limit Sell Order via Poloniex API - JavaScript Source: https://github.com/poloniex/poloniex.js/blob/master/README.md This JavaScript snippet demonstrates how to place a limit sell order using the Poloniex API client. It calls the `sell` method with currency pairs, rate, and amount, handling the asynchronous result with `.then()` for success and `.catch()` for errors, logging the outcome to the console. ```JavaScript poloniex.sell('NXT', 'BTC', 0.1, 100) .then(console.log) .catch(console.error); ``` -------------------------------- ### Make Poloniex API Call (Promise-based) Source: https://github.com/poloniex/poloniex.js/blob/master/README.md Demonstrates how to call any Poloniex API method using the client instance, handling the asynchronous response using a Promise. The `.then()` block processes successful responses, while `.catch()` handles errors. ```JavaScript poloniex.method(arg1, arg2) .then(function (data) { console.log(data) }) .catch(function (err) { console.error(err) }); ``` -------------------------------- ### Create Poloniex Client Instance (Public) Source: https://github.com/poloniex/poloniex.js/blob/master/README.md Instantiates a new Poloniex client object without providing API credentials. This instance can only be used to make public API calls that do not require authentication. ```JavaScript const poloniex = new Poloniex(); ``` -------------------------------- ### Create Poloniex Client Instance (Private) Source: https://github.com/poloniex/poloniex.js/blob/master/README.md Instantiates a new Poloniex client object with your API key and secret. This instance can be used to make both public and private (authenticated) API calls, including trading and account management functions. ```JavaScript const poloniex = new Poloniex('API_KEY', 'API_SECRET'); ``` -------------------------------- ### Import Poloniex.js Module (ES Modules) Source: https://github.com/poloniex/poloniex.js/blob/master/README.md This JavaScript code demonstrates how to import the Poloniex class using ES Module syntax, suitable for modern JavaScript environments and bundlers. ```JavaScript import Poloniex from 'poloniex.js'; ``` -------------------------------- ### Make Poloniex API Call (Callback-based) Source: https://github.com/poloniex/poloniex.js/blob/master/README.md Illustrates making a Poloniex API call using a traditional callback function as the last argument. The callback receives an error object (or null) and the response data. ```JavaScript poloniex.method(arg1, arg2, function (err, data) { ... }); ``` -------------------------------- ### Initiating a Withdrawal via Poloniex API - JavaScript Source: https://github.com/poloniex/poloniex.js/blob/master/README.md This JavaScript snippet illustrates how to request a withdrawal of a specific currency amount to a given address through the Poloniex API. The `withdraw` method is called with the currency, amount, and destination address, using promises (`.then`, `.catch`) to handle the API's response or report failures. ```JavaScript poloniex.withdraw('NXT', 2398, '17Hzfoobar') .then(console.log) .catch(console.error) ``` -------------------------------- ### Fetch Open Orders for a Market (Private) Source: https://github.com/poloniex/poloniex.js/blob/master/README.md Calls the authenticated `returnOpenOrders` method to retrieve your open orders for a specific market (NXT/BTC). Requires an authenticated client instance. Can fetch orders for 'all' markets if specified. ```JavaScript poloniex.returnOpenOrders('NXT', 'BTC') .then(console.log) .catch(console.error) ``` -------------------------------- ### Require Poloniex.js Module (CommonJS) Source: https://github.com/poloniex/poloniex.js/blob/master/README.md This JavaScript code shows how to require the Poloniex class using CommonJS syntax, typically used in Node.js environments. ```JavaScript const Poloniex = require('poloniex.js'); ``` -------------------------------- ### Canceling an Order via Poloniex API - JavaScript Source: https://github.com/poloniex/poloniex.js/blob/master/README.md This JavaScript snippet shows how to cancel an existing order on the Poloniex exchange. It invokes the `cancelOrder` method using the currency pair and the specific order number, chaining `.then()` and `.catch()` to process the API response or any errors encountered. ```JavaScript poloniex.cancelOrder('NXT', 'BTC', 170675) .then(console.log) .catch(console.error) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.