Reference

API

nuclei.api.main.create_session()[source]

Initialising session object to call the NUCLEI endpoints. Provide the user token from https://nuclei.cemsbv.io/#/personal-access-tokens to upon request or set as environment variable.

Return type:

Session

Client

class nuclei.client.main.NucleiClient[source]
property applications: List[str]

Provide available API’s in the Nuclei landscape.

Returns:

out – Names of the API’s

Return type:

list[str]

call_endpoint(app, endpoint, methode='auto', version='latest', schema=None, return_response=False)[source]

Calls an API in the nuclei landscape.

Note

The provided schema is serialized by the utils.serialize_jsonifyable_object. For get request the payload is passed to the params parameter of request.get function. For post request the payload is passed to the json parameter of request.post function. This has an effect on the request content type.

Parameters:
  • app (str) – Name of the API. Call applications to obtain a list with all applications.

  • endpoint (str) – Name of the API’s endpoint. call get_endpoints to obtain a list with all applications for a given API.

  • methode (str) – default is auto HTTP methode used to call endpoint. When auto methode is selected the HTTP methode is obtained from the openapi docs. Please note that this is the first one. call get_endpoint_type to obtain list with all methods related to the endpoint.

  • version (str, optional) – default is latest. API version used. Call get_versions to obtain a list with all versions of a specific application.

  • schema (dict or json-string, optional) – Default is None The parameter schema for the API. Take a look at the API documentation.

  • return_response (bool, optional) – Default is False Return the requests response instead of the parsed data object.

Return type:

Any

Returns:

  • json (dict) – json response

  • text (str) – text response

  • content (bytes) – content response

  • out (Response) – requests response object

  • figure (Image) – IPython display Image object

Raises:
  • RuntimeError: – Thrown when response is between 400 and 600 to see if there was a client error or a server error.

  • NotImplementedError: – HTTP methode not get or post request

  • ConnectionError: – Application not available

  • TypeError: – Wrong type for an argument

  • ValueError: – Wrong value for an argument

get_application_version(app, version='latest')[source]

Provide the semanctic version of the API in the Nuclei landscape.

Parameters:
  • app (str) – Name of the API. Call applications to obtain a list with all applications.

  • version (str, optional) – default is latest. API version used. Call get_versions to obtain a list with all version of a specific application.

Returns:

out – Semantic Version of the API

Return type:

str

Raises:
  • ConnectionError: – Application not available

  • TypeError: – Wrong type for app or version argument

  • ValueError: – Wrong value for app or version argument

get_endpoint_type(app, endpoint, version='latest')[source]

Get a list of HTTP methods used for this endpoint.

Parameters:
  • app (str) – Name of the API. Call applications to obtain a list with all applications.

  • endpoint (str) – url of the endpoint.

  • version (str, optional) – default is latest. API version used. Call get_versions to obtain a list with all version of a specific application.

Returns:

methods – List of HTTP methods used for endpoint

Return type:

List[str]

Raises:
  • ConnectionError: – Application not available

  • TypeError: – Wrong type for an argument

  • ValueError: – Wrong value for an argument

get_endpoints(app, version='latest')[source]

Get available endpoints of single API.

Parameters:
  • app (str) – Name of the API. Call applications to obtain a list with all applications.

  • version (str, optional) – default is latest API version used. Call get_versions to obtain a list with all version of a specific application.

Returns:

endpoints – Endpoint urls.

Return type:

list[str]

Raises:
  • ConnectionError: – Application not available

  • TypeError: – Wrong type for app or version argument

  • ValueError: – Wrong value for app or version argument

get_url(app, version='latest')[source]

Get API’s url

Parameters:
  • app (str) – Name of the API. Call applications to obtain a list with all applications.

  • version (str, optional) – default is latest. API version used. Call get_versions to obtain a list with all version of a specific application.

Returns:

url

Return type:

str

Raises:
  • TypeError: – Wrong type for app or version argument

  • ValueError: – Wrong value for app or version argument

get_versions(app)[source]

Provide available API’s versions in the Nuclei landscape.

Parameters:

app (str) – Name of the API. Call applications to obtain a list with all applications.

Returns:

out – Versions of the API.

Return type:

list[str]

Raises:
  • TypeError: – Wrong type for app argument

  • ValueError: – Wrong value for app argument

property user_permissions: List[str | None]

Provide the user permissions of your token.

Returns:

out – Names of the API’s

Return type:

list[str]

Utils

nuclei.client.utils.serialize_jsonifyable_object(obj)[source]

Takes an object and converts it to a JSON-serializable object. Uses orjson.dumps() to do the heavy lifting.

Serializable objects are (amongst others):
  • python natives

  • dataclasses

  • datetime objects

  • numpy objects

Some known objects that are not serializable:
  • numpy.float16

  • numpy.float128

Parameters:

obj (Any) – The object to serialize

Returns:

json-string – a JSON string

Return type:

str

nuclei.client.utils.serialize_json_string(obj)[source]

Takes an object and converts it to a JSON-string. Uses orjson.dumps() to do the heavy lifting.

Serializable objects are (amongst others):
  • python natives

  • dataclasses

  • datetime objects

  • numpy objects

Some known objects that are not serializable:
  • numpy.float16

  • numpy.float128

Parameters:

obj (Any) – The object to serialize

Returns:

json-string – a JSON string

Return type:

str

nuclei.client.utils.serialize_json_bytes(obj)[source]

Takes an object and converts it to a JSON-bytes-string. Uses orjson.dumps() to do the heavy lifting.

Serializable objects are (amongst others):
  • python natives

  • dataclasses

  • datetime objects

  • numpy objects

Some known objects that are not serializable:
  • numpy.float16

  • numpy.float128

Options:
  • Serialize datetime.datetime objects without a tzinfo as UTC. This has no effect on datetime.datetime objects that have tzinfo set.

  • Serialize a UTC timezone on datetime.datetime instances as Z instead of +00:00

  • Serialize numpy.ndarray instances. For more, see numpy.

Parameters:

obj (Any) – The object to serialize

Returns:

json-string – a JSON bytes-string

Return type:

bytes