SDK REFERENCE¶
binaryai.client module¶
-
class
binaryai.client.Client(token, url, timeout=1000)¶ Bases:
objectBinaryAI api client
-
token¶ token used for query
- Type
string
-
url¶ BinaryAI api endpoint url
- Type
string
-
timeout¶ seconds of timeout, default is 1000
- Type
int
-
execute(query, var, throw_duplicate_error=False)¶ Send request to API server and get response
- Parameters
query (string) – graphql query
var (dict) – variables to send
- Returns
response data of this request
- Return type
dict
-
binaryai.function module¶
-
binaryai.function.clear_index_list(client)¶ Clear all things in your index list
- Returns
None
-
binaryai.function.create_function_set(client, name, description='', function_ids=None, throw_duplicate_error=True)¶ Create a new function set and add functions if needed
- Parameters
client (binaryai.client.Client) – Client instance
name (string) – Name of the new functionset
description (string) – Description of the new functionset. Can be empty string
function_ids (list) – Functions to be inserted into the new function set. Can be null so no functions will be added into the set.
- Returns
id (string) – id of the function set
-
binaryai.function.insert_function_set_member(client, setid, function_ids)¶ Insert functions into certain functionset
- Parameters
client (binaryai.client.Client) – Client instance
setid (string) – ID of the target
function_ids (list) – Functions to be inserted into the new function set. Can be null so no functions will be added into the set.
- Returns
id (string) – id of the function set
-
binaryai.function.insert_index_list(client, function_ids=None, functionset_ids=None)¶ Insert functions into your retrive list
- Parameters
client (binaryai.client.Client) – Client instance
function_ids (list) – Functions to be inserted into the index list. Can be null so no functions will be added into the list.
functionset_ids (list) – Functionsets to be inserted into the index list. Can be null so no sets will be added into the list.
- Returns
None
-
binaryai.function.query_created_function_set(client)¶ Get all function sets created by current user
- Returns
functionSetIDs (list) – functionSet’s id
-
binaryai.function.query_function(client, function_id)¶ get function information by id
- Parameters
client (binaryai.client.Client) – Client instance
function_id (string) – ID of the function
- Returns
function (dict) – Function’s information
-
binaryai.function.query_function_set(client, funcset_id)¶ get function set information by id
- Parameters
client (binaryai.client.Client) – Client instance
funcset_id (string) – id of the function set
- Returns
functionSet (dict) – functionSet’s information
-
binaryai.function.search_sim_funcs(client, function_id=None, feature=None, topk=1)¶ search top similar functions of the function in your retrieve list
- Parameters
client (binaryai.client.Client) – Client instance
function_id (string) – id of the function
topk (int) – return first topk results, default value is 1.
- Returns
list of the top similarity functions
- Return type
similarity (list)
-
binaryai.function.upload_function(client, name, feature, source_code=None, source_file=None, source_line=None, binary_file=None, platform=None, throw_duplicate_error=False, pseudo_code=None, package_name=None)¶ upload function to BinaryAI server
- Parameters
client (binaryai.client.Client) – Client instance
name (string) – name of the function
feature (string) – Feature of the function. Genertaed by feature extraction library. Encoding in base64.
source_code (string) – Source code of the function
source_file (string) – Source file of the function
source_line (int) – line number of the function
binary_file (string) – Name of the binary file which contains this function
platform (string) – Platform of the binary file, for example, metapc64, or x86_64, or mipsel
throw_duplicate_error (bool) – If a duplicate error should be raised when two name equals
pseudo_code (string) – Pseudo code of the function
package_name (string) – Package name containing this function
- Returns
id (string) – id of this function