IMPORTANT ANNOUNCEMENT: On May 6, 2024, Carbon Black User eXchange (UeX) and Case Management will move to a new platform!
The Community will be in read-only mode starting April 19th, 7:00 AM PDT. Check out the blog post!
You will still be able to use the case portal to create and interact with your support cases until the transition, view more information here!

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

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

Environment

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

Objective

How To Install Python Based CB REST API On Windows 

Resolution

  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:
credentials.INI
credentials.psc
  1. Once the changes made, you should be able to run the script to retrieve the information using cbapi.

Additional Notes

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: https://github.com/carbonblack/cbapi-python/tree/master/examples/defense
  • Save the raw script locally on the machine and run the script. For example: C:\api>python list_devices.py
  • Output as follows:
    C:\api>python list_devices3.py
    ID        Hostname                                IP Address        Last Checkin
     Time
     20755512 LINUXlab                                10.70.1.xxx       1970-01-01 0
    0:00:00
     20748067 GovaTesting                             10.70.1.xxx       1970-01-01 0
    0:00:00
     21203863 Gova2019                                10.70.1.xxx       1970-01-01 0
    0:00:00
     22758394 WIND10-Rameez                           10.70.1.45        1970-01-01 0

Was this article helpful? Yes No
0% helpful (0/1)
Article Information
Author:
Creation Date:
‎06-24-2020
Views:
1048
Contributors