Skip to content

Data Analytics API

Compare
Choose a tag to compare
@leesharma leesharma released this 23 Apr 17:03
· 54 commits to main since this release

Scope

v0.2.0 provides nearly-full coverage of the RescueTime Analytic Data API.

Features

# Basics
@client = Rescuetime::Client.new

@client.api_key?            #=> false
@client.valid_credentials?  #=> false
@client.activities          #=> Rescuetime::MissingCredentials

@client.api_key='invalid'
@client.api_key?            #=> true
@client.valid_credentials?  #=> false
@client.activities          #=> Rescuetime::InvalidCredentials

@client.api_key= VALID_KEY
@client.valid_credentials?  #=> true




# #productivity_levels
@client.productivity_levels     #=> Hash
@client.productivity_levels[-2] #=> 'Very Unproductive'
@client.productivity_levels[0]  #=> 'Neutral'




# #activities
@client.activities          #=> Array<Hash>
@client.activities.first    #=> Hash

#   :by (report order/perspective)
@client.activities(by: 'rank')    # returns ranked report by time spent per activity/category
@client.activities(by: 'time')    # returns chronological report
@client.activities(by: 'member')  # returns report grouped by member

#   :detail (detail level of report)
@client.activities(detail: 'overview')    # returns report at the 'overview' level (ie. Entertainment)
@client.activities(detail: 'category')    # returns report at the 'category' level (ie. News and Opionion)
@client.activities(detail: 'activity')    # returns report at the 'activity' level (ie. reddit.com)
                                          # note: 'productivity' and 'efficiency' are options as well, but
                                          #       #productivity and #efficiency are the preferred way to 
                                          #       get that information.

#   :date, :from, and :to (date range of report)
@client.activities(date: '2015-04-02')    # returns report for selected date
@client.activities(from: '2015-04-18')    # returns report between selected and current date
@client.activities(from: Time.new(2015,04,19))            # time objects work too
@client.activities(from: '2015-04-02', to: '2015-04-02')  # returns report between start and end date

#   :interval (time interval of the report)
@client.activities(by: 'time', interval: 'minute')        # returns report in 5-minute intervals
@client.activities(by: 'time', interval: 'hour')          # returns report in 1-hour intervals
@client.activities(by: 'time', interval: 'day')           # returns report in 1-day intervals
@client.activities(by: 'time', interval: 'week')          # returns report in 1-week intervals
@client.activities(by: 'time', interval: 'month')         # returns report in 1-month intervals

#   :format (output format)
@client.activities                  #=> Array<Hash>
@client.activities(format: 'csv')   #=> CSV




# #productivity
@client.productivity(...)                 # productivity takes the same options as #activities except :detail
                                          # returns a productivity report with the given options



# #efficiency
@client.efficiency(...)                   # efficiency takes the same options as #activities except :detail
                                          # returns an efficiency report with the given options



# All of this can be used together
@client.efficiency( from: '2015-03-20',     # returns weekly efficiency report between March 20th and 
                    to: '2015-04-20' ,      #   April 20th of 2015 by member in csv format
                    interval: 'week', 
                    format: 'csv' )