Last active
November 7, 2019 15:35
-
-
Save ewlarson/37dd90e95deaf5eec41cc8a31bf727c9 to your computer and use it in GitHub Desktop.
Gimlet API - Example GET request to list entries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ruby Example | |
require 'date' | |
require 'faraday' | |
require 'json' | |
# Required API Variables | |
domain = 'your_domain' | |
email = 'your_email_address' | |
api_key = 'your_api_key' | |
site_id = 'your_site_id' | |
# Report Dates | |
today = Date.today | |
thirty_days_ago = today - 30 | |
# URL and Path | |
url = "https://#{domain}.gimlet.us" | |
path = "/api/v1/sites/#{site_id}/questions.json?start_date=#{thirty_days_ago.to_s}&end_date=#{today.to_s}" | |
# New connection with base URL and path | |
conn = Faraday.new(url: url) # New connection with base URL | |
conn.basic_auth(email, api_key) # Set the authentication header | |
response = conn.get(path) # GET API request | |
# Do what you need with the data | |
results = JSON.parse(response.body) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment