### HostList Parameter Structure Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/a00030.html Example structure for the HostList parameter, showing how to identify hosts by name or display name and set preliminary start flags. ```text +---0 (paramParams) +---HostName = (paramString)"295ce3ac-f4b7-47e9-a7a5-b6aa7cb74e66" +---1 (paramParams) +---HostName = (paramString)"638168dc-735d-40af-88a5-b2f28eea6e99" +---2 (paramParams) +---HostDispName = (paramString)"Host3" +---Preliminary = (paramBool)true +---3 (paramParams) +---HostDispName = (paramString)"Host4" +---Preliminary = (paramBool)false ``` -------------------------------- ### Chart Parameter Configuration Example Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/a00447.html An example demonstrating the structure of chart data, series definitions, and visual configuration parameters. ```text +--- (paramParams) +---KLRPT_CHART_DATA (paramArray) | +---0 (paramParams) | | +---data (paramArray) | | | +---0 = (paramInt)0 | | | +---1 = (paramInt)4 | | | +---2 = (paramInt)0 | | +---name = (paramString)"631B52B3A5263BCC29026B87EFEFC78C" | +---1 (paramParams) | | +---data (paramArray) | | | +---0 = (paramInt)1 | | | +---1 = (paramInt)3 | | | +---2 = (paramInt)0 | | +---name = (paramString)"8092899C5F60B2580BE1EEBDD7F48742" | +---2 (paramParams) | +---data (paramArray) | | +---0 = (paramInt)1 | | +---1 = (paramInt)1999 | | +---2 = (paramInt)0 | +---name = (paramString)"A123-E56789-027F1F3F" +---KLRPT_CHART_DATA_DESC = (paramString)"Number of licensing units:" +---KLRPT_CHART_LGND_DESC = (paramString)"Key usage:" +---KLRPT_CHART_SERIES (paramArray) | +---0 = (paramString)"In use" | +---1 = (paramString)"Vacant" | +---2 = (paramString)"Exceeded" +---KLRPT_CHART_SERIES_COLORS (paramArray) | +---0 = (paramInt)9557089 | +---1 = (paramInt)13620370 | +---2 = (paramInt)8947967 +---KLRPT_CHART_STACK_SERIES = (paramBool)true +---KLRPT_HORIZONTAL_COLUMNS = (paramBool)true ``` -------------------------------- ### File download request example Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html An example of an HTTP GET request to download a file, specifying the range and encoding. ```http GET /PRFX/Some/test/file HTTP/1.1 Accept-Encoding: identity Range: bytes=0-99 ``` -------------------------------- ### Session Start Response Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html Example of a successful authentication response containing the session ID. ```json {"PxgRetVal":"n4QFPNjYK2oXRMYkis5CMcg=="} ``` -------------------------------- ### Session.StartSession Request and Response Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html Example of an authenticated session start request and the corresponding server response. ```http POST /api/v1.0/Session.StartSession HTTP/1.1 Accept-Encoding: gzip, deflate Authorization: KSCBasic user="0LvQvtCz0LjQvQ==", pass="0L/QsNGA0L7Qu9GM", internal="0" Content-Type: application/json Content-Length: 2 {} HTTP/1.1 200 OK Transfer-Encoding: chunked Content-Length: 41 ``` -------------------------------- ### KLHST_APP_INFO structure example Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/a00473.html This example illustrates the hierarchical structure of the KLHST_APP_INFO container, showing product IDs, versions, and their associated state and timestamp variables. ```text +--- (PARAMS_T) +---KLHST_APP_INFO (PARAMS_T) +---1093 (PARAMS_T) | +---1.0.0.0 (PARAMS_T) | +---KLHST_APP_STATE = (INT_T)3 | +---KLHST_APP_STATE_TIME = (DATE_TIME_T)25-01-2018 09:10:27 +---1103 (PARAMS_T) | +---1.0.0.0 (PARAMS_T) | +---KLHST_APP_STATE = (INT_T)3 | +---KLHST_APP_STATE_TIME = (DATE_TIME_T)25-01-2018 09:10:27 +---ConnProd (PARAMS_T) +---1.0.0.0 (PARAMS_T) +---KLHST_APP_STATE = (INT_T)3 +---KLHST_APP_STATE_TIME = (DATE_TIME_T)25-01-2018 09:10:27 ``` -------------------------------- ### paramLong Example Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html Example of a 64-bit integer represented as an object. ```json {"type": "long", "value": 13} ``` -------------------------------- ### paramDate Example Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html Example of a date object. ```json {"type": "date", "value": "2016-09-19"} ``` -------------------------------- ### Install License Key with Error Handling Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/a00535_a42d0b5d83d540627d8cfe770f514c2d5.html Attempts to install a license key, with a fallback to download key files if specific server or license errors occur. ```python try: wstrSerial = oLicenseKeys.InstallKey(KlAkOAPI.Params.KlAkParams({"KLLICSRV_KEYDATA": {"KLLIC_LICFILE": wstrActivationCode.encode('ascii'), "KLLIC_IFKEYFILE": False} })).RetVal() except KlAkOAPI.Error.KlAkError as err: if err.code == 2351 and (err.subcode == 3 or err.subcode == 34): # code KLOLA::KLOLA_ERR_SERVER (2351), subcode KLOLAEL_ERR_SERVER_1_REQUIRED (3) or KLOLAEL_ERR_LICENSE_NOT_FOUND (34) arrKeys = oLicenseKeys.DownloadKeyFiles(wstrActivationCode).RetVal() for arrKey in arrKeys: oLicenseKeys.InstallKey(KlAkOAPI.Params.KlAkParams({"KLLICSRV_KEYDATA": {"KLLIC_LICFILE": arrKey, "KLLIC_IFKEYFILE": False} })) else: raise ``` -------------------------------- ### paramParams Example Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html Example of a universal container object. ```json {"type": "params", "value": {"var1": 23, "var2": "str12", "var3": {"type": "date", "value": "2016-09-19"}}} ``` -------------------------------- ### KLHST_WKS_HSDP_REASON examples Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/a00011.html Two example values for the KLHST_WKS_HSDP_REASON attribute. ```text "1103/1.0.0.0/DBD500D3F6F04541910AD14C5CA47AE0" ``` ```text "1093/1.0.0.0/D2152D6328CE4328BCB3192632670E58" ``` -------------------------------- ### HostGroup::GetHostProducts Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/a00517_a3462eed9c19e7c832333a09301a044aa.html Returns information about installed products on a host, including product names, versions, and installation details. ```APIDOC ## HostGroup::GetHostProducts ### Description Returns information about installed products on the host. ### Method N/A (SDK method) ### Endpoint HostGroup::GetHostProducts ### Parameters #### Path Parameters - **strHostName** (wstring) - Required - host name (GUID-like ID). ### Response #### Success Response Returns a `params` container with names and versions of the products. The format is: - `` (paramParams) - `` (paramParams) - InstallTime - InstallationId - DisplayName - BaseRecords - ConnDisplayName - ConnProdVersion - ConnectorComponentName ### See Also - Product informative attributes - Local settings and policy format for some products ``` -------------------------------- ### paramFloat Example Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html Example of a real number object. ```json {"type": "float", "value": 1.23} ``` -------------------------------- ### paramDateTime Example Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html Example of a UTC datetime object. ```json {"type": "datetime", "value": "2016-09-19T15:22:35Z"} ``` -------------------------------- ### paramDouble Example Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html Example of a double precision real number object. ```json {"type": "double", "value": 1.23} ``` -------------------------------- ### paramArray Example Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html Example of an ordered collection of different types. ```json [{"type": "date", "value": "2016-09-19"}, {"type": "datetime", "value": "2016-09-19T15:22:35Z"}] ``` -------------------------------- ### paramBinary Example Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html Example of a binary data object with base64 encoded value. ```json {"type": "binary", "value": "c29tZXRleHQ="} ``` -------------------------------- ### paramString Example Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html Example of a string value with escaped double quotes. ```json "Some text with \"double quotes\" must be like this" ``` -------------------------------- ### JSON error response example with PxgError Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html Example JSON object containing an error description in the PxgError field, with code, module, file, line, and message fields. This is shown as an example of an error response. ```json { "PxgError": { "code": 1681, "module": "KLFT", "file": "kca/ft/filetransferimp.cpp", "line": 1234, "message": "File not found. File name - 'JobId-5771bdab-dfdd-4e6a-ad52-536ef095813f'." } } ``` -------------------------------- ### JSON response examples with PxgRetVal and output variables Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html Three JSON object examples showing possible successful responses: one with a numeric PxgRetVal and output variables, one with a string PxgRetVal, and one empty object when no result or output variables are present. ```json { "PxgRetVal": 15, "OutVar1": "value1", "OutVar2": "value2" } ``` ```json { "PxgRetVal": "abc" } ``` ```json { } ``` -------------------------------- ### HTTP Request Headers Example Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html An example of the required HTTP headers for a KSC API request, including the method path, content type, and encoding preferences. ```http POST /api/v1.0/TestInterface.ScMethod1 HTTP/1.1 Content-Type: application/json Content-Length: 56 Accept-Encoding: gzip, deflate ``` -------------------------------- ### File download response example Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html The server response to a file download request, indicating partial content. ```http HTTP/1.1 206 Partial Content Content-Length: 3 Content-Range: bytes=0-2/1024 Content-Type: application/octet-stream XYZ ``` -------------------------------- ### JSON Request Body Examples Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html Examples of JSON objects used in the request body to pass method arguments. If a method has no input parameters, an empty object '{}' must be provided. ```json { "arg1":"value1" } ``` ```json { "arg1":"value2", "arg2":43 } ``` ```json { } ``` -------------------------------- ### SPNEGO Authentication Process Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html Example of a successful SPNEGO (Negotiate) authentication request. ```http POST /api/v1.0/login HTTP/1.1 Authorization: Negotiate YY..... Content-Length: 0 HTTP/1.1 200 OK Content-Length: 27 Content-Type: text/plain ``` -------------------------------- ### Authenticated API Request Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html Example of an API call using the X-KSC-Session header obtained from the StartSession method. ```http POST /api/v1.0/HostGroup.GetStaticInfo HTTP/1.1 Content-Type: application/json Transfer-Encoding: chunked X-KSC-Session: n4QFPNjYK2oXRMYkis5CMcg== Content-Length: 16 {"pValues":null} ``` -------------------------------- ### Checking Supported Authentication Methods Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html Example of sending an unauthorized request to inspect the WWW-Authenticate headers returned by the server. ```http POST /api/v1.0/gssprobe HTTP/1.1 Content-Length: 0 HTTP/1.1 401 Unauthorized Content-Length: 23 Content-Type: text/plain WWW-Authenticate: Negotiate WWW-Authenticate: NTLM WWW-Authenticate: KSCBasic Authentication required ``` -------------------------------- ### NWC console (KSCNT) authentication format and request Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html Example showing the clear JSON format for KSCNT tokens and the corresponding API login request. ```http KSCNT {"AuthType": "AdfsAuthCode", "AdfsAuthCode": "AwABAAAAvPM1KaPlrEqdFSBzjqfTGBCmLdgfSTLEMPGYuNHSUYBrq", "AdfsClientId": "Client Id", "WorkspaceId": "hostedinst_0207132feccc4cba834d76518cdc5005", "UserSessionId": "4adee13b-0b25-4956-b74e-57fbd6baef24", "UserSessionState": "076D0A24AE082858740E13FE1E5F7BA5", "AdfsIssuer": "http://localhost:63076/adfs"} ``` ```http POST /api/v1.0/login HTTP/1.1 Authorization: KSCNT ZXlKaGJHY2lPaUpJVXpJMU5pSXNJblI1Y0NJNklrcFhWQ0o5LmV5SnBaQ0k2SWpFeU16UTFOamM0T1RBaWZRLlRuMEdhSEtoQVpaQjlZM2Zad1A0UURHLXl2alVYTXgzZHpBYkxLakNYOU0= Content-Type: application/json Content-Length: 2 {} ``` -------------------------------- ### Basic Authentication Request Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html Example of a login request using the KSCBasic authentication scheme. ```http POST /api/v1.0/login HTTP/1.1 Authorization: KSCBasic user="0LvQvtCz0LjQvQ==", pass="0L/QsNGA0L7Qu9GM", internal="0" Content-Type: application/json X-KSC-VServer: 0LLQuNGA0YLRgdC10YDQstC1MQ== Content-Length: 2 {} ``` -------------------------------- ### WebToken (KSCWT) authentication request Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html Example of using the KSCWT scheme with a token obtained from Kaspersky UIS. ```http POST /api/v1.0/login HTTP/1.1 Authorization: KSCWT ZXlKaGJHY2lPaUpJVXpJMU5pSXNJblI1Y0NJNklrcFhWQ0o5LmV5SnBaQ0k2SWpFeU16UTFOamM0T1RBaWZRLlRuMEdhSEtoQVpaQjlZM2Zad1A0UURHLXl2alVYTXgzZHpBYkxLakNYOU0= Content-Type: application/json Content-Length: 2 {} ``` -------------------------------- ### main: Sample entry point to enumerate licenses Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/a00440.html Connects to the KSC server using KlAkAdmServer.Create, checks for an active license on the main server, and then enumerates licenses on all virtual servers. ```python def main(): """ This sample shows how you can see licenses in use """ print (main.__doc__) #connect to KSC server using basic auth by default server = KlAkAdmServer.Create(server_url, username, password, verify = SSLVerifyCert) print('Main server licenses:') if not FindActiveLicense(server): print('FAILURE! There''s no active license on server') EnumVServersAndTheirLicenses(server) if __name__ == '__main__': main() ``` -------------------------------- ### NTLM Authentication Process Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html Example of a multi-step NTLM authentication process involving a 401 challenge and a subsequent successful request. ```http POST /api/v1.0/login HTTP/1.1 Authorization: NTLM TlRM.... Content-Length: 0 HTTP/1.1 401 Unauthorized Content-Length: 27 Content-Type: text/plain WWW-Authenticate: NTLM TlRM.... Authentication not finished POST /api/v1.0/login HTTP/1.1 Authorization: NTLM TlRM.... Content-Length: 0 HTTP/1.1 200 OK Content-Length: 0 ``` -------------------------------- ### TestApi.TestMethod0 Request and Response Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/index.html Example of calling the TestMethod0 endpoint with a simple integer argument. ```http POST /api/v1.0/KlsrvoapiTestApi.TestMethod0 HTTP/1.1 X-KSC-RequestId: 39C49236A51C334C_98969A4853053FEC Content-Length: 15 Content-Type: application/json {"arg1":102030} ``` ```http HTTP/1.1 200 OK Content-Length: 20 Content-Type: application/json {"PxgRetVal":123456} ``` -------------------------------- ### TryToInstallLicForSaas2 Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/a00534.html Install the Administration Server license key. ```APIDOC ## TryToInstallLicForSaas2 ### Description Install the Administration Server license key. ### Method TryToInstallLicForSaas2 ### Parameters #### Parameters - **pKeyInfo** (params) - Required - Description not provided. - **bAsCurrent** (boolean) - Required - Description not provided. ### Response None ``` -------------------------------- ### GetTaskStartEvent Source: https://support.kaspersky.com/help/KSC/14.2/KSCAPI/a00521.html Get task start event. ```APIDOC ## GetTaskStartEvent ### Description Get task start event. ### Method GetTaskStartEvent ### Parameters - **strSrvObjId** (wstring) - Required - Server object ID. - **strTask** (wstring) - Required - Task identifier. ### Response Returns task start event as params. ```