CoCalc Shared FilesPublic / PYTHON / 00-ping.ipynbOpen in CoCalc with one click!
Author: Hal Snyder
Views : 49
Description: Ping the CoCalc API

API Examples 00-ping

This example will check whether you can reach the CoCalc API service.

Security key is not required for ping. You can pass empty strings for user and password in the HTTP POST authentication.

In [1]:
import requests from requests.auth import HTTPBasicAuth import json import pprint
In [2]:
pp = pprint.PrettyPrinter()
In [3]:
s = requests.Session() a = requests.adapters.HTTPAdapter(max_retries=3) s.mount('https://', a) url = "" auth = HTTPBasicAuth('','') headers = {'content-type': 'application/json'} r =,auth=auth,headers=headers) assert r.status_code ==,"bad status code {}".format(r.status_code) pp.pprint(r.json())
{'event': 'pong', 'id': 'ec94a824-46a4-48b5-808a-51946251bb8a', 'now': '2017-11-16T15:45:52.428Z'}
In [ ]: