Hi
you can either for mgmt api use the SDK from Checkpoint ( https://github.com/CheckPointSW/cp_mgmt_api_python_sdk ) for logging in and checking if logging in was successful. like:
if login_res.success is False:
print("Login failed: {}".format(login_res.error_message))
raise SystemExit("UNKNOWN")
do-something = client.api_call("show-something")
if login_res.success just checks if the respons´s JSON field "success" has value false
I assume you have some kind of Monitoring in place that looks for Responses like "OK", "WARNING, "CRITICAL" or "UNKNOWN"? i.e. Nagios based. With the SystemExit you can raise these towards the application.
(remember to logoff the session afterwards, otherwise you´ll end up with lots of orphaned sessions)
Maybe this helps:
https://github.com/leinadred/CP_IPS-Update-Monitoring4Nagios
(just take out the IPS stuff 🙂 )
For gateway API there is no SDK AFAIK, so you might have to "login manually" via sending http requests in json and so... it´s possible with some time
Daniel