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.


NFTs

/mint_nft

Mints a new NFT on a specified contract.

Method: POST

Standard NFT Minting

Param Description
token_id ID for new token you are minting
metadata Metadata for the new token as a string.
account_id Account ID for the new token owner.
seed_phrase OR private_key Seed phrase OR private key for the NFT contract.
nft_contract Account ID for the NFT contract your are minting on.

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

Example:

{
    "token_id": "EXAMPLE-TOKEN",
    "metadata": "https://ipfs.io/ipfs/Qme7ss3ARVgxv6rXqVPiikMJ8u2NLgmgszg13pYrDKEoiu",
    "account_id": "example.testnet",
    "private_key": "41oHMLtYygTsgwDzaMdjWRq48Sy9xJsitJGmMxgA9A7nvd65aT8vQwAvRdHi1nruPP47B6pNhW5T5TK8SsqCZmjn",
    "contract": "nft.example.near",
}

Example Response:

[
  {
    "token": {
      "owner_id": "example.testnet",
      "metadata": "https://ipfs.io/ipfs/Qme7ss3ARVgxv6rXqVPiikMJ8u2NLgmgszg13pYrDKEoiu",
      "approved_account_ids": [],
      "token_id": "EXAMPLE_TOKEN"
    },
    "tx": "Be7tV1h2dvhg53S2rartojeSUbNfQTB7ypuprmb6xRhw"
  }
]

Simple NFT Minting

Requires /init configuration with master account.

Example:

{
  "token_id": "EXAMPLE_TOKEN",
  "metadata": "https://ipfs.io/ipfs/Qme7ss3ARVgxv6rXqVPiikMJ8u2NLgmgszg13pYrDKEoiu"
}

Example Response:

[
  {
    "token": {
      "owner_id": "example.testnet",
      "metadata": "https://ipfs.io/ipfs/Qme7ss3ARVgxv6rXqVPiikMJ8u2NLgmgszg13pYrDKEoiu",
      "approved_account_ids": [],
      "token_id": "EXAMPLE_TOKEN"
    },
    "tx": "Be7tV1h2dvhg53S2rartojeSUbNfQTB7ypuprmb6xRhw"
  }
]

(tx is the transaction hash that can be queried in NEAR Explorer)


Batch NFT minting (simple)

Requires /init configuration with master account.

Example:

{
  "token_id": "EXAMPLE_TOKEN_{inc}",
  "metadata": "https://ipfs.io/ipfs/Qme7ss3ARVgxv6rXqVPiikMJ8u2NLgmgszg13pYrDKEoiu",
  "min": 31,
  "max": 33
}

_(This creates EXAMPLE_TOKEN_1, EXAMPLE_TOKEN_2, & EXAMPLE_TOKEN_3)_

Example Response:

[
  {
    "tx": "mAL92gb6g6hhubZBRewJk5vSwmmzm2SXmwdAfYqfWcG"
  },
  {
    "tx": "Dv9h8nWJLujkKpmw58ZR4QwAgPVprb4j5QarDUumoGEX"
  },
  {
    "tx": "J48F3vALJBbbUguKXp6e16g5vKVwzC2LtVBpsfEVFpYa"
  }
]

(Above response are transaction hashes that can be queried in NEAR Explorer)


/transfer_nft

_Transfers ownership of NFT from specified contract on behalf of provided enforce_owner_id signed with owner_private_key._

Method: POST

Standard Transfer NFT

Param Description
token_id Token ID of the token being transferred
receiver_id Account ID taking ownership of the NFT
enforce_owner_id Account ID for the account that currently owns the NFT.
memo Optional message to the new token holder.
owner_private_key _Private key of the enforce_owner_id._
nft_contract NFT contract that the token being transferred is on.

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

Example:

{
  "token_id": "EXAMPLE-TOKEN",
  "receiver_id": "receiver.testnet",
  "enforce_owner_id": "example.testnet",
  "memo": "Here's a token I thought you might like! :)",
  "owner_private_key": "YOUR_PRIVATE_KEY",
  "contract": "nft.example.near"
}

Example Response:

{
  "owner_id": "receiver.testnet",
  "metadata": "https://ipfs.io/ipfs/Qme7ss3ARVgxv6rXqVPiikMJ8u2NLgmgszg13pYrDKEoiu",
  "approved_account_ids": [],
  "tx": "5WdNgmNeA5UNpSMDRXemwJc95MB6J22LcvAaimuN5YzF"
}

(tx is the transaction hash that can be queried in NEAR Explorer)


Simple Transfer NFTs

Requires /init configuration with master account.

Param Description
token_id Token ID of the token being transferred
receiver_id Account ID taking ownership of the NFT
enforce_owner_id Account ID for the account that currently owns the NFT.
memo Optional message to new token holder.

Example:

{
  "token_id": "EXAMPLE-TOKEN",
  "receiver_id": "receiver.testnet",
  "enforce_owner_id": "example.testnet",
  "memo": "Here's a token I thought you might like! :)"
}

Example Response:

{
  "owner_id": "receiver.testnet",
  "metadata": "https://ipfs.io/ipfs/Qme7ss3ARVgxv6rXqVPiikMJ8u2NLgmgszg13pYrDKEoiu",
  "approved_account_ids": [],
  "tx": "5WdNgmNeA5UNpSMDRXemwJc95MB6J22LcvAaimuN5YzF"
}

(tx is the transaction hash that can be queried in NEAR Explorer)


view_nft

Standard View NFT

Returns owner, metadata, and approved account IDs for a given token ID.

Method: POST

Example:

{
  "token_id": "EXAMPLE-TOKEN",
  "contract": "nft.example.testnet"
}

Example Response:

{
  "owner_id": "example.testnet",
  "metadata": "https://ipfs.io/ipfs/Qme7ss3ARVgxv6rXqVPiikMJ8u2NLgmgszg13pYrDKEoiu",
  "approved_account_ids": []
}

Simple View NFT

Receive detailed information about NFT using URL params. Requires /init configuration with master account.

Example:

http://localhost:3000/view_nft/EXAMPLE-TOKEN

Example Response:

{
  "owner_id": "example.testnet",
  "metadata": "https://ipfs.io/ipfs/Qme7ss3ARVgxv6rXqVPiikMJ8u2NLgmgszg13pYrDKEoiu",
  "approved_account_ids": []
}

Scroll to Top