Skip to content

Requesting API Access

Gabrielle Zhou edited this page Oct 11, 2018 · 2 revisions

Access to some APIs may be restricted and requires login with username and passphrase.

In order to access the unrestricted state-less querying, we call make use of usual stateless RPC-calls. To access the restricted authencitated interaction we are required to use the websocket connection with callbacks to access them.

  • state-less querying: Database API, Account History API, Network Nodes API
  • authencitated interaction: Network Broadcast API

Requesting API Access

The full node offers a wide range of APIs that can be accessed via websockets. The procedure works as follows:

  1. Login to the Full Node
  2. Request access to an API
  3. Obtain the API identifier
  4. Call methods of a specific API by providing the identifier

Find below a list of available APIs:

  • Database API
  • Account History API
  • Network Broadcast API
  • Network Nodes API

1. Login

The first thing we need to do is to login:

> {"id":2,"method":"call","params":[1,"login",["",""]]}
< {"id":2,"result":true}

If you have restricted access then you may be required to put your username and pasword into the quotes, accordingly. Furthermore, you should verify, that the result give positive confirmation about your login.

2. Requesting Access to an API

Most data can be queried from the Database API-API to which we register with the following call:

> {"id":2,"method":"call","params":[1,"database",[]]}

3. Obtain the API identifier

After requesting access, the full node will either deny access or return an identifier to be used in future calls:

< {"id":2,"result":2}

The result will be our identifier for the database API, in the following called DATABASE_API_ID!

4. Call methods of a specific API by providing the identifier

Now we can call any methods available to the database API via:

> {"id":1, "method":"call", "params":[DATABASE_API_ID,"get_accounts",[["1.2.0"]]]}

Network Broadcast API

The network broadcast API is available from the full node via websockets.

Transactions

void graphene::app::network_broadcast_api::broadcast_transaction(const signed_transaction &trx)

Broadcast a transaction to the network.

The transaction will be checked for validity in the local database prior to broadcasting. If it fails to apply locally, an error will be thrown and the transaction will not be broadcast.

Parameters

trx: The transaction to broadcast

开发者社区

了解CYBEX

文档中心

DEVELOPERS

GETTING STARTED

DOCUMENTATION

Clone this wiki locally