API Wrappers

Base Client

PassiveTotal API Interface.

class passivetotal.api.Client(username, api_key, server='api.passivetotal.org', version='v2', http_proxy=None, https_proxy=None)

Base client that all data sources will inherit from.

_dump_requests()

Dump requests being made.

_endpoint(endpoint, action, *url_args)

Return the URL for the action.

Parameters:
  • endpoint (str) – The controller
  • action (str) – The action provided by the controller
  • url_args – Additional endpoints(for endpoints that take part of the url as option)
Returns:

Full URL for the requested action

_get(endpoint, action, *url_args, **url_params)

Request API Endpoint - for GET methods.

Parameters:
  • endpoint (str) – Endpoint
  • action (str) – Endpoint Action
  • url_args – Additional endpoints(for endpoints that take part of the url as option)
  • url_params – Parameters to pass to url, typically query string
Returns:

response deserialized from JSON

_json(response)

JSON response from server.

Parameters:response – Response from the server
Throws ValueError:
 from requests’ response.json() error
Returns:response deserialized from JSON
_send_data(method, endpoint, action, data, *url_args, **url_params)

Submit to API Endpoint - for DELETE, PUT, POST methods.

Parameters:
  • method (str) – Method to use for the request
  • endpoint (str) – Endpoint
  • action (str) – Endpoint Action
  • url_args – Additional endpoints(for endpoints that take part of the url as option)
  • url_params – Parameters to pass to url, typically query string
Returns:

response deserialized from JSON

_undump_requests()

Reload request details.

classmethod from_config()

Method to return back a loaded instance.

DNS Request

class passivetotal.libs.dns.DnsRequest(*args, **kwargs)

Bases: passivetotal.api.Client

Client to interface with the DNS calls from the PassiveTotal API.

get_passive_dns(**kwargs)

Get passive DNS data based on a query value.

Reference:

Parameters:
  • query (str) – Query value to use when making the request for data
  • start (str) – Starting period for record filtering
  • end (str) – Ending period for record filtering
  • timeout (int) – Timeout to apply to source queries
  • sources (list) – List of sources to use for the query
Returns:

List of passive DNS results

get_unique_resolutions(**kwargs)

Get unique resolutions from passive DNS.

Reference:

Parameters:
  • query (str) – Query value to use when making the request for data
  • start (str) – Starting period for record filtering
  • end (str) – Ending period for record filtering
  • timeout (int) – Timeout to apply to source queries
  • sources (list) – List of sources to use for the query
Returns:

List of passive DNS unique resolutions

WHOIS Request

class passivetotal.libs.whois.WhoisRequest(*args, **kwargs)

Bases: passivetotal.api.Client

Client to interface with the WHOIS calls from the PassiveTotal API.

get_whois_details(**kwargs)

Get WHOIS details based on query value.

Reference:

Parameters:
  • query (str) – Query value to use when making the request for data
  • compact_record (str) – Return the record in a compact format
Returns:

WHOIS details for the query

search_whois_by_field(**kwargs)

Search WHOIS details based on query value and field.

Reference:

Parameters:
  • query (str) – Query value to use when making the request for data
  • compact_record (str) – Return the record in a compact format
  • field (str) – Field to run the query against
Returns:

WHOIS records matching the query

SSL Request

class passivetotal.libs.ssl.SslRequest(*args, **kwargs)

Bases: passivetotal.api.Client

Client to interface with the SSL calls from the PassiveTotal API.

get_ssl_certificate_details(**kwargs)

Get SSL certificate details based on query value.

Reference:

Parameters:
  • query (str) – SHA-1 or IP address
  • compact_record (str) – Return the record in a compact format
Returns:

SSL certificate details for the query

get_ssl_certificate_history(**kwargs)

Search SSL certificate history.

Reference:

Parameters:
  • query (str) – SHA-1 or IP address
  • compact_record (str) – Return the record in a compact format
  • field (str) – Field to run the query against
  • type (str) – Type of search to conduct
Returns:

WHOIS records matching the query

search_ssl_certificate_by_field(**kwargs)

Search SSL certificate details based on query value and field.

Reference:

Parameters:
  • query (str) – Query value to use when making the request for data
  • compact_record (str) – Return the record in a compact format
  • field (str) – Field to run the query against
  • type (str) – Type of search to conduct
Returns:

SSL certificates matching the query