npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

orionx-sdk

v2.0.0-rc8

Published

Official Orionx SDK for Node.js

Downloads

110

Readme


Usage

First you need to install it via npm.

npm install orionx-sdk --save

Then you will need to get your credentials, follow this tutorial

After that we are ready to go

Code examples

How to initialize SDK

// App.ts
import { Orionx } from 'orionx-sdk';

const apiKey = 'your-api-key';
const secretKey = 'your-secret-key';

export const orionx = new Orionx(
  apiKey,
  secretKey,
  'https://api.orionx.com/graphql'
);

Methods

User:

This interface represents the structure of the User object, which contains details about the currently authenticated user, including their basic information and profile data.

const me = await orionx.user.getMe();

// Example response:

{
  _id: 'userId',
  email: '[email protected]',
  name: 'Test User',
  profile: {
    fullName: 'Test Orionx User',
    phone: '+569 88888888',
    kycVerified: true,
    birthdate: '01/30/2000',
    countryCode: 'CL',
    occupation: 'Developer',
    address: 'Independencia 2404'
  }
}

Markets:

Obtain the OrderBook of a marketplace in Orionx

This method allows you to obtain the order book (OrderBook) for a specific market in Orionx. The order book includes both buy and sell orders, as well as a calculation of the spread and average price.

const marketCode = "BTCCLP"; // Market code to be consulted
const resultLimit = 25; // Number of orders to obtain (optional). The default value is 50 if not specified.

const orderBook = await orionx.markets.getOrderBook(marketCode, resultLimit);

// Example response:

{
  "sell": [
    { "amount": 500000, "limitPrice": 70000000 },
    { "amount": 12000, "limitPrice": 69500000 }
  ],
  "buy": [
    { "amount": 30000, "limitPrice": 67000000 },
    { "amount": 8000, "limitPrice": 65000000 }
  ],
  "spread": 2500000,
  "mid": 67850000
}

Market Information

This interface represents the structure of a Market object, which contains details about a specific market, such as its code, name, and currency information, as well as the most recent trade.

const marketCode = "USDTCLP"; // Market code to be consulted
const market = await orionx.markets.getMarket(marketCode);

// Example response:

{
  code: 'BTCCLP',
  name: 'BTC/CLP',
  mainCurrency: { code: 'BTC', name: 'Bitcoin', units: 8 },
  secondaryCurrency: { code: 'CLP', name: 'Pesos chilenos', units: 0 },
  lastTrade: { price: 70000000 }
}

Accounts:

This interface represents the structure of an Account object, which provides details about a specific account, including balance information, currency, and available networks for transactions.

const currencyCode = "BTC" // The code representing the currency (e.g., "BTC", "CLP").
const account = await orionx.accounts.getAccount(currencyCode);

// Example response:

{
  _id: 'accountId',
  currency: { code: 'ETH', units: 8 },
  balance: 100000, // 0.001 ETH
  availableBalance: 100000, // 0.001 ETH
  availableNetworks: [ { code: 'ETH' }, { code: 'ETHTN' } ],
  balanceUSD: 2.3,
  balanceCLP: 2000
}

Alternatively you can request the information of all the accounts associated to your user with the getAccounts method. This method returns an array of Account types.

const accounts = await orionx.accounts.getAccounts();

// Example response:
[
  {
    _id: 'accountId',
    currency: { code: 'DAI', units: 8 },
    balance: 0,
    availableBalance: 0,
    availableNetworks: [ [Object] ],
    balanceUSD: 0,
    balanceCLP: 0
  },
  {
    _id: 'accountId',
    currency: { code: 'ETH', units: 8 },
    balance: 0,
    availableBalance: 0,
    availableNetworks: [ [Object], [Object] ],
    balanceUSD: 0,
    balanceCLP: 0
  },
  ... more accounts ...
]

Orders:

Create new Limit Order

This interface represents the structure of a PlaceLimitOrder object, which contains details about a limit order placed on a market, including the order's type, amount, price, and status.

const limitPrice = 72000000 // Order Limit Price
const market = 'BTCCLP' // Market code
const sell = true // Wether is sell or buy order
const amount = 10000 // Amount of the order
const order = await orionx.orders.placeLimitOrder(market, amount, limitPrice, sell)

// Example response:

{
  _id: 'orderId',
  type: 'limit',
  amount: 10000,
  limitPrice: 72000000,
  status: 'open',
  createdAt: 1726071616518,
  market: { code: 'BTCCLP' },
  clientId: null
}

Create new Market Order

This interface represents the structure of a PlaceMarketOrder object, which contains details about a limit order placed on a market, including the order's type, amount, and status.

const market = 'ETHCLP' // Market code
const sell = false // Wether is sell or buy order
const amount = 10000 // Amount of the order
const order = await orionx.orders.placeMarketOrder(market, amount, limitPrice, sell)

// Example response:

{
  _id: 'orderId',
  type: 'market',
  amount: 10000,
  limitPrice: null,
  status: 'closed',
  createdAt: 1726068320271,
  market: { code: 'ETHCLP' },
  clientId: null
}

Create new Stop Limit Order

This interface represents the structure of a StopLimitOrder object, which contains details about a limit order placed on a market, including the order's type, amount, and status.

const market = 'BTCCLP' // Market code
const triggerPriceUp = 72000000 // Upper price to trigger limit order
const triggerDownPrice = 65000000 // Lower price to trigger limit order
const amount = 15000 // Amount of the order
const limitPrice = 75000000 // Limit order price to be created when any of the trigger conditions are met
const sell = true // Wether is sell or buy order

const order = await orionx.orders.placeStopLimitOrder(market, triggerPriceUp, triggerDownPrice, amount, limitPrice, sell)

// Example response:

{
  _id: 'orderId',
  type: 'limit',
  amount: 15000,
  limitPrice: 75000000,
  status: 'stop',
  createdAt: 1726071893318,
  market: { code: 'BTCCLP' },
  clientId: null
}

Cancel an open order

This interface represents the structure of a Canceled Order object, which contains details about a canceled order, including the order's type.

const orderId = "6789qwer"
const cancelOrder = await orionx.orders.cancelOrder(orderId)

// Example response:

{
  _id: 'orderId',
  type: 'limit',
  status: 'canceled',
  clientId: null
}

Transactions

Send

This interface represents the structure of a Send object, which contains details about a send transaction, including the transaction's id, amount and date.

const walletId = "2345yuiop" // You can get it with getAccount method
const network = "ETH"
const amount = 1000000
const contactId = "uuid-contact-id"
const transaction = await orionx.transactions.send(walletId, network, amount, contactId)

// Example response:

{
  _id: 'transactionId',
  type: 'send',
  amount: 1500000,
  price: null,
  hash: null,
  date: 1726072591707,
  market: null,
  meta: null
}

Get Transaction Details

This interface represents the structure of a Transaction object, which contains details about a transaction, including the transaction's type, amount, market and cost.

const transactionId = "xzcvb6789"
const transaction = await orionx.transactions.getTransaction(transactionId)

// Example response:

{
  _id: 'transactionId',
  amount: 544746,
  balance: 500000000,
  commission: 0,
  currency: { code: 'CLP', units: 0 },
  date: 1722486341664,
  type: 'trade-out',
  adds: false,
  hash: null,
  description: null,
  market: {
    code: 'BTCCLP',
    mainCurrency: { code: 'BTC', units: 8 },
    secondaryCurrency: { code: 'CLP', units: 0 }
  },
  price: 68000000,
  cost: 797000,
  explorerURL: null,
  isInside: null,
  meta: null
}

Alternatively you can request the information of all the transactions associated to your user with the getTransactions method. This method returns an array of Transaction types.

Note: Sending an object with filters is optional. You can call the getTransactions method without parameters to get all the results.

const transactions = await orionx.accounts.getTransactions({
  walletId: "my-wallet-id",
  types: ["receive", "revert"],
  page: 2,
  limit: 4,
  sortType: "DESC"
});

// Example response:
[
    {
      amount: 49750,
      balance: 999500,
      commission: 250,
      currency: { "code": "BTC", "units": 8 },
      date: 1726065370624,
      type: 'receive',
      adds: true,
      hash: null,
      description: null,
      market: {
        "code": "BTCCLP",
        "mainCurrency": { "code": "BTC", "units": 8 },
        "secondaryCurrency": { "code": "CLP", "units": 0 }
      },
      price: null,
      cost: 49750,
      explorerURL: null,
      isInside: null,
      meta: null
    },
    {
      amount: 50000,
      balance: 999500,
      commission: 0,
      currency: { "code": "ETH", "units": 8 },
      date: 1726065374255,
      type: 'revert',
      adds: false,
      hash: null,
      description: null,
      market: {
        "code": "ETHCLP",
        "mainCurrency": { "code": "ETH", "units": 8 },
        "secondaryCurrency": { "code": "CLP", "units": 0 }
      },
      price: null,
      cost: null,
      explorerURL: null,
      isInside: null,
      meta: null
    },
  ... more transactions ...
]