Skip to content

algodex/algodex-sdk

@algodex/algodex-sdk

semantic-release

algodex/algodex-sdk:main

Client-side JavaScript API calls for Algodex as an npm package

Github

SDK Reference

Examples

Algodex Documentation

βš™ Getting Started

✨ Prerequisites

πŸ“¦ Installing

NPM

npm install @algodex/algodex-sdk

Yarn

yarn add @algodex/algodex-sdk

βš— Usage

πŸ”§ Configuration:

⚠ The API resources must be accessible with valid credentials (where necessary).

The SDK fetches data from the following API resources:

The service URIs, token, port are passed into the AlgodexAPI constructor. See API Properties for more information

βš™ Example Testnet config.json

{
  "config": {
    "algod": {
      "uri": "https://testnet-algorand.api.purestake.io/ps2",
      "token": "<TOKEN>"
    },
    "indexer": {
      "uri": "https://algoindexer.testnet.algoexplorerapi.io",
      "token": ""
    },
    "explorer": {
      "uri": "https://indexer.testnet.algoexplorerapi.io",
      "port": ""
    },
    "dexd": {
      "apiVersion": 2,
      "uri": "https://testnet.algodex.com/api/v2",
      "token": ""
    }
  }
}

βš™ Example Mainnet config.json

{
  "config": {
    "algod": {
      "uri": "https://mainnet-algorand.api.purestake.io/ps2",
      "token": "<TOKEN>"
    },
    "indexer": {
      "uri": "https://algoindexer.algoexplorerapi.io",
      "token": ""
    },
    "explorer": {
      "uri": "https://indexer.algoexplorerapi.io",
      "port": ""
    },
    "dexd": {
      "apiVersion": 2,
      "uri": "https://app.algodex.com/api/v2",
      "token": ""
    }
  }
}

πŸ— Constructing

 const config = require('./config.json')
 const AlgodexAPI = require('@algodex/algodex-sdk')
 const api = new AlgodexAPI(config)

πŸ’± Placing Orders:

πŸ’‘οΈ We recommend reading the following links before placing your first order: Maker Order | Taker Order | Orderbook

Maker Buy Order

// Configure wallet
api.setWallet({
  "type": "sdk",
  "address": "WYWRYK42XADLY3O62N52BOLT27DMPRA3WNBT2OBRT65N6OEZQWD4OSH6PI",
  "connector": require('@algodex/algodex-sdk/lib/wallet/connector/AlgoSDK'),
  "mnemonic": "Your 25 word mneumonic goes here"
})


// Placing an Order
const orders = await api.placeOrder({
  "asset": {
    "id": 15322902, // Asset Index
    "decimals": 6, // Asset Decimals
  },
  "address": "WYWRYK42XADLY3O62N52BOLT27DMPRA3WNBT2OBRT65N6OEZQWD4OSH6PI",
  "price": 2.22, // Price in ALGOs
  "amount": 1, // Amount to Buy or Sell
  "execution": "maker", // Type of exeuction
  "type": "buy", // Order Type
})

// Closing an Order
await api.closeOrder(orders[0])

πŸ“š Documentation

All available execution types are found in the Place Order Tutorial

🏘 Community

πŸ•Έ Links

About

Client-side JavaScript SDK for Algodex as an npm package

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •