[comment]: # translation:outdated

[comment]: # ({new-cd91b3fe})
# script.get

[comment]: # ({/new-cd91b3fe})

[comment]: # ({new-96ec37bc})
### Description

`integer/array script.get(object parameters)`

The method allows to retrieve scripts according to the given parameters.

::: noteclassic
This method is available to users of any type. Permissions
to call the method can be revoked in user role settings. See [User
roles](/manual/web_interface/frontend_sections/administration/user_roles)
for more information.
:::

[comment]: # ({/new-96ec37bc})

[comment]: # ({new-c425a65a})
### Parameters

`(object)` Parameters defining the desired output.

The method supports the following parameters.

|Parameter|[Type](/manual/api/reference_commentary#data_types)|Description|
|---------|---------------------------------------------------|-----------|
|groupids|string/array|Return only scripts that can be run on the given host groups.|
|hostids|string/array|Return only scripts that can be run on the given hosts.|
|scriptids|string/array|Return only scripts with the given IDs.|
|usrgrpids|string/array|Return only scripts that can be run by users in the given user groups.|
|selectGroups|query|Return a [groups](/manual/api/reference/hostgroup/object) property with host groups that the script can be run on.|
|selectHosts|query|Return a [hosts](/manual/api/reference/host/object) property with hosts that the script can be run on.|
|selectActions|query|Return a [actions](/manual/api/reference/action/object) property with actions that the script is associated with.|
|sortfield|string/array|Sort the result by the given properties.<br><br>Possible values are: `scriptid` and `name`.|
|countOutput|boolean|These parameters being common for all `get` methods are described in detail in the [reference commentary](/manual/api/reference_commentary#common_get_method_parameters).|
|editable|boolean|^|
|excludeSearch|boolean|^|
|filter|object|^|
|limit|integer|^|
|output|query|^|
|preservekeys|boolean|^|
|search|object|^|
|searchByAny|boolean|^|
|searchWildcardsEnabled|boolean|^|
|sortorder|string/array|^|
|startSearch|boolean|^|

[comment]: # ({/new-c425a65a})

[comment]: # ({7223bab1-7223bab1})
### Повернуті значення

`(integer/array)` Повертає або:

- масив об'єктів;
- кількість отриманих об'єктів, якщо використовувався параметр `countOutput`.

[comment]: # ({/7223bab1-7223bab1})

[comment]: # ({b41637d2-b41637d2})
### Приклади

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({new-6d428f32})
#### Retrieve all scripts

Retrieve all configured scripts.

Request:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "script.get",
    "params": {
        "output": "extend"
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": [    
        {
            "scriptid": "1",
            "name": "Ping",
            "command": "/bin/ping -c 3 {HOST.CONN} 2>&1",
            "host_access": "2",
            "usrgrpid": "0",
            "groupid": "0",
            "description": "",
            "confirmation": "",
            "type": "0",
            "execute_on": "1",
            "timeout": "30s",
            "parameters": []
        },
        {
            "scriptid": "2",
            "name": "Traceroute",
            "command": "/usr/bin/traceroute {HOST.CONN} 2>&1",
            "host_access": "2",
            "usrgrpid": "0",
            "groupid": "0",
            "description": "",
            "confirmation": "",
            "type": "0",
            "execute_on": "1",
            "timeout": "30s",
            "parameters": []
        },
        {
            "scriptid": "3",
            "name": "Detect operating system",
            "command": "sudo /usr/bin/nmap -O {HOST.CONN} 2>&1",
            "host_access": "2",
            "usrgrpid": "7",
            "groupid": "0",
            "description": "",
            "confirmation": "",
            "type": "0",
            "execute_on": "1",
            "timeout": "30s",
            "parameters": []
        },
        {
            "scriptid": "4",
            "name": "Webhook",
            "command": "try {\n var request = new HttpRequest(),\n response,\n data;\n\n request.addHeader('Content-Type: application/json');\n\n response = request.post('https://localhost/post', value);\n\n try {\n response = JSON.parse(response);\n }\n catch (error) {\n response = null;\n }\n\n if (request.getStatus() !== 200 || !('data' in response)) {\n throw 'Unexpected response.';\n }\n\n data = JSON.stringify(response.data);\n\n Zabbix.Log(3, '[Webhook Script] response data: ' + data);\n\n return data;\n}\ncatch (error) {\n Zabbix.Log(3, '[Webhook Script] script execution failed: ' + error);\n throw 'Execution failed: ' + error + '.';\n}",
            "host_access": "2",
            "usrgrpid": "7",
            "groupid": "0",
            "description": "",
            "confirmation": "",
            "type": "5",
            "execute_on": "1",
            "timeout": "30s",
            "parameters": [
                {
                    "name": "token",
                    "value": "{$WEBHOOK.TOKEN}"
                },
                {
                    "name": "host",
                    "value": "{HOST.HOST}"
                },
                {
                    "name": "v",
                    "value": "2.2"
                }
            ]
        }
    ],
    "id": 1
}
```

[comment]: # ({/new-6d428f32})

[comment]: # ({new-b0b740ec})
### See also

-   [Host](/manual/api/reference/host/object#object_details)
-   [Host group](/manual/api/reference/hostgroup/object#object_details)

[comment]: # ({/new-b0b740ec})

[comment]: # ({new-90dfc753})
### Source

CScript::get() in *ui/include/classes/api/services/CScript.php*.

[comment]: # ({/new-90dfc753})
