> For the complete documentation index, see [llms.txt](https://computation-sdk.phoenix.global/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://computation-sdk.phoenix.global/reference/api-reference/job-queries.md).

# Job Queries

{% hint style="info" %}
**Good to know:** All job query interfaces need to use token as the request header.
{% endhint %}

## Querying job

### Querying job list

<mark style="color:green;">`POST`</mark> `https://www.phoenix.global/sdk/computation/panel/jobListByUser`

Query the list of jobs that the user participates in.

#### Headers

| Name                                    | Type   | Description                              |
| --------------------------------------- | ------ | ---------------------------------------- |
| token<mark style="color:red;">\*</mark> | string | The token generated in the previous step |

#### Request Body

| Name                                       | Type    | Description |
| ------------------------------------------ | ------- | ----------- |
| pageNo<mark style="color:red;">\*</mark>   | integer | page number |
| pageSize<mark style="color:red;">\*</mark> | integer | page size   |

{% tabs %}
{% tab title="200: OK Return job list" %}

```json
{
    "code":200,
    "msg":"success",
    "size":20,
    "page":1,
    "totalPages":1,
    "totalCount":2,
    "data":[
        {
            "jobID":"23852445952590777475260973439464112207496364646998189462210436653351556571331",
            "typeStr":"Upload",
            "jobName":"matrix addition job",
            "parties":[
                "111@gmail.com",
                "222@gmail.com",
                "333@gmail.com"
            ],
            "contractAddr":"0xD23C411aF00D557Bfef4390d8a1D1F2f61622130",
            "creator":"111@gmail.com",
            "creationTime":1676518206,
            "updateTime":1676518206
        },
        {
            "jobID":"3011173339614700144228046993114909367073003421675739591333024515403501305843",
            "typeStr":"Input",
            "jobName":"matrix multiplication",
            "parties":[
                "111@gmail.com",
                "222@gmail.com",
                "333@gmail.com"
            ],
            "contractAddr":"0x5402e4FCd2c90A72525ff891CD4C2eC9281E62ff",
            "creator":"111@gmail.com",
            "creationTime":1673422844,
            "updateTime":1673422844
        }
    ]
}
```

{% endtab %}
{% endtabs %}

The usage of curl and golang sdk is as follows:

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location 'https://www.phoenix.global/sdk/computation/panel/jobListByUser' \
--header 'token: xxxxxx' \
--header 'Content-Type: application/json' \
--data '{
  "pageNo": 1,
  "pageSize": 20
}'
```

{% endtab %}

{% tab title="Golang" %}

```go
import (
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/common"
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/controllers"
)

func main() {
	token := "xxxxxx"
	reqBody := common.ReqPage{
		PageNo:   1,
		PageSize: 10,
	}
	result, err := controllers.JobListByUser(reqBody, token)
	......
}
```

{% endtab %}
{% endtabs %}

### Querying job detail by job id

<mark style="color:green;">`POST`</mark> `https://www.phoenix.global/sdk/computation/panel/jobDetailByUser`

Query job details according to jobid. The query user must be a participant of the job

#### Headers

| Name                                    | Type   | Description                              |
| --------------------------------------- | ------ | ---------------------------------------- |
| token<mark style="color:red;">\*</mark> | string | The token generated in the previous step |

#### Request Body

| Name                                    | Type   | Description |
| --------------------------------------- | ------ | ----------- |
| jobID<mark style="color:red;">\*</mark> | string | job id      |

{% tabs %}
{% tab title="200: OK Return job detail" %}

```json
{
    "code": 200,
    "msg": "success",
    "jobID": "106006086598460350897135634523568280408477446978521913351461287547366806554671",
    "typeStr": "Upload",
    "jobName": "decision tree job",
    "parties": [
        "111@gmail.com"
    ],
    "contractAddr": "0x717c6364378D2de0032BEfD0AB5964B44691750f",
    "creator": "111@gmail.com",
    "computationStr": "decision tree",
    "creationTime": 1678342677,
    "updateTime": 1678342677,
    "input": "",
    "featureData": "titanic_x.csv",
    "targetData": "titanic_y.csv",
    "testingData": "titanic_testx.csv"
}
```

{% endtab %}
{% endtabs %}

The usage of curl and golang sdk is as follows:

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location 'https://www.phoenix.global/sdk/computation/panel/jobDetailByUser' \
--header 'token: xxxxxx' \
--header 'Content-Type: application/json' \
--data '{
  "jobID": "xxxxxx"
}'
```

{% endtab %}

{% tab title="Golang" %}

```go
import (
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/common"
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/controllers"
)

func main() {
	token := "xxxxxx"
	reqBody := common.ReqJobDetailByUser{
		JobID: "xxxxxx",
	}
	result, err := controllers.JobDetailByUser(reqBody, token)
	......
}
```

{% endtab %}
{% endtabs %}

## Querying notice list

<mark style="color:green;">`POST`</mark> `https://www.phoenix.global/sdk/computation/panel/noticeList`

Query the list of jobs that require input data.

#### Headers

| Name                                    | Type   | Description                              |
| --------------------------------------- | ------ | ---------------------------------------- |
| token<mark style="color:red;">\*</mark> | string | The token generated in the previous step |

#### Request Body

| Name                                       | Type    | Description |
| ------------------------------------------ | ------- | ----------- |
| pageNo<mark style="color:red;">\*</mark>   | integer | page number |
| pageSize<mark style="color:red;">\*</mark> | integer | page size   |

{% tabs %}
{% tab title="200: OK Return job list that require input data" %}

```json
{
    "code":200,
    "msg":"success",
    "size":20,
    "page":1,
    "totalPages":1,
    "totalCount":2,
    "data":[
        {
            "jobID":"32684791260453298104859009647047307465673888568545092225165106656999975656724",
            "type":"Input",
            "jobName":"privacy comparison job",
            "creator":"222@gmail.com",
            "creationTime":1675668300,
            "updateTime":1675668300,
            "contractAddr":"0x5402e4FCd2c90A72525ff891CD4C2eC9281E62ff"
        },
        {
            "jobID":"56819547717557264144992771514561558548085549762085773881024816086398223185533",
            "type":"Input",
            "jobName":"matrix addition job",
            "creator":"222@gmail.com",
            "creationTime":1675219780,
            "updateTime":1675219780,
            "contractAddr":"0x3b283afE5976272781Cc6DA3Fc7a9CAadb425758"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

The usage of curl and golang sdk is as follows:

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location 'https://www.phoenix.global/sdk/computation/panel/noticeList' \
--header 'token: xxxxxx' \
--header 'Content-Type: application/json' \
--data '{
  "pageNo": 1,
  "pageSize": 20
}'
```

{% endtab %}

{% tab title="Golang" %}

```go
import (
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/common"
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/controllers"
)

func main() {
	token := "xxxxxx"
	reqBody := common.ReqPage{
		PageNo:   1,
		PageSize: 10,
	}
	result, err := controllers.NoticeList(reqBody, token)
	......
}
```

{% endtab %}
{% endtabs %}

## Querying computation result of a job

<mark style="color:green;">`POST`</mark> `https://www.phoenix.global/sdk/computation/panel/subListByUser`

The computation results will be submitted to the blockchain through smart contracts. You can query the results submitted to the chain by this api. All participants can submit their calculation results to the blockchain.

#### Headers

| Name                                    | Type   | Description                              |
| --------------------------------------- | ------ | ---------------------------------------- |
| token<mark style="color:red;">\*</mark> | string | The token generated in the previous step |

#### Request Body

| Name                                       | Type    | Description |
| ------------------------------------------ | ------- | ----------- |
| pageNo<mark style="color:red;">\*</mark>   | integer | page number |
| pageSize<mark style="color:red;">\*</mark> | integer | page size   |
| jobID<mark style="color:red;">\*</mark>    | string  | job id      |

{% tabs %}
{% tab title="200: OK Return the computation result submitted to the phoenix blockchain" %}

```json
{
    "code": 200,
    "msg": "success",
    "size": 20,
    "page": 1,
    "totalPages": 1,
    "totalCount": 3,
    "trainModel": "",
    "testingResult": "",
    "data": [
        {
            "txHash": "0xea89d05654be3009ebe61fe163347afbf40a053ecc641b2fc075347b7d6020eb",
            "submitValue": "[[b'5.000000' b'8.199982']\n [b'-15.000000' b'12.000000']\n [b'3.000000' b'6.000000']]",
            "submitTime": 1673407741,
            "ccdUsage": "0.018"
        },
        {
            "txHash": "0xab3df69787c634ab29bb784e00e59e017806683ee74667f4b9e340c66906c6cd",
            "submitValue": "[[b'5.000000' b'8.199982']\n [b'-15.000000' b'12.000000']\n [b'3.000000' b'6.000000']]",
            "submitTime": 1673407740,
            "ccdUsage": "0.018"
        },
        {
            "txHash": "0xce311949f53579056cf69b151a342245a019c3f0450ea209e139fafa908d3d1e",
            "submitValue": "[[b'5.000000' b'8.199982']\n [b'-15.000000' b'12.000000']\n [b'3.000000' b'6.000000']]",
            "submitTime": 1673407740,
            "ccdUsage": "0.018"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

The usage of curl and golang sdk is as follows:

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location 'https://www.phoenix.global/sdk/computation/panel/subListByUser' \
--header 'token: xxxxxx' \
--header 'Content-Type: application/json' \
--data '{
  "pageNo": 1,
  "pageSize": 20,
  "jobID": "xxxxxx"
}'
```

{% endtab %}

{% tab title="Golang" %}

```go
import (
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/common"
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/controllers"
)

func main() {
	token := "xxxxxx"
	reqPage := common.ReqPage{
		PageNo:   1,
		PageSize: 10,
	}
	reqBody := common.ReqSubListByUser{
		ReqPage: &reqPage,
		JobID:   "xxxxxx",
	}
	result, err := controllers.SubmissionList(reqBody, token)
	......
}
```

{% endtab %}
{% endtabs %}

## Querying CCD usage

<mark style="color:green;">`POST`</mark> `https://www.phoenix.global/sdk/computation/panel/ccdUsageList`

Query the details of the CCD consumption of the account.

#### Headers

| Name                                    | Type   | Description                              |
| --------------------------------------- | ------ | ---------------------------------------- |
| token<mark style="color:red;">\*</mark> | string | The token generated in the previous step |

#### Request Body

| Name                                       | Type    | Description |
| ------------------------------------------ | ------- | ----------- |
| pageNo<mark style="color:red;">\*</mark>   | integer | page number |
| pageSize<mark style="color:red;">\*</mark> | integer | page size   |

{% tabs %}
{% tab title="200: OK Return CCD usage list" %}

```json
{
    "code":200,
    "msg":"success",
    "size":20,
    "page":1,
    "totalPages":1,
    "totalCount":2,
    "data":[
        {
            "jobID":"67359335745793195679188745481165227472100204117487131087027292513447780097380",
            "type":"Upload",
            "jobName":"logistic regression job",
            "creator":"111@gmail.com",
            "creationTime":1677490079,
            "updateTime":1677490079,
            "ccdUsage":"0.003521",
            "contractAddr":"0x234f698c47ff3B6DC05DC2f9F1a357f2f6Dcda16"
        },
        {
            "jobID":"92660823194349043075443300863708415242102090291282612538954225036265610510681",
            "type":"Upload",
            "jobName":"decision tree job",
            "creator":"111@gmail.com",
            "creationTime":1677489985,
            "updateTime":1677489985,
            "ccdUsage":"0.011765",
            "contractAddr":"0x717c6364378D2de0032BEfD0AB5964B44691750f"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

The usage of curl and golang sdk is as follows:

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location 'https://www.phoenix.global/sdk/computation/panel/ccdUsageList' \
--header 'token: xxxxxx' \
--header 'Content-Type: application/json' \
--data '{
  "pageNo": 1,
  "pageSize": 20
}'
```

{% endtab %}

{% tab title="Golang" %}

```go
import (
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/common"
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/controllers"
)

func main() {
	token := "xxxxxx"
	reqBody := common.ReqPage{
		PageNo:   1,
		PageSize: 10,
	}
	result, err := controllers.CcdUsageList(reqBody, token)
	......
}
```

{% endtab %}
{% endtabs %}

## Downloading uploaded dataset

<mark style="color:blue;">`GET`</mark> `https://www.phoenix.global/sdk/computation/panel/downloadDataset`

Download the dataset of the upload job. Only the creator of the upload job can successfully call this api.

#### Query Parameters

| Name                                          | Type   | Description                                  |
| --------------------------------------------- | ------ | -------------------------------------------- |
| datasetType<mark style="color:red;">\*</mark> | string | dataset type，one of feature, target, testing |
| jobID<mark style="color:red;">\*</mark>       | string | job id                                       |

#### Headers

| Name                                    | Type   | Description                              |
| --------------------------------------- | ------ | ---------------------------------------- |
| token<mark style="color:red;">\*</mark> | string | The token generated in the previous step |

{% tabs %}
{% tab title="200: OK File stream" %}

{% endtab %}
{% endtabs %}

The usage of curl and golang sdk is as follows:

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location 'https://www.phoenix.global/sdk/computation/panel/downloadDataset?datasetType=target&jobID=xxxxxx' \
--header 'token: xxxxxx'
```

{% endtab %}

{% tab title="Golang" %}

```go
import (
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/common"
	"github.com/PhoenixGlobal/Phoenix-Computation-SDK/controllers"
)

func main() {
	token := "xxxxxx"
	reqBody := common.ReqDownloadDataset{
		JobID:       "xxxxxx",
		DatasetType: "target",
	}

	result, err := controllers.DownloadDataset(reqBody, token)
	......
}
```

{% endtab %}
{% endtabs %}
