# Node API

Alcor Exchange provides an API for the UI view reasons charts/lates deals/orderbook. etc. But any intereation with blockchain, such as new order or order cancel, we have to work with blockchain now api directly, here we will provide some examples.

We will use EosJS lib to interact with node api. And will use WAX blockchain as example.

#### Submit new order.

```
// Code not tested yet, and provided for explanation reason

import fetch from 'node-fetch'
import { Api, JsonRpc, RpcError, JsSignatureProvider } from 'eosjs'

const rpc = new JsonRpc('https://wax.greymass.com', { fetch })
const signatureProvider = new JsSignatureProvider(['private key of order owner'])
const api = new Api({ rpc, signatureProvider, textDecoder: new TextDecoder(), textEncoder: new TextEncoder() });

// Place buy limit order, buying 1000 TLM for 10 WAX
const objTrans = [{
  account: 'eosio', // token contract
  name: 'transfer',
  authorization: [{
    actor: 'useraaaaaaaa', // account placing order (owner)
    permission: 'active',
  }],
  data: {
    from: 'useraaaaaaaa',
    to: 'alcordexmain',
    quantity: `10.0000 WAX`,
    memo: `1000.0000 TLM@alien.worlds`
  }
}]

// Result of transaction
const r = await api.transact(objTrans, { blocksBehind: 3, expireSeconds: 30})
```

#### **Get order from contract table.**

```
// Code not tested yet, and provided for explanation reason

import fetch from 'node-fetch'
import { Api, JsonRpc, RpcError } from 'eosjs'

const rpc = new JsonRpc('https://wax.greymass.com', { fetch })

// Get buy orderbook from conract table

const { rows } = await rpc.get_table_rows({
  code: 'alcordexmain',
  table: 'buyorder',
  limit: 1000,
  scope: 29, // Market id from /api/markets
  key_type: 'i128', // we are using it for getting order sorted by price.
  index_position: 2
})

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.alcor.exchange/developers-api/api/node-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
