OWASP ZAP API parameter to control maximum crawl depth

I'm trying to control the crawl depth of OWASP ZAP tool. I'm able to achieve it easily when using GUI mode.

However, while accessing through python API, I'm unable to do so.

I have tried setting the parameter as spider.setOptionMaxDepth = 1 and tried initiation spider. However it isn't taking the crawl depth I set. I have also tried setting the other parameter "spider.optionMaxDepth" = 1 without any luck. Please suggest me the correct parameter name or the syntax to be used to control crawl depth via Python API.

2 answers