Skip to main content

NEAR API REST Server

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

ParamDescription
token_idID for new token you are minting
metadataMetadata for the new token as a string.
account_idAccount ID for the new token owner.
seed_phrase OR private_keySeed phrase OR private key for the NFT contract.
nft_contractAccount 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

ParamDescription
token_idToken ID of the token being transferred
receiver_idAccount ID taking ownership of the NFT
enforce_owner_idAccount ID for the account that currently owns the NFT.
memoOptional message to the new token holder.
owner_private_keyPrivate key of the enforce_owner_id.
nft_contractNFT 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.

ParamDescription
token_idToken ID of the token being transferred
receiver_idAccount ID taking ownership of the NFT
enforce_owner_idAccount ID for the account that currently owns the NFT.
memoOptional 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": []
}