The Chrometa API
Integrating passive time tracking into your app couldn't be simpler
Overview
Chrometa provides a simple rest-based API to import data into your application. A user generates a key for your application to use, and you can pull data for that user from the URL show below. Data is returned a day at a time, which gives you a good way to update a progress bar if you wish to pull more than one day's worth of data.
Sample Code
Here's some sample ruby code:
require "uri"
require "net/http"
require "rexml/document"
email = "sample_user@chrometa.com"
api_key = "e3637372f49518c89ef3668b44b002b15da10d88"
params = { "date" => "10/11/2010" }
url = URI.parse("https://api.chrometa.com/api/report")
req = Net::HTTP::Post.new(url.path)
req.basic_auth email, api_key
req.set_form_data(params)
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
resp = http.start {|http| http.request(req) }
puts "XML Response ==============================="
puts resp.body
puts "============================================"
xml = REXML::Document.new( resp.body )
root = xml.elements["chrometa-info"]
puts "Email : " + root.attributes["email"]
puts "Date : " + root.attributes["date"]
for client in root.elements do
puts " Client Name : " + client.attributes["name"]
for project in client.elements do
puts " Project Name : " + project.attributes["name"]
puts " Project Rate : " + project.attributes["rate"]
for time_entry in project.elements do
puts " Application : " + time_entry.attributes["application"]
puts " Timestamp : " + time_entry.attributes["timestamp"]
puts " Activity : " + time_entry.attributes["activity"]
puts " URL : " + time_entry.attributes["url"]
puts " Seconds : " + time_entry.attributes["seconds"]
puts " Billable : " + time_entry.attributes["billable"]
end
end
end
XML Format
The XML format is very simple. Here is an example document:
<chrometa-info date='2010-11-01' email='example@example.com'>
<client name='Client1'>
<project name='Project1' rate='5'>
<time_entry seconds='1552'
billable=''
timestamp='2010-11-01 22:26:39.179722'
activity='TweetDeck'
url='null'
application='TweetDeck.exe'/>
</project>
</client>
<client name='Client2'>
<project name='Project2' rate='0'>
<time_entry seconds='344'
billable='' timestamp='2010-11-01 21:04:17.892618'
activity='Mail - Ted'
url='https://mail.google.com/'
application='chrome.exe'/>
<time_entry seconds='1055'
billable=''
timestamp='2010-11-01 21:04:17.892618'
activity='Mail - Josh'
url='https://mail.google.com/'
application='chrome.exe'/>
</project>
</client>
</chrometa-info>
Note: Only data that people have classified under public (i.e. non-personal) projects is available via our API.
