Get Analysis Results
About 2 min
Introduction
Query task execution results.
Request Description
API address: https://api.phenonet.org/api/v1/openapi/classification/
Request method: HTTPS GET
Return format: JSON
Content-Type: multipart/form-data
Headers: {"accessID": {{STRING}}, "secretKey": {{STRING}}}
Body: {"task_id": {{STRING}}}
Parameter Description
parameter | data type | description | value | required |
---|---|---|---|---|
accessID | string | accessID is required when sending requests | see Step I: Get AI&SK | True |
secretKey | string | secretKey is required when sending requests | see Step I: Get AI&SK | True |
task_id | string | task unique identification | - | True |
Response Description
{
"code": "{{INTEGER}}",
"msg": "{{STRING}}",
"data": {
"task_id": "{{STRING}}",
"file_path": "{{STRING}}",
"model_id": "{{STRING}}",
"user": "{{STRING}}",
"task_name": "{{STRING}}",
"create_date": "{{STRING}}",
"is_finished": "{{INTEGER}}",
"stage": "{{INTEGER}}"
}
}
Returned parameter description
parameter | data type | description |
---|---|---|
code | integer | state code |
msg | string | reference information |
task_id | string | task Unique Identification |
file_path | string | - |
model_id | string | - |
user | string | - |
task_name | string | - |
create_date | string | - |
is_finished | integer | 0: queue / 1: processing / 2: success / 3: error |
stage | integer | 1: jointing to booting stage (J-B) 2: heading stage (H), 3: flowering stage (F), 4: grain filling stage (G-F) 5: mature stage (M) |
Example Code
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import requests
ACCESS_ID = ''
SECRET_KEY = ''
HEADERS = {
"accessID": ACCESS_ID,
"secretKey": SECRET_KEY
}
def get_task_status(task_id):
url = "https://api.phenonet.org/api/v1/openapi/classification"
params = {
'task_id': task_id,
}
try:
response = requests.get(url, headers=HEADERS, params=params)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
print('Exception occurred while obtaining task status: ', e)
return None
if __name__ == '__main__':
task_id = ''
status_res = get_task_status(task_id)
if status_res:
print(status_res)
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
const (
ACCESS_ID = ""
SECRET_KEY = ""
)
var (
HEADERS = map[string]string{
"accessID": ACCESS_ID,
"secretKey": SECRET_KEY,
}
)
func getTaskStatus(taskID string) []byte {
url := "https://api.phenonet.org/api/v1/openapi/classification"
params := "?task_id=" + taskID
req, _ := http.NewRequest("GET", url+params, nil)
for key, value := range HEADERS {
req.Header.Set(key, value)
}
client := &http.Client{}
res, err := client.Do(req)
if err != nil {
fmt.Println("Exception occurred while obtaining task status: ", err)
return nil
}
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
return body
}
func main() {
taskID := ""
statusRes := getTaskStatus(taskID)
if statusRes != nil {
fmt.Println(string(statusRes))
}
}
const https = require('https');
const ACCESS_ID = '';
const SECRET_KEY = '';
const HEADERS = {
"accessID": ACCESS_ID,
"secretKey": SECRET_KEY
}
function getTaskStatus(taskID) {
const url = "https://api.phenonet.org/api/v1/openapi/classification?task_id=" + taskID;
const options = {
headers: HEADERS
};
return new Promise((resolve, reject) => {
https.get(url, options, (res) => {
let body = '';
res.on('data', (chunk) => {
body += chunk;
});
res.on('end', () => {
resolve(body);
});
}).on('error', (e) => {
console.log('Exception occurred while obtaining task status: ', e);
reject(e);
});
});
}
const taskID = '';
getTaskStatus(taskID).then((statusRes) => {
console.log(statusRes);
}).catch((err) => {
console.log(err);
});
<?php
$accessID = "";
$secretKey = "";
$HEADERS = array(
"accessID" => $accessID,
"secretKey" => $secretKey
);
function getTaskStatus($taskID) {
global $HEADERS;
$url = "https://api.phenonet.org/api/v1/openapi/classification?task_id=" . $taskID;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $HEADERS);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Exception occurred while obtaining task status: ' . curl_error($ch);
curl_close($ch);
return null;
}
curl_close($ch);
return $res;
}
$taskID = '';
$statusRes = getTaskStatus($taskID);
if ($statusRes != null) {
echo $statusRes;
}
Error Code
code | description |
---|---|
403 | AI (Access ID) or SK (Secret Key) error |