Introduction This step will guide you on how to get the public and private networks for inference. The PhenoNet platform will return the parameters file_path
and task_id
, which serve as an identifier for inference.
Request Description API address: https:
Request method: HTTPS GET
Return format: JSON
Content-Type: multipart/form-data
Headers: { "accessID" : { { STRING} } , "secretKey" : { { STRING} } }
Parameter Description parameter data type description value required accessID string accessID
is required when sending requestssee Step I: Get AI&SK True secretKey string secretKey
is required when sending requestssee Step I: Get AI&SK True
Response Description {
"code" : "{{INTEGER}}" ,
"msg" : "{{STRING}}" ,
"data" : {
"{{STRING}}" : "{{STRING}}" ,
}
}
Returned parameter description parameter data type description code integer state code msg string reference information data object returned content network id string network unique identification network name string -
Example Code Python GO (alpha) JavaScript (alpha) PHP (alpha)
import requests
ACCESS_ID = ''
SECRET_KEY = ''
HEADERS = {
"accessID" : ACCESS_ID,
"secretKey" : SECRET_KEY
}
def get_network ( headers) :
url = "https://api.phenonet.org/api/v1/openapi/models/"
try :
response = requests. get( url, headers= headers)
response. raise_for_status( )
return response. json( )
except requests. exceptions. RequestException as e:
print ( f"Error get networks: { e} " )
return None
if __name__ == '__main__' :
network_res = get_network( HEADERS)
if network_res:
print ( network_res)
package main
import (
"encoding/json"
"fmt"
"net/http"
)
const (
ACCESS_ID = ""
SECRET_KEY = ""
URL = "https://api.phenonet.org/api/v1/openapi/models/"
)
var headers = map [ string ] string {
"accessID" : ACCESS_ID,
"secretKey" : SECRET_KEY,
}
func getNetwork ( headers map [ string ] string ) map [ string ] interface { } {
client := & http. Client{ }
req, err := http. NewRequest ( "GET" , URL, nil )
if err != nil {
fmt. Println ( "Error creating request:" , err)
return nil
}
for key, value := range headers {
req. Header. Set ( key, value)
}
resp, err := client. Do ( req)
if err != nil {
fmt. Println ( "Error making request:" , err)
return nil
}
defer resp. Body. Close ( )
var data map [ string ] interface { }
err = json. NewDecoder ( resp. Body) . Decode ( & data)
if err != nil {
fmt. Println ( "Error decoding response:" , err)
return nil
}
return data
}
func main ( ) {
networkRes := getNetwork ( headers)
if networkRes != nil {
fmt. Println ( networkRes)
}
}
const https = require ( 'https' ) ;
const ACCESS_ID = '' ;
const SECRET_KEY = '' ;
const HEADERS = {
'accessID' : ACCESS_ID ,
'secretKey' : SECRET_KEY ,
} ;
function getNetwork ( headers ) {
const url = 'https://api.phenonet.org/api/v1/openapi/models/' ;
const options = {
headers : headers,
} ;
return new Promise ( ( resolve, reject ) => {
https. get ( url, options, ( res ) => {
let data = '' ;
res. on ( 'data' , ( chunk ) => {
data += chunk;
} ) ;
res. on ( 'end' , ( ) => {
resolve ( JSON . parse ( data) ) ;
} ) ;
} ) . on ( 'error' , ( error ) => {
console. error ( ` Error getting networks: ${ error} ` ) ;
reject ( error) ;
} ) ;
} ) ;
}
const networkRes = getNetwork ( HEADERS )
. then ( ( data ) => {
console. log ( data) ;
} )
. catch ( ( error ) => {
console. error ( ` Error getting networks: ${ error} ` ) ;
} ) ;
<?php
$ACCESS_ID = '' ;
$SECRET_KEY = '' ;
$HEADERS = array (
'accessID' => $ACCESS_ID ,
'secretKey' => $SECRET_KEY ,
) ;
function getNetwork ( $headers ) {
$url = 'https://api.phenonet.org/api/v1/openapi/models/' ;
$ch = curl_init ( ) ;
curl_setopt ( $ch , CURLOPT_URL , $url ) ;
curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true ) ;
curl_setopt ( $ch , CURLOPT_HTTPHEADER , $headers ) ;
curl_setopt ( $ch , CURLOPT_SSL_VERIFYPEER , false ) ;
curl_setopt ( $ch , CURLOPT_SSL_VERIFYHOST , false ) ;
$response = curl_exec ( $ch ) ;
curl_close ( $ch ) ;
return json_decode ( $response , true ) ;
}
$networkRes = getNetwork ( $HEADERS ) ;
if ( $networkRes ) {
echo $networkRes ;
} else {
echo 'Error getting networks' ;
}
?>
Error Code code description 403 AI (Access ID)
or SK (Secret Key)
error
Prev
Upload image
Next
Call API