Created
January 5, 2014 23:58
-
-
Save rdetert/8275895 to your computer and use it in GitHub Desktop.
An example of how to use the App Annie API to get sales using Ruby.
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
require "net/https" | |
require "uri" | |
require "date" | |
ACCOUNT_ID = "000000" | |
APP_ID = "000000000" | |
API_KEY = "0000000000000000000000000000000000000000" | |
yesterday = (Date.today.to_time - 1).strftime("%Y-%m-%d") | |
url = "https://api.appannie.com/v1/accounts/#{ACCOUNT_ID}/apps/#{APP_ID}/sales" | |
url += "?break_down=date+iap&start_date=#{yesterday}&end_date=#{yesterday}" | |
uri = URI.parse(url) | |
http = Net::HTTP.new(uri.host, uri.port) | |
http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
request = Net::HTTP::Get.new(uri.request_uri) | |
request.add_field "Authorization", "bearer #{API_KEY}" | |
response = http.request(request) | |
puts response.body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment