# BRC-20 API

## Introduction

### Return Parameters

The request return parameters:

| Parameter | Type   | Description |
| --------- | ------ | ----------- |
| code      | string | 0 - success |
| msg       | string |             |
| data      | string |             |

#### Example

```
{
    "code":0,
    "msg":"ok",
    "data":{
        "total":1200,
        "page":1,
        "limit":1,
        "list":[
            {
                "token":"ordi",
                "tokenType":"brc20",
                "totalSupply":"21000000",
                "limit":"1000",
                "decimals":18,
                "minted":"21000000",                
                "holders":10671
            }
        ]
    }
}

```

##

## Inscription API

### Get inscription list

#### Request

GET /v1/btc/inscriptionList

#### Parameters

| Parameter | Type   | Required? | Description         |
| --------- | ------ | --------- | ------------------- |
| address   | string | No        |                     |
| page      | number | No        | request page number |
| size      | number | No        | request page size   |

#### Return data

| Parameter | Type   | Description      |
| --------- | ------ | ---------------- |
| total     | number | total amount     |
| page      | number | page number      |
| limit     | number | returned amount  |
| list      | array  | inscription list |

Inscription:

| Parameter         | Type   | Description |
| ----------------- | ------ | ----------- |
| inscriptionNumber | number |             |
| inscriptionId     | string |             |
| owner             | string |             |
| output            | string |             |

#### Example

Request:

```
curl '127.0.0.1:8181/v1/btc/inscriptionList?address=bc1pf8hsn52rvag59hysdw4jn9hsk4vex4r6e2d3jeec4tkxj9wmwlmq9ztm4w&page=1&size=20'
```

Response:

```
{
  "code": 2000,
  "msg": "Success",
  "data": {
    "list": [
      {
        "owner": "bc1pf8hsn52rvag59hysdw4jn9hsk4vex4r6e2d3jeec4tkxj9wmwlmq9ztm4w",
        "output": "ba78518b8bb4185bbb8e7236bab4f915f2c4e34dffc7cb6d1e88eb056fb00fd6:0",
        "inscriptionId": "d95c0fb86bc0f0dce6a732c5ab77d47e33ed24099bdb01133f768cef75a47724i0",
        "inscriptionNumber": 8
      }
    ],
    "page": 1,
    "limit": 1,
    "total": 1
  }
}
```

### Get inscription

#### Request

GET /v1/btc/inscription

#### Parameters

| Parameter         | Type   | Required? | Description |
| ----------------- | ------ | --------- | ----------- |
| inscriptionId     | string | No        |             |
| inscriptionNumber | string | No        |             |

#### Return data

| Parameter         | Type   | Description |
| ----------------- | ------ | ----------- |
| inscriptionNumber | string |             |
| inscriptionId     | string |             |
| txid              | string |             |
| holder            | string |             |
| creator           | string |             |
| deployHeight      | string |             |
| deployTime        | string |             |
| output            | string |             |

#### Example

### Get inscription transaction list

#### Request

GET /v1/btc/inscriptionHistory

#### Parameters

| Parameter     | Type   | Required? | Description         |
| ------------- | ------ | --------- | ------------------- |
| inscriptionId | string | Yes       |                     |
| start         | string | No        | request start index |
| limit         | string | No        | request limit       |

#### Return data

| Parameter         | Type   | Description                  |
| ----------------- | ------ | ---------------------------- |
| inscriptionId     | string |                              |
| inscriptionNumber | string |                              |
| total             | string | total amount                 |
| start             | string | start index                  |
| limit             | string | returned amount              |
| transactionList   | array  | inscription transaction list |

Inscription Transaction:

| Parameter | Type   | Description                          |
| --------- | ------ | ------------------------------------ |
| txid      | string | tx Id                                |
| block     | string | block height                         |
| txType    | string | transaction type: inscribe, transfer |
| from      | string | from address                         |
| to        | string | to address                           |
| time      | string |                                      |

#### Example

## BRC20 API

### Get BRC20 token list

#### Request

GET /v1/btc/tokenList

#### Parameters

| Parameter | Type   | Required? | Description                                           |
| --------- | ------ | --------- | ----------------------------------------------------- |
| page      | number | No        | request page number                                   |
| size      | number | No        | request page size                                     |
| status    | number | No        | token status (0: all status, 1: minting, 2: complate) |

#### Return data

| Parameter | Type   | Description        |
| --------- | ------ | ------------------ |
| total     | number | total token amount |
| page      | number | start page number  |
| limit     | number | returned amount    |
| list      | array  | token list         |

Token:

| Parameter    | Type   | Description       |
| ------------ | ------ | ----------------- |
| tokenType    | string | token type: brc20 |
| token        | string | total tick        |
| totalSupply  | number | total supply      |
| limit        | number | mint limit        |
| decimals     | number |                   |
| minted       | number | minted amount     |
| creator      | string |                   |
| deployTime   | string |                   |
| deployHeight | string |                   |
| holders      | string | holder amount     |

#### Example

Request:

```
curl '127.0.0.1:8181/v1/btc/tokenList?status=1&page=1&size=20'
```

Response:

```
{
  "code": 2000,
  "msg": "Success",
  "data": {
    "list": [
      {
        "tokenType": "brc20",
        "token": "abcd",
        "totalSupply": 21000,
        "limit": 1,
        "decimals": 18,
        "minted": 2,
        "creator": "bc1paxv6lr52gfxn7sk5l6g3zr3xt5q4506em4z9mxmelgmke3yx7x5s2k8qle",
        "deployTime": 1685418579,
        "deployHeight": 7958021,
        "holders": 2
      }
    ],
    "page": 1,
    "limit": 1,
    "total": 1
  }
}
```

### Get BRC20 token info

#### Request

GET /v1/btc/token

#### Parameters

| Parameter | Type   | Required? | Description |
| --------- | ------ | --------- | ----------- |
| token     | string | Yes       | token tick  |

#### Return data

| Parameter              | Type   | Description       |
| ---------------------- | ------ | ----------------- |
| tokenType              | string | token type: brc20 |
| token                  | string | total tick        |
| totalSupply            | number | total supply      |
| limit                  | number | mint limit        |
| minted                 | number | minted amount     |
| decimals               | number |                   |
| txid                   | string | deploy tx id      |
| creator                | string |                   |
| deployHeight           | number |                   |
| deployTime             | number |                   |
| inscriptionNumberStart | string |                   |
| inscriptionNumberEnd   | string |                   |

#### Example

Request:

```
curl '127.0.0.1:8181/v1/btc/token?token=abcd'
```

Response:

```
{
    "code": 2000,
    "msg": "Success",
    "data": {
        "tokenType": "brc20",
        "token": "abcd",
        "totalSupply": 21000,
        "limit": 1,
        "decimals": 18,
        "minted": 2,
        "creator": "bc1paxv6lr52gfxn7sk5l6g3zr3xt5q4506em4z9mxmelgmke3yx7x5s2k8qle",
        "deployTime": 1685418579,
        "deployHeight": 7958021,
        "txid": "16f3c32468e3e52ac20dc8fc633c686f0e31c5f34407413d12ad764ba5ad5f3b",
        "inscriptionNumberStart": 0,
        "inscriptionNumberEnd": 0
    }
}
```

### Get BRC20 token holder list

#### Request

GET /v1/btc/tokenHolders

#### Parameters

| Parameter | Type   | Required? | Description |
| --------- | ------ | --------- | ----------- |
| token     | string | Yes       | token tick  |
| start     | string | No        |             |
| limit     | string | No        |             |

#### Return data

| Parameter  | Type   | Description         |
| ---------- | ------ | ------------------- |
| total      | string | total holder amount |
| start      | string | start index         |
| limit      | string | returned amount     |
| holderList | Array  | holder list         |

Holder:

| Parameter | Type   | Description  |
| --------- | ------ | ------------ |
| address   | string |              |
| amount    | string | token amount |

### Get BRC20 token transaction list

#### Request

GET /v1/btc/tokenHistory

#### Parameters

| Parameter | Type   | Required? | Description                                                     |
| --------- | ------ | --------- | --------------------------------------------------------------- |
| token     | string | Yes       | token tick                                                      |
| type      | string | No        | transaction type: all, deploy, mint, transfer, inscribeTransfer |
| start     | string | No        | start index                                                     |
| limit     | string | No        |                                                                 |
| from      | string | No        | from address                                                    |
| to        | string | No        | to address                                                      |

#### Return data

| Parameter | Type   | Description      |
| --------- | ------ | ---------------- |
| token     | string | token tick       |
| total     | string | total amount     |
| start     | string | start index      |
| limit     | string | returned amount  |
| txList    | array  | transaction list |

Transaction:

| Parameter         | Type   | Description                                                     |
| ----------------- | ------ | --------------------------------------------------------------- |
| txid              | string | tx Id                                                           |
| block             | string | block height                                                    |
| tokenType         | string | token type: brc20                                               |
| token             | string | token tick                                                      |
| txType            | string | transaction type: all, deploy, mint, transfer, inscribeTransfer |
| from              | string | from address                                                    |
| to                | string | to address                                                      |
| amount            | string | transaction amount                                              |
| inscriptionNumber | string | inscription number                                              |
| inscriptionId     | string | inscription Id                                                  |
| time              | string |                                                                 |

#### Example

### Get Address token list

#### Request

GET /v1/btc/addressTokenBalance

#### Parameters

| Parameter | Type   | Required? | Description |
| --------- | ------ | --------- | ----------- |
| address   | string | Yes       |             |
| token     | string | No        | token tick  |
| start     | string | No        |             |
| limit     | string | No        |             |

#### Return data

| Parameter | Type   | Description     |
| --------- | ------ | --------------- |
| address   | string |                 |
| total     | string | total amount    |
| start     | string | start index     |
| limit     | string | returned amount |
| tokenList | array  | token list      |

TokenBalance:

| Parameter           | Type   | Description       |
| ------------------- | ------ | ----------------- |
| tokenType           | string | token type: brc20 |
| token               | string | total token count |
| balance             | string |                   |
| transferableBalance | string |                   |
| avaliableBalance    | string |                   |

#### Example

### Get Address inscribe-transfer list

#### Request

GET /v1/btc/addressTransferList

#### Parameters

| Parameter | Type   | Required? | Description |
| --------- | ------ | --------- | ----------- |
| address   | string | Yes       |             |
| token     | string | No        | token tick  |
| start     | string | No        |             |
| limit     | string | No        |             |

#### Return data

| Parameter    | Type   | Description            |
| ------------ | ------ | ---------------------- |
| address      | string |                        |
| total        | string | total amount           |
| start        | string | start index            |
| limit        | string | returned amount        |
| transferList | array  | inscribe-transfer list |

Inscribe-transfer:

| Parameter         | Type   | Description              |
| ----------------- | ------ | ------------------------ |
| tokenType         | string | token type: brc20        |
| token             | string | total token count        |
| amount            | string | inscribe-transfer amount |
| inscriptionId     | string |                          |
| inscriptionNumber | string |                          |

#### Example

### Get Address transaction list

#### Request

GET /v1/btc/addressHistory

#### Parameters

| Parameter | Type   | Required? | Description                                                     |
| --------- | ------ | --------- | --------------------------------------------------------------- |
| address   | string | Yes       |                                                                 |
| token     | string | Yes       | token tick                                                      |
| type      | string | No        | transaction type: all, deploy, mint, transfer, inscribeTransfer |
| start     | string | No        |                                                                 |
| limit     | string | No        |                                                                 |

#### Return data

| Parameter | Type   | Description      |
| --------- | ------ | ---------------- |
| total     | string | total amount     |
| start     | string | start index      |
| limit     | string | returned amount  |
| txList    | array  | transaction list |

Transaction:

| Parameter         | Type   | Description                                                     |
| ----------------- | ------ | --------------------------------------------------------------- |
| txid              | string | tx Id                                                           |
| block             | string | block height                                                    |
| tokenType         | string | token type: brc20                                               |
| token             | string | token tick                                                      |
| txType            | string | transaction type: all, deploy, mint, transfer, inscribeTransfer |
| from              | string | from address                                                    |
| to                | string | to address                                                      |
| amount            | string | transaction amount                                              |
| inscriptionNumber | string | inscription number                                              |
| inscriptionId     | string | inscription Id                                                  |
| time              | string |                                                                 |

#### Example
