--- title: "Quickstart: Ruby" slug: "quickstart-ruby" updated: 2026-09-10T17:40:34Z published: 2026-09-10T17:40:34Z canonical: "docs.redcanary.com/quickstart-ruby" --- > ## 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. # Ruby Example Follow these necessary steps to write and run a simple Ruby program 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 Ruby](https://www.ruby-lang.org/en/downloads/). ## Create your Ruby program Create a Ruby program called `example.rb`, which fetches a list of endpoints from a subdomain. 1. In your working directory, create a new file called `example.rb`, and then copy the following code into it. ```plaintext require "net/http" # Build a GET request. uri = URI("https://.my.redcanary.co/openapi/v3/endpoints") key = "" request = Net::HTTP::GET.new(uri) request["X-API-Key"] = key # Perform the request and save the response. response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http|    http.request(request) } # Print the response body. puts response.body ``` 2. In `example.rb`, replace with the subdomain you want to query. 3. In `example.rb`, replace with your API key. 4. Save `example.rb`. ## Build and run the example Run your example with the following command. ```plaintext ruby example.rb ``` 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.rb` using the `per_page` parameter. 1. Open `example.rb`, and then find the URL passed to `URI()`. 2. Add the following to the end of the URL: ```plaintext ?per_page=1 ``` This sets the number of requested endpoints to one. 3. Save `example.rb`, and then run the example. The program should print a JSON object containing exactly one endpoint.