How to use the shodan.helpers.api_request function in shodan

To help you get started, we’ve selected a few shodan examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github achillean / shodan-python / shodan / client.py View on Github external
"""Edit the IPs that should be monitored by the alert.

        :param aid: Alert ID
        :type name: str
        :param ip: Network range(s) to monitor
        :type ip: str OR list of str

        :returns: A dict describing the alert
        """
        data = {
            'filters': {
                'ip': ip,
            },
        }

        response = api_request(self.api_key, '/shodan/alert/{}'.format(aid), data=data, params={}, method='post',
                               proxies=self._session.proxies)

        return response
github achillean / shodan-python / shodan / client.py View on Github external
def alerts(self, aid=None, include_expired=True):
        """List all of the active alerts that the user created."""
        if aid:
            func = '/shodan/alert/%s/info' % aid
        else:
            func = '/shodan/alert/info'

        response = api_request(self.api_key, func, params={
            'include_expired': include_expired,
        }, proxies=self._session.proxies)

        return response
github achillean / shodan-python / shodan / client.py View on Github external
def delete_alert(self, aid):
        """Delete the alert with the given ID."""
        func = '/shodan/alert/%s' % aid

        response = api_request(self.api_key, func, params={}, method='delete',
                               proxies=self._session.proxies)

        return response
github achillean / shodan-python / shodan / client.py View on Github external
:param name: Name of the alert
        :type name: str
        :param ip: Network range(s) to monitor
        :type ip: str OR list of str

        :returns: A dict describing the alert
        """
        data = {
            'name': name,
            'filters': {
                'ip': ip,
            },
            'expires': expires,
        }

        response = api_request(self.api_key, '/shodan/alert', data=data, params={}, method='post',
                               proxies=self._session.proxies)

        return response