I'm looking for help using multiple filters in my API call. For example, I can filter by "Group-A," but I'm not sure how to filter for "Group-A" and "Group-B. Please see below
api_url = "https://server/api/table.xml?content=sensors&columns=objid,group,device,sensor,status,uptimetime,uptime,knowntime&apitoken=KEY" query = {'filter_type':'ping','filter_group':'GROUP-A'} response = requests.get(api_url, verify=False, params=query)
Article Comments
I tried to added multiple groups into the parameter, but it's not working. Do I need to format the list differently?
C:\Users\name\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py:1095: InsecureRequestWarning: Unverified HTTPS request is being made to host 'prtg.domain.local'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings warnings.warn( <?xml version="1.0" encoding="UTF-8"?> <sensors totalcount="0" listend="1"> <prtg-version>23.2.83.1760</prtg-version> </sensors>
May, 2023 - Permalink
Hello
I have checked this internally and as we use API v1 it is not possible to use multiple filters in an API call
Regards
May, 2023 - Permalink
Is there documentation for API v2? I have API v2 activated. I assumed that I was using API v2.
May, 2023 - Permalink
Hello
Thank you for your response,
There are some documents here for you to check about APIv2:
- https://www.paessler.com/support/prtg/api/v2/overview
- https://www.paessler.com/support/prtg/api/v2/oas
If you have any questions please let us know
Regards
May, 2023 - Permalink
Hello Dear customer,
Thank you for contacting PRTG support.
To filter for multiple groups in your API call using the PRTG API, you can make use of the filter_group parameter with multiple values separated by a comma. Here's an example of how you can modify your code to filter for both "Group-A" and "Group-B":
{{{import requests
api_url = "https://server/api/table.xml?content=sensors&columns=objid,group,device,sensor,status,uptimetime,uptime,knowntime&apitoken=KEY"
query = {'filter_type': 'ping', 'filter_group': 'GROUP-A,GROUP-B'}
response = requests.get(api_url, verify=False, params=query)}}}
In the filter_group parameter, you can provide a comma-separated list of the groups you want to filter for. In the example above, it filters for both "Group-A" and "Group-B". You can modify the list to include any additional groups you require.
Make sure to replace 'GROUP-A' and 'GROUP-B' with the actual names of the groups you want to filter. Also, ensure that the API token (KEY) is properly replaced with your actual PRTG API token.
This modified code will retrieve the sensors that belong to either "Group-A" or "Group-B" based on the provided filter criteria.
May, 2023 - Permalink