# NFT API -- [draft document]
###### tags: `ERC721 token` `ERC5511 token`
# Table of Contents
[toc]
## Main configuration(.env)
| Attribute | Description | Example |
| --------- | ----------- | ------- |
DATABASE_TYPE | Database type | postgres |
| POSTGRES_HOST | database host | localhost |
| POSTGRES_PORT | database port | 5432 |
| POSTGRES_USER | database username | postgres |
| POSTGRES_PASSWORD | database password | mysecretpassword |
| POSTGRES_DATABASE | databse name | postgres |
## NFT MAIN APIs
Manage users accounts as described below:
**Endpoint` /users`**
* Method: `post`
[Request]
```JSON
{
"address":"address",
"firstname": "string",
"lastname": "string;",
"email":"string",
"username":"string;"
}
```
[Response]
```JSON
{
"address": "0x20c558DD389b101e4141f2Aa59209FB11c944d06",
"firstname": "string",
"lastname": "string;",
"email": "string@test.com",
"username": "string;",
"id": "3fd84b5a-71bc-4ee9-8e0c-a0e0252bdaa3"
}
```
* Method: `get`
[Request]
```JSON
{
}
```
[Response]
```JSON
[
{
"id": "32b2aa13-d000-4a16-8121-f6c2c8a3f15a",
"address": "0x20c558DD389b101e4141f2Aa59209FB11c944d06",
"firstname": "string",
"lastname": "string;",
"username": "string;",
"email": "string@test.com"
}
]
```
### IPFS api
this endpoint save connected user settings as below
**Endpoint `/ipfs`**
* Method: `post`
[Request]
```JSON
{
"name":"string",
"description":"string",
"file": "base64"
}
```
[Response]
```URL
https://ipfs.io/QmZJ35GLCPebwujbTRpPUypRiBB26PSJiLF6ZudjF5njKF
```
* Method: `get /ipfs/{hash}`
Body:
```JSON
{
"name":"name",
"description":"description",
"file": "base64"
}
```
Result:
```
boolean
```
### NFT api
**Endpoint: `/nfts`**
* Method: `post`
[Request]
```JSON
{
"token_id":"string",
"uri": "ipfs/hash",
"contract_type": "string",
"for_sell": "boolean",
"owner_address": "address",
"collection": "address",
"sold": "number",
"supply": "number",
"value": "number"
}
```
[Response]
```JSON
{
"token_id": "111111",
"uri": "ipfs/2384982749872984",
"contract_type": "ERC721",
"for_sell": false,
"owner_address": "0x20c558DD389b101e4141f2Aa59209FB11c944d06",
"collection": "0x20c558DD389b101e4141f2Aa59209FB11c944d06",
"sold": 4,
"supply": 41,
"id": "304e93c3-78d3-4bd7-87df-34303cce50b9",
"value": 0
}
```
* Method: `put`
[Request]
```JSON
{
"token_id": "111111",
"owner_address": "0x20c558DD389b101e4141f2Aa59209FB11c944d06",
"collection": "0x20c558DD389b101e4141f2Aa59209FB11c944d06",
"id": "304e93c3-78d3-4bd7-87df-34303cce50b9",
"value": 41
}
```
[Response]
```JSON
{
"generatedMaps": [],
"raw": [],
"affected": 1
}
```
* Method: `get /nfts`
[Request]
```JSON
{
}
```
[Response]
```JSON
[
{
"id": "e6c006b2-f561-42d1-bc54-2d0b8d67e635",
"token_id": "94582853440569721971258064241134716640749172105768608110743273546248617990",
"value": 0,
"uri": "https://ipfs.io/QmbvE5GN2oXwj5KC4eKB4fttfJer9pm3RffJ6PxXDMcaUk",
"contract_type": "ERC721",
"collection": "",
"for_sell": false,
"owner_address": "0x00358831046eA4a9c2d10B2d362535441A35A4da",
"sold": 0,
"supply": 0
}
]
```
* Method: `get /nfts/{owner address}`
[Request]
```JSON
{
}
```
[Response]
```JSON
[
{
"id": "e6c006b2-f561-42d1-bc54-2d0b8d67e635",
"token_id": "94582853440569721971258064241134716640749172105768608110743273546248617990",
"value": 0,
"uri": "https://ipfs.io/QmbvE5GN2oXwj5KC4eKB4fttfJer9pm3RffJ6PxXDMcaUk",
"contract_type": "ERC721",
"collection": "",
"for_sell": false,
"owner_address": "0x00358831046eA4a9c2d10B2d362535441A35A4da",
"sold": 0,
"supply": 0
}
]
```
### Offer api
**Endpoint: `/offers`**
* Method: `post`
[Request]
```JSON
{
"seller":"address",
"collection": "address",
"assetId":"number",
"token": "address",
"isEther": true,
"price":"number",
"isForSell":"boolean",
"isForAuction":"boolean",
"expiresAt": "number",
"isSold": "boolean",
"nft_id":"e6c006b2-f561-42d1-bc54-2d0b8d67e635"
}
```
[Response]
```JSON
{
"seller": "sfdsf",
"collection": "fffff",
"assetId": "dsfdsfs",
"token": "string",
"isEther": true,
"price": 200,
"isForSell": true,
"isForAuction": false,
"expiresAt": 323232,
"isSold": false,
"nft_id": "e6c006b2-f561-42d1-bc54-2d0b8d67e635",
"nft": {
"id": "e6c006b2-f561-42d1-bc54-2d0b8d67e635"
},
"id": "8303c88d-4b16-4ef6-b3d6-757fc962b7d9",
"offer_id": 0,
"createdAt": "1620838140691",
"updatedAt": "1620838140691"
}
```
* Method: `put`
[Request]
```JSON
{
"seller": "address",
"collection": "address",
"assetId": "string",
"token": "address",
"isEther": "boolean",
"price": "number",
"isForSell": "boolean",
"isForAuction": "boolean",
"expiresAt": "number",
"isSold": "boolean",
"id": "number",
"offer_id": "number"
}
```
[Response]
```JSON
{
"generatedMaps": [],
"raw": [],
"affected": 1
}
```
* Method: `delete /offers`
[Request]
```JSON
{
id:number
}
```
[Response]
```JSON
{}
```
* Method: `get /nfts`
[Request]
```JSON
{
}
```
[Response]
```JSON
[
{
"id": "70caceca-da72-4017-a671-242baead39c6",
"offer_id": 0,
"seller": "sfdsf",
"collection": "fffff",
"assetId": "dsfdsfs",
"token": "string",
"isEther": true,
"price": 200,
"isForSell": true,
"isForAuction": false,
"expiresAt": 323232,
"isSold": false,
"createdAt": "1620770391318",
"updatedAt": "1620770391318",
"bids": [
{
"id": "a6017447-aa2d-421d-a552-c4cd4a5ba5f7",
"bidder": "sfdsf",
"token": "skjdhfk",
"price": 12,
"expiresAt": "89289738293",
"createdAt": "1620805775906",
"updatedAt": "1620805775906"
}
]
},
{
"id": "30e23d7a-517f-4954-9dc9-ad8709446ec0",
"offer_id": 0,
"seller": "sfdsf",
"collection": "fffff",
"assetId": "dsfdsfs",
"token": "string",
"isEther": true,
"price": 200,
"isForSell": true,
"isForAuction": false,
"expiresAt": 323232,
"isSold": false,
"createdAt": "1620770391318",
"updatedAt": "1620770391318",
"bids": []
}
]
```
* Method: `get /offers/getbynft/{nft id}`
[Request]
```JSON
{
}
```
[Response]
```JSON
[
{
"id": "8303c88d-4b16-4ef6-b3d6-757fc962b7d9",
"offer_id": 0,
"seller": "sfdsf",
"collection": "fffff",
"assetId": "dsfdsfs",
"token": "string",
"isEther": true,
"price": 200,
"isForSell": true,
"isForAuction": false,
"expiresAt": 323232,
"isSold": false,
"createdAt": "1620838140691",
"updatedAt": "1620838140691",
"bids": [
{
"id": "27573591-e968-4474-8bae-8127f9c4df26",
"bidder": "sfdsf",
"token": "skjdhfk",
"price": 12,
"expiresAt": "89289738293",
"createdAt": "1620838140690",
"updatedAt": "1620838140690"
}
]
}
]
```
### Bid api
**Endpoint: `/bids`**
* Method: `post`
[Request]
```JSON
{
"bidder":"string",
"price":number,
"token":"string",
"offer_id":"number",
"expiresAt":"number"
}
```
[Response]
```JSON
{
"bidder": "sfdsf",
"price": 12,
"token": "skjdhfk",
"offer": {
"id": "8303c88d-4b16-4ef6-b3d6-757fc962b7d9"
},
"expiresAt": 89289738293,
"id": "27573591-e968-4474-8bae-8127f9c4df26",
"createdAt": "1620838140690",
"updatedAt": "1620838140690"
}
```
* Method: `put`
[Request]
```JSON
{
"price": 12,
"id": "27573591-e968-4474-8bae-8127f9c4df26"
}
```
[Response]
```JSON
{
"generatedMaps": [],
"raw": [],
"affected": 1
}
```
* Method: `get /bids`
[Request]
```JSON
{
}
```
[Response]
```JSON
[
{
"id": "a6017447-aa2d-421d-a552-c4cd4a5ba5f7",
"bidder": "sfdsf",
"token": "skjdhfk",
"price": 12,
"expiresAt": "89289738293",
"createdAt": "1620805775906",
"updatedAt": "1620805775906"
},
{
"id": "27573591-e968-4474-8bae-8127f9c4df26",
"bidder": "sfdsf",
"token": "skjdhfk",
"price": 12,
"expiresAt": "89289738293",
"createdAt": "1620838140690",
"updatedAt": "1620838140690"
}
]
```
* Method: `delete /bids`
[Request]
```JSON
{
id:number
}
```
[Response]
```JSON
{}
```
* Method: `get /bids/{bidder address}`
[Request]
```JSON
{
}
```
[Response]
```JSON
[
{
"id": "a6017447-aa2d-421d-a552-c4cd4a5ba5f7",
"bidder": "sfdsf",
"token": "skjdhfk",
"price": 12,
"expiresAt": "89289738293",
"createdAt": "1620805775906",
"updatedAt": "1620805775906"
},
{
"id": "27573591-e968-4474-8bae-8127f9c4df26",
"bidder": "sfdsf",
"token": "skjdhfk",
"price": 12,
"expiresAt": "89289738293",
"createdAt": "1620838140690",
"updatedAt": "1620838140690"
}
]
```