NEAR API REST Server

To Share and +4 nLEARNs

NEAR REST API Server is a project that allows you create your own simple REST API server that interacts with the NEAR blockchain.


Utils

/init

Configures near-api-server.config.json and creates a master account that stores credentials in this file. This allows for "simple methods" to be called where you won’t have to pass as many parameters, primarily the master account id and private key or seed phrase.

ATTN: SERVER MUST BE RESTARTED AFTER CALLING THIS ENDPOINT

Method: POST

Param Description
master_account_id Master account that has full access to the NFT contract below
seed_phrase OR private_key Seed phrase OR private key of the account id above.
nft_contract Contract account that has NFT contract deployed to it
server_host Public IP address for your API server (localhost is default)
server_port (Port your API server will listen on)
rpc_node Network your server will be running on (testnet, mainnet, or betanet)

Note: Use near login to save your key pair to your local machine.

Example:

{
  "master_account_id": "example.testnet",
  "seed_phrase": "seed phrase for master_account_id goes here",
  "nft_contract": "nft-contract.example.testnet",
  "server_host": "localhost",
  "server_port": 3000,
  "rpc_node": "https://rpc.testnet.near.org"
}

Example Response:

{
  "text": "Settings updated."
}

/create_user

Creates a NEAR sub-account using initialized master account and saves credentials to /storage directory. Requires /init configuration with master account.

Note: Only letters, digits, and – or _ separators are allowed.

Method: POST

Example:

{
    "name" : "satoshi"
}

Example Response:

{
  "text": "Account satoshi.example.testnet created. Public key: ed25519:HW4koiHqLi5WdVHWy9fqBWHbLRrzfmvCiRAUVhMa14T2"
}

/parse_seed_phrase

Converts seed phrase into public / private key pair.

Method: POST

Example:

{
    "seed_phrase" : "witch collapse practice feed shame open despair creek road again ice least"
}

Example Response:

{
    "seedPhrase": "witch collapse practice feed shame open despair creek road again ice least",
    "secretKey": "ed25519:41oHMLtYygTsgwDzaMdjWRq48Sy9xJsitJGmMxgA9A7nvd65aT8vQwAvRdHi1nruPP47B6pNhW5T5TK8SsqCZmjn",
    "publicKey": "ed25519:Cgg4i7ciid8uG4K5Vnjzy5N4PXLst5aeH9ApRAUA3y8U"
}

Generate comment with AI 2 nL
Scroll to Top
Report a bug👀