Skip to content

Instantly share code, notes, and snippets.

@tjl2
Last active December 22, 2015 22:18
Show Gist options
  • Save tjl2/6538788 to your computer and use it in GitHub Desktop.
Save tjl2/6538788 to your computer and use it in GitHub Desktop.
Getting user IDs from the GitHub API
# You'll need the rest-client and json gems installed to use this
require 'rubygems'
require 'rest-client'
require 'json'
HOSTNAME = '' # Put your GHE hostname here
USERNAME = '' # Put your Admin user name here
PASSWORD = '' # Put your Admin user password here
# Please change this to https, if you are using SSL on your GHE installation
api_url = "http://#{USERNAME}:#{PASSWORD}@#{HOSTNAME}/api/v3/"
json_response = JSON.parse(RestClient.get(api_url + 'users'))
json_response.each do |user|
puts "#{user['login']} has ID #{user['id']}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment