--- title: "Quickstart: Python" slug: "quickstart-python" updated: 2026-09-10T17:39:47Z published: 2026-09-10T17:39:47Z canonical: "docs.redcanary.com/quickstart-python" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.redcanary.com/llms.txt > Use this file to discover all available pages before exploring further. # Python Example Follow these necessary steps to write and run a simple Python script that queries the Zscaler MDR API. ## Prerequisites Before running any code, ensure you have the following: - [Your API token](/doc/docs/red-canary-rest-api#generating-an-api-authentication-token) - [The latest recommended version of Python](https://www.python.org/downloads/) ## Create your Python program Create a Python program called `example.py`, which fetches a list of endpoints from a subdomain. 1. In your working directory, create a new file called `example.py`, and then copy the following code into it. ```plaintext import requests # Build a GET request. url = 'https://.my.redcanary.co/openapi/v3/endpoints' headers = {'X-Api-Key': ''} # Send the request and save the response. response = requests.get(url, headers=headers) # Print the response body. print(response.content) ``` 2. In `example.py`, replace with the subdomain you want to query. 3. In `example.py`, replace with your API key. 4. Save `example.py`. ## Run the example Open the command line, and run your example. ```plaintext python3 example.py ``` The program should print a JSON object containing the first page of endpoints associated with the subdomain. ## Customize your request with parameters You can use HTTP parameters to customize the results of your request. Visit the [Zscaler MDR API docs](https://go.my.redcanary.co/openapi/v3/docs/index.html) for a list of supported parameters for each API endpoint. ## Example: Limit the number of endpoints returned Limit the number of endpoints returned by `example.py` using the `per_page` parameter. 1. Open `example.py`, and then edit the GET request to match the following: ```plaintext # Build a GET request. url = 'https://.my.redcanary.co/openapi/v3/endpoints' headers = {'X-Api-Key': ''} params = {'per_page': '1'} # Send the request and save the response. response = requests.get(url, headers=headers, params=params) ``` This sets the number of requested endpoints to one. 2. Save `example.py`, and then run the example. The program should print a JSON object containing exactly one endpoint.