Public API

Anyone can integrate nanote with their apps!

Table of Contents

Getting Started

 

So you want to use nanote in your own application? Sounds great! You are in the right place to get started.

You have two options for using nanote:

  1. npmjs package (also available on GitHub)
  2. A hosted RESTful API

If you are interested in the npmjs package, I recommend you visit the GitHub or npmjs site linked above as all the needed documentation is there.

If you are interested in using the RESTful API hosted on this site, keep reading.

But before we begin, if you have not yet read about how nanote works, I recommend you do so before digging into the API.


nanote API

The nanote API is the RESTful API for the npmjs package. It is simple input/output. It relies on no external data sources. I make it available so that if you want to create a serverless application, you have a place to use the npmjs functionality. It is possible to Browserify the npmjs package. However, I use the BigInt built-in object  which is not widely supported by browsers (but is supported by Node.js).

Encode

/api/encode/:message

Encodes given :message. If success is not true, an error message will be populated.

Example Input: /api/encode/hello,%20world!

Example Output:

{
  "decoded":"hello, world!",
  "encoded":"0.000102182701366461085457178942",
  "charset":" etaoinsrhldcumfpgw~!@#$%&*()-_+=,.",
  "error":"",
  "success":true,
  "nanote_version":"0.3.0"
}

Decode

/api/decode/:amount

Decodes given :amount. If success is not true, an error message will be populated.

Example Input: /api/decode/0.000102182701366461085457178942

Example Output:

{
  "decoded":"hello, world!",
  "encoded":"0.000102182701366461085457178942",
  "charset":" etaoinsrhldcumfpgw~!@#$%&*()-_+=,.",
  "error":"",
  "success":true,
  "nanote_version":"0.3.0"
}

Valid Characters

/api/valid_chars

Returns string of valid characters. Only these characters are supported by the nanote protocol. If any invalid character is included in an attempt to encode, an error will be returned. If success is not true, an error message will be populated.

Example Input: /api/valid_chars

Example Output:

{
  "valid_chars":" etaoinsrhldcumfpgwybvkxjqz1234567890~!@#$%&*()-_+=,.?/<>;:[]'",
  "success":true,
  "nanote_version":"0.3.0"
}

nanote Data API

The nanote Data API should be relied upon with caution. While the above nanote API is resilient and built to not be reliant on external data sources, the nanote Data API is reliant on external data sources. I maintain a database of nanote messages and this portion of the Public API queries that database. As the protocol changes I will make all reasonable attempts to retain backwards compatibility. But I can not guarantee that. This portion of the API is ultimately for me to run this site, not really meant for external use. But as it is readonly, there is no good reason for me to keep it to myself completely.

User

/api/user/:user

Returns data about the give user (Nano Account)

Example Input: /api/user/xrb_1nanoteiu8euwzrgqnn79c1fhpkeuzi4b4ptogoserckbxkw15dma6dg5hb5

{
  "success":true,
  "account":"xrb_1nanoteiu8euwzrgqnn79c1fhpkeuzi4b4ptogoserckbxkw15dma6dg5hb5",
  "alias":"nanote",
  "website":"https://nanote.io",
  "verified":true,
  "avatar":"https://robohash.org/set_set4/bgset_bg2/xrb_1nanoteiu8euwzrgqnn79c1fhpkeuzi4b4ptogoserckbxkw15dma6dg5hb5-963501?size=60x60",
  "donation":10
}

Sender

/api/sender/:account

Returns 50 most recent nanotes sent from the given account. Also returns user data associate with the blocks. If an account has not configured an alias, website, or new avatar, their account is not stored in the database and will not be returned with the block.

Important to note that this tracks blocks sent from the account, not the block created by the account for the receive of the transaction. This allows messages to be tracked by nanote once someone sends the transaction without having to wait for the recipient to receive.

Example Input: /api/sender/xrb_3xd9a3wne1hxbowk7x1ykzpwx5coo1of8h467jya77cttjohwug6sjxpam7x

Example Output:

{
  "success":true,
  "blocks":
    [
      {
        "hash":"CB604C2C894366425E7ED151A8B7D644A596B6A3C345C2619470D852CE515307",
        "account_from":"xrb_3xd9a3wne1hxbowk7x1ykzpwx5coo1of8h467jya77cttjohwug6sjxpam7x",
        "account_to":"xrb_1i7naoiazr8u3sxsw3y5fbo5oefjm5rht1rnwrxoyg9hr3418f8gza5fbfdk",
        "message":"v0.3.0 work?",
        "date_created":"2019-03-05T02:55:04.988Z",
        "amount":"0.000124599222446060048060429987",
        "nanote_version":"0.3.0"
      }
    ],
  "users":
    {
      "xrb_3xd9a3wne1hxbowk7x1ykzpwx5coo1of8h467jya77cttjohwug6sjxpam7x":{
        "alias":"test alias",
        "website":"https://nanote.io",
        "verified":false,
        "avatar":"https://robohash.org/set_set4/bgset_bg2/xrb_3xd9a3wne1hxbowk7x1ykzpwx5coo1of8h467jya77cttjohwug6sjxpam7x-954821?size=60x60",
        "donation": 0
        }
    }
}

Receiver

/api/receiver/:account

Returns 50 most recent nanotes sent to the given account. Also returns user data associate with the blocks. If an account has not configured an alias, website, or new avatar, their account is not stored in the database and will not be returned with the block.

Important to note that this tracks blocks sent to the account, not the block created by the account for the receive of the transaction. This allows messages to be tracked by nanote once someone sends the transaction without having to wait for the recipient to receive.

Example Input: /api/receiver/xrb_1i7naoiazr8u3sxsw3y5fbo5oefjm5rht1rnwrxoyg9hr3418f8gza5fbfdk

Example Output:

{
  "success":true,
  "blocks":
    [
      {
        "hash":"CB604C2C894366425E7ED151A8B7D644A596B6A3C345C2619470D852CE515307",
        "account_from":"xrb_3xd9a3wne1hxbowk7x1ykzpwx5coo1of8h467jya77cttjohwug6sjxpam7x",
        "account_to":"xrb_1i7naoiazr8u3sxsw3y5fbo5oefjm5rht1rnwrxoyg9hr3418f8gza5fbfdk",
        "message":"v0.3.0 work?",
        "date_created":"2019-03-05T02:55:04.988Z",
        "amount":"0.000124599222446060048060429987",
        "nanote_version":"0.3.0"
      }
    ],
  "users":
    {
      "xrb_3xd9a3wne1hxbowk7x1ykzpwx5coo1of8h467jya77cttjohwug6sjxpam7x":{
        "alias":"test alias",
        "website":"https://nanote.io",
        "verified":false,
        "avatar":"https://robohash.org/set_set4/bgset_bg2/xrb_3xd9a3wne1hxbowk7x1ykzpwx5coo1of8h467jya77cttjohwug6sjxpam7x-954821?size=60x60",
        "donation": 0
        }
    }
}

Block

/api/block/:hash

Returns data of the block as identified by the given hash. Also returns user data associate with the block. If an account has not configured an alias, website, or new avatar, their account is not stored in the database and will not be returned with the block.

Example Input: /api/block/CB604C2C894366425E7ED151A8B7D644A596B6A3C345C2619470D852CE515307

Example Output:

{
  "success":true,
  "hash":"CB604C2C894366425E7ED151A8B7D644A596B6A3C345C2619470D852CE515307",
  "account_from":"xrb_3xd9a3wne1hxbowk7x1ykzpwx5coo1of8h467jya77cttjohwug6sjxpam7x",
  "account_to":"xrb_1i7naoiazr8u3sxsw3y5fbo5oefjm5rht1rnwrxoyg9hr3418f8gza5fbfdk",
  "message":"v0.3.0 work?",
  "date_created":"2019-03-05T02:55:04.988Z",
  "amount":"0.000124599222446060048060429987",
  "nanote_version":"0.3.0",
  "users":
    {
      "xrb_3xd9a3wne1hxbowk7x1ykzpwx5coo1of8h467jya77cttjohwug6sjxpam7x":{
        "alias":"test alias",
        "website":"https://nanote.io",
        "verified":false,
        "avatar":"https://robohash.org/set_set4/bgset_bg2/xrb_3xd9a3wne1hxbowk7x1ykzpwx5coo1of8h467jya77cttjohwug6sjxpam7x-954821?size=60x60",
        "donation": 0
        }
    }
}

Recent

/api/recent

Returns 20 most recent nanotes regardless of account. Important to note that this tracks blocks that send an amount, not the block created by the account for the receive of the transaction. This allows messages to be tracked by nanote once someone sends the transaction without having to wait for the recipient to receive.

Does not return user data for blocks.

Example Input: /api/recent

Example Output:

{
  "success":true,
  "blocks":
    [
      {
        "hash":"CB604C2C894366425E7ED151A8B7D644A596B6A3C345C2619470D852CE515307",
        "account_from":"xrb_3xd9a3wne1hxbowk7x1ykzpwx5coo1of8h467jya77cttjohwug6sjxpam7x",
        "account_to":"xrb_1i7naoiazr8u3sxsw3y5fbo5oefjm5rht1rnwrxoyg9hr3418f8gza5fbfdk",
        "message":"v0.3.0 work?",
        "date_created":"2019-03-05T02:55:04.988Z",
        "amount":"0.000124599222446060048060429987",
        "nanote_version":"0.3.0"
      }
    ]
}