PHP API for RescueTime Licensed under the MIT license
See this online at http://rescuetime.derk-jan.org/
Simply place the rescuetime.php somewhere in your website. Require the file and enable the love.
require 'api/rescuetime.php'
For visualisation include chartjs on your HTML page.
And the javascript js/rescuetime.js
###Request
To do an API request, you need an api-key
. Get one here.
Create a new request object:
$rt_request = new RescueTimeRequest( $apikey );
and use one or more of the following functions to manipulate the request:
set_perspective
: Sets the perspective (rank, member, interval)set_resolution
: Sets the resolution (hour, week, day, month)set_startdate
: Sets the start date restrictionset_enddate
: Sets the end date restrictionrestrict_user
: Restricts to a certain user name or e-mailrestrict_group
: Restricts to a certain group namerestrict_kind
: Restricts to a certain kindrestrict_project
: Restricts to a certain projectrestrict_thing
: Restricts to a certain taxonomyrestrict_thingy
: Restricts to a certain sub-taxonomy The function calls are chainable, so you can: $rt_request->set_perspective( 'interval' )->set_resolution( 'hour' )->restrict_user( 'derk-jan@karrenbeld.info' ); When you are ready call the execute command: $rt_result = $rt_request->execute(); The request object is re-usable.
###Result You can manipulate the result, as long as the request was valid: $rt_result->is_error(); //checks if the result has data The data returned is tabular and the headers are provided seperately from the rows. Access those:
get_rows
: Gets the raw row dataget_row_headers
: Gets the row headers
You can GROUP BY
by issuing one of the get_by
commands. Does not manipulate the data:
get_rows_by_activity
: Group per activityget_rows_by_category
: Group per categoryget_rows_by_productivity
: Group per productivity valueget_rows_by_person
: Group per person (only valid with perspective member)get_rows_by_date
: Group per date (only valid with perspective interval)
You can WHERE
data by issuing one of the get_with
commands. Simply provide one value or an array of valid values. Does not manipulate the data:
get_rows_with_rank
: Gets a row with a rank (only valid with perspective rank)get_rows_with_activity
: Gets rows with that activityget_rows_with_category
: Gets rows with that categoryget_rows_with_productivity
: Gets rows with that productivityget_rows_with_person
: Gets rows with that person (only valid with perspective member)get_rows_between_time
: Gets rows between min and max time spent
You can filter data just like WHERE
issuing one of the filter
commands. Same arguments as the get_with
are valid. Note: you don't get a subsection of rows back. Instead a new RescueTimeResult
object is created with the subsection of data:
filter_time
: Filters the data on rows between min and max time spentfilter_min_time
: Filters the data on rows at least time spentfilter_max_time
: Filters the data on rows at most time spentfilter_activity
: Filters the data on rows with that activityfilter_category
: Filters the data on rows with that categoryfilter_productivity
: Filters the data on rows with that productivityfilter_unproductive
: Filters data to only unproductive rowsfilter_productive
: Filters data to only productive rowsfilter_person
: Filters rows for that person (only valid with perspective member)