title: Getting serial number from Host Inventory with Zabbix API (python)
body: <p>I'm trying to fetch a seriel number of a router with Zabbix API. I use the following code:</p>
  
  <pre><code>from pyzabbix import ZabbixAPI
  
  username = "myuser"
  password = "mypasswd"
  servername = "https://10.10.1.1/zabbix/api_jsonrpc.php"
  
  zapi = ZabbixAPI(servername)
  zapi.session.verify = False
  zapi.login(username, password)
  
  payload = {
                  "jsonrpc": "2.0",
                  "method": "host.get",
                  "params": {
                          "output": [
                                  "host"
                          ],
                          "selectInventory": [
                                  "serialno_a"
                          ],
                          "searchInventory": {
                                  "oob_ip": "174.145.27.15"
                          }
                  },
                  "id": 2
          }
  
  
  hosts = zapi.host.get(payload)
  print(hosts)
  </code></pre>
  
  <p>So, this code prints every single host in my Zabbix and every single item property in <strong>host</strong> object. What I want, is to print a value that is a property in <strong>host inventory</strong> object. Also, I want to restrict my code only to fetch the serial number associated with that IP address of 174.145.27.15. As far as I can understand, this code should do that.</p>
  
  <p>And below is the example syntax from Zabbix API's official reference.</p>
  
  <p><em>Searching by host inventory data</em></p>
  
  <p><em>Retrieve hosts that contain “Linux” in the host inventory “OS” field.</em></p>
  
  <pre><code>{
      "jsonrpc": "2.0",
      "method": "host.get",
      "params": {
          "output": [
              "host"
          ],
          "selectInventory": [
              "os"
          ],
          "searchInventory": {
              "os": "Linux"
          }
      },
      "id": 2,
      "auth": "7f9e00124c75e8f25facd5c093f3e9a0"
  }
  </code></pre>
  
  <p>And below is the link to the official API documentation, where you can see properties of <strong>host</strong> and <strong>host inventory</strong></p>
  
  <p><a href="https://www.zabbix.com/documentation/3.0/manual/api/reference/host/object" rel="nofollow noreferrer">https://www.zabbix.com/documentation/3.0/manual/api/reference/host/object</a></p>
  
  <p>I'm really lost here and can't find any help by googling around. Also, I don't really understand what is the point of that <strong>"id": 2</strong> because I get the same result no matter what the value is.</p>