Carbon Black Cloud: How To Install Python Based CB REST API On Windows
search cancel

Carbon Black Cloud: How To Install Python Based CB REST API On Windows


Article ID: 290035


Updated On:


Carbon Black Cloud Endpoint Standard (formerly Cb Defense) Carbon Black Cloud Enterprise EDR (formerly Cb Threathunter)


How To Install Python Based CB REST API On Windows 


  • Carbon Black Cloud: All Supported Versions
  • Microsoft Windows: All Supported Versions
  • Python: All Supported Versions


  1. Install Python How to Install Python On Windows
  2. Install Pip How to Install PIP on Windows
  3. Once the Python and pip are installed open a command prompt and run the following command line:
pip install cbapi
  1. Cbapi will be installed in the location where you have installed python. So navigate to the python folder, For example, in windows machine the default location is: C:\Python27\Scripts
  2. Once changed the directory to C:\Python27\Scripts, run the following command line: 
python cbapi-defense configure
  1. Once the cbapi-defense is configured, it will ask for the URL to the CB Defense API server. Please find your respective backend URL using:API URL
  2. Once entered the API URL it will prompt for Connector ID and API Key. Please find the steps below to create an API key:
  • Log into the CB Cloud console
  • Go to settings
  • Go to API Access
  • Create an API Access key
  1. After entering the API credentials, a credential.defense file will be created in the user location, for example: C:\Users\Administrator\.carbonblack\credential.defense
  2. Open the credentials.defense file with notepad and save as .INI file in the same location and rename the credentials.defense to credentials.psc. There should be two files as shown below:
  1. Once the changes made, you should be able to run the script to retrieve the information using cbapi.

Additional Information

Note: Make sure that python and pip should be installed on the machine before installing cbapi.

Example output:
  • Few cbapi-python sample scripts are available in the Git-hub. Please follow this link:
  • Save the raw script locally on the machine and run the script. For example: C:\api>python
  • Output as follows:
    ID        Hostname                                IP Address        Last Checkin
     20755512 LINUXlab                             1970-01-01 0
     20748067 GovaTesting                          1970-01-01 0
     21203863 Gova2019                             1970-01-01 0
     22758394 WIND10-Rameez                         1970-01-01 0