Skip to main content
RapidDev - Software Development Agency
lovable-integrationsEdge Function Integration

How to Integrate Lovable with RescueTime

Integrate RescueTime with Lovable by building a Supabase Edge Function that proxies the RescueTime Analytic Data API using your personal API key. Store the key in Cloud → Secrets, create an Edge Function to fetch daily summaries, productivity scores, and category breakdowns, then prompt Lovable to generate a personal productivity dashboard with charts and trend analysis.

What you'll learn

  • How to authenticate with the RescueTime Analytic Data API using an API key passed as a query parameter inside a Deno Edge Function
  • How to fetch daily summary data including total hours, productive hours, and productivity pulse score
  • How to retrieve time-use category breakdowns showing how many hours were spent on different activity types
  • How to build a personal productivity dashboard in Lovable with trend charts showing focus scores over time
  • How to schedule daily data pulls using Supabase's pg_cron extension to cache RescueTime data in your own database
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate14 min read40 minutesProductivityMarch 2026RapidDev Engineering Team
TL;DR

Integrate RescueTime with Lovable by building a Supabase Edge Function that proxies the RescueTime Analytic Data API using your personal API key. Store the key in Cloud → Secrets, create an Edge Function to fetch daily summaries, productivity scores, and category breakdowns, then prompt Lovable to generate a personal productivity dashboard with charts and trend analysis.

Build a Personal Productivity Dashboard with RescueTime and Lovable

RescueTime distinguishes itself from manual time trackers by running completely automatically. Once installed on your computer or mobile device, it silently categorizes every application, website, and document you interact with — no start/stop buttons required. This automatic approach generates highly accurate data about how you actually spend your time, including idle periods, distracted browsing, and deep focus sessions. The result is a Productivity Pulse score (0-100) for each day that reflects your overall focus quality.

Integrating RescueTime data into a Lovable app lets you build custom productivity dashboards that go beyond what RescueTime's own interface offers. You can combine RescueTime data with other metrics stored in Supabase, create goal tracking interfaces, build weekly review pages for personal retrospectives, or surface productivity insights in team management tools. Because RescueTime tracks activity passively, the data is always available without any manual input from the user.

The RescueTime Analytic Data API uses a simple query-parameter authentication pattern: append ?key=YOUR_API_KEY to any request. The API returns JSON data about daily summaries, productivity scores, top applications and websites, and time spent in different categories. The Lovable Edge Function pattern keeps this key server-side, proxying requests safely while your frontend displays the results in rich charts and summary cards.

Integration method

Edge Function Integration

RescueTime has no native Lovable connector, so its Analytic Data API is accessed through a Supabase Edge Function proxy running on Deno. The Edge Function appends your API key to every request as a query parameter and returns structured productivity data to your Lovable frontend. Because the API key grants read access to all activity data, it must remain server-side in Cloud → Secrets and never appear in browser code.

Prerequisites

  • A RescueTime account with the desktop or mobile client installed and running for at least a few days (to have data to display)
  • Your RescueTime API key — found at rescuetime.com/anapi/manage under 'Create a new API key'
  • A Lovable project with Lovable Cloud enabled
  • Basic familiarity with Lovable's Cloud → Secrets panel
  • RescueTime Premium recommended for full category and application-level data (free plan may have limited API access)

Step-by-step guide

1

Generate your RescueTime API key

Log in to your RescueTime account at rescuetime.com. Navigate to the API management page at rescuetime.com/anapi/manage — you can also find this by clicking your username in the top-right corner, selecting 'API Keys' from the profile menu, or visiting Settings → Integrations → API Keys. On the API management page, you will see a section for creating new API keys. Click 'Create a new API key'. You will be prompted to give the key a name (something like 'Lovable Dashboard') and to specify the purpose — select 'For myself' since this key will access your personal data. Leave the scope at the default 'All' to ensure the key can access daily summaries, category data, and productivity scores. Once created, the key appears as a long alphanumeric string. Copy it immediately — RescueTime does not show the full key again after you leave the page. Store it temporarily in a secure location like a password manager. The RescueTime Analytic Data API base URL is https://www.rescuetime.com/anapi/data and all requests use the format: https://www.rescuetime.com/anapi/data?key=YOUR_KEY&format=json&perspective=interval&resolution_time=day.

Pro tip: RescueTime's free plan has limited API access. If you see 'premium required' errors on certain endpoints, you may need to upgrade to RescueTime Premium to access full category breakdown and application-level data via the API.

Expected result: You have a RescueTime API key ready to add to Cloud Secrets. The key grants read access to your personal productivity and time-use data.

2

Store the RescueTime API key in Cloud Secrets

In your Lovable project, open the Cloud tab by clicking the '+' icon next to the Preview panel at the top of the editor. In the Cloud tab sidebar, click 'Secrets' to open the Secrets management panel. Click 'Add new secret'. Set the Name to RESCUETIME_API_KEY (exactly as written, all uppercase with underscore). Paste your RescueTime API key as the Value. Click Save. This secret is now encrypted and stored server-side in your Lovable Cloud project. It will be injected into Edge Function environments automatically. Your Deno Edge Function code will access it via Deno.env.get('RESCUETIME_API_KEY'). Lovable's security layer — which prevents approximately 1,200 API keys from being hardcoded into application code every day — will flag any attempt to use this value in frontend React code, ensuring your RescueTime key stays protected. Unlike services that require multiple credentials (workspace ID, secret key, etc.), RescueTime only needs a single API key, making the secrets configuration minimal. One secret is all you need for this integration.

Pro tip: RescueTime API keys can be revoked and regenerated from the same API management page at any time. If you ever suspect the key has been exposed, generate a new one and update the Cloud Secret immediately — no code changes are needed.

Expected result: RESCUETIME_API_KEY appears in your Cloud → Secrets panel with its value masked. The secret is ready to be consumed by Edge Functions.

3

Create the RescueTime Edge Function proxy

The Edge Function acts as a secure intermediary between your Lovable frontend and the RescueTime API. It reads the API key from the Deno environment, constructs authenticated API URLs, fetches data from RescueTime, and returns it to the frontend. Because all authentication happens server-side, the browser never sees the API key. The RescueTime Analytic Data API uses query parameters for both authentication (key) and data selection (perspective, resolution_time, restrict_begin, restrict_end, restrict_kind). The Edge Function translates simple action names from the frontend into properly formatted RescueTime API URLs with all required parameters.

Lovable Prompt

Create a Supabase Edge Function called 'rescuetime-proxy' at supabase/functions/rescuetime-proxy/index.ts. It should read RESCUETIME_API_KEY from Deno.env.get() and proxy requests to the RescueTime Analytic Data API. Accept POST requests with a JSON body containing an 'action' field and optional 'payload'. Supported actions: 'get_daily_summary' (fetch today's summary data using perspective=interval&resolution_time=day&restrict_begin=TODAY&restrict_end=TODAY), 'get_date_range_summary' (fetch summaries for a date range using start_date and end_date from payload), 'get_category_data' (fetch category breakdown for a date range with restrict_kind=category), 'get_productivity_data' (fetch productivity level breakdown with restrict_kind=productivity), 'get_top_apps' (fetch top applications for a date using restrict_kind=activity&restrict_begin=DATE). All requests use format=json. Return CORS headers. Handle errors gracefully.

Paste this in Lovable chat

supabase/functions/rescuetime-proxy/index.ts
1// supabase/functions/rescuetime-proxy/index.ts
2import { serve } from 'https://deno.land/std@0.168.0/http/server.ts';
3
4const corsHeaders = {
5 'Access-Control-Allow-Origin': '*',
6 'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
7};
8
9const BASE_URL = 'https://www.rescuetime.com/anapi/data';
10
11serve(async (req) => {
12 if (req.method === 'OPTIONS') {
13 return new Response('ok', { headers: corsHeaders });
14 }
15
16 try {
17 const apiKey = Deno.env.get('RESCUETIME_API_KEY');
18 if (!apiKey) {
19 return new Response(
20 JSON.stringify({ error: 'RESCUETIME_API_KEY not configured' }),
21 { status: 500, headers: { ...corsHeaders, 'Content-Type': 'application/json' } }
22 );
23 }
24
25 const { action, payload = {} } = await req.json();
26 const today = new Date().toISOString().split('T')[0];
27 const params = new URLSearchParams({ key: apiKey, format: 'json' });
28
29 switch (action) {
30 case 'get_daily_summary':
31 params.set('perspective', 'interval');
32 params.set('resolution_time', 'day');
33 params.set('restrict_begin', payload.date || today);
34 params.set('restrict_end', payload.date || today);
35 break;
36 case 'get_date_range_summary':
37 params.set('perspective', 'interval');
38 params.set('resolution_time', 'day');
39 params.set('restrict_begin', payload.start_date);
40 params.set('restrict_end', payload.end_date);
41 break;
42 case 'get_category_data':
43 params.set('perspective', 'rank');
44 params.set('resolution_time', 'day');
45 params.set('restrict_kind', 'category');
46 params.set('restrict_begin', payload.start_date || today);
47 params.set('restrict_end', payload.end_date || today);
48 break;
49 case 'get_productivity_data':
50 params.set('perspective', 'rank');
51 params.set('resolution_time', 'day');
52 params.set('restrict_kind', 'productivity');
53 params.set('restrict_begin', payload.start_date || today);
54 params.set('restrict_end', payload.end_date || today);
55 break;
56 case 'get_top_apps':
57 params.set('perspective', 'rank');
58 params.set('resolution_time', 'day');
59 params.set('restrict_kind', 'activity');
60 params.set('restrict_begin', payload.date || today);
61 params.set('restrict_end', payload.date || today);
62 params.set('restrict_begin', payload.date || today);
63 break;
64 default:
65 return new Response(
66 JSON.stringify({ error: `Unknown action: ${action}` }),
67 { status: 400, headers: { ...corsHeaders, 'Content-Type': 'application/json' } }
68 );
69 }
70
71 const res = await fetch(`${BASE_URL}?${params.toString()}`);
72 const data = await res.json();
73
74 return new Response(JSON.stringify(data), {
75 status: res.status,
76 headers: { ...corsHeaders, 'Content-Type': 'application/json' },
77 });
78 } catch (err) {
79 return new Response(
80 JSON.stringify({ error: err.message }),
81 { status: 500, headers: { ...corsHeaders, 'Content-Type': 'application/json' } }
82 );
83 }
84});

Pro tip: The RescueTime API returns data in a rows/columns format — the 'row_headers' array defines column names and 'rows' contains the data arrays. Map them together in your frontend: data.rows.map(row => Object.fromEntries(row.map((val, i) => [data.row_headers[i], val]))).

Expected result: Lovable creates and deploys the rescuetime-proxy Edge Function. It appears in Cloud → Logs and is ready to receive requests from your frontend components.

4

Build the productivity dashboard UI

With the Edge Function in place, ask Lovable to build the main dashboard page. The dashboard should fetch daily summary data when it loads and display the key productivity metrics that RescueTime tracks: Productivity Pulse score, total time logged, productive versus distracting time breakdown, and a list of top applications. The design should make the Pulse score visually prominent since it is the single most useful number RescueTime produces — a 0-100 daily focus quality rating. The dashboard should also show a 30-day trend line so users can see their productivity patterns over time, not just today's snapshot. This requires fetching a date range summary and rendering it as a chart using shadcn/ui's built-in chart components which wrap Recharts.

Lovable Prompt

Build a productivity dashboard page that fetches data from the rescuetime-proxy Edge Function. On page load, fetch today's daily summary using action 'get_daily_summary' and the past 30 days using action 'get_date_range_summary'. Display: 1) A large Productivity Pulse score (0-100) gauge at the top — color it red below 50, yellow 50-70, green above 70. 2) Three metric cards below: Total Time Tracked, Productive Hours, and Distracting Hours. 3) A line chart showing the daily Productivity Pulse score for the past 30 days. 4) A section showing today's category breakdown from action 'get_category_data' as a horizontal bar chart. 5) A top 10 applications list from action 'get_top_apps' showing app name and time spent. Show loading skeletons while data fetches and handle API errors with a clear error message.

Paste this in Lovable chat

Pro tip: RescueTime's Productivity Pulse is calculated from productivity levels: Very Productive (+2), Productive (+1), Neutral (0), Distracting (-1), Very Distracting (-2), normalized to a 0-100 scale. A score above 72 is generally considered a focused day.

Expected result: A productivity dashboard renders with your real RescueTime data. The Pulse score gauge shows today's focus quality and the 30-day trend line displays your historical pattern.

Common use cases

Personal daily focus score dashboard

Build a dashboard that displays your RescueTime Productivity Pulse for today and the past 30 days as a trend line chart. See your total productive hours versus distracting hours side by side, along with the top five most-used applications and websites. This gives you a daily habit tracker view of your focus quality without manually logging anything.

Lovable Prompt

Create a personal productivity dashboard that calls our rescuetime-proxy Edge Function to fetch today's daily summary data. Show the Productivity Pulse score (0-100) in a large circular gauge at the top. Below that show two columns: 'Productive Hours' and 'Distracting Hours' as numbers. Add a line chart showing the Productivity Pulse score for the past 30 days. At the bottom show a top 5 list of applications/websites used today by time spent. Use a clean dark theme with green for productive time and red for distracting time.

Copy this prompt to try it in Lovable

Weekly productivity review with category breakdown

Create a weekly review page that aggregates RescueTime category data across a full week and presents it as a pie chart and detail table. Categories include Software Development, Communication, Social Media, and others that RescueTime assigns automatically. Use this for weekly retrospectives to identify patterns in how time is being distributed across different types of work.

Lovable Prompt

Build a Weekly Review page that fetches a week of RescueTime category data via the Edge Function. Show a date range picker defaulting to the current week. Display a donut chart of time split between RescueTime's major categories (Very Productive, Productive, Neutral, Distracting, Very Distracting). Below the chart show a detailed table with category name, hours spent, and color-coded productivity level. Add a week-over-week comparison showing the change in productive hours versus last week. Include a text summary at the top like 'You spent X hours in deep work this week, up Y% from last week.'

Copy this prompt to try it in Lovable

Productivity trend tracker with daily goals

Build a goal-setting and tracking interface where users set a daily productive hours target stored in Supabase, then automatically compare actual RescueTime data against that goal each day. Display a calendar view showing which days hit the goal (green), missed it (red), or came close (yellow), creating a visual habit streak tracker driven entirely by automatic RescueTime data.

Lovable Prompt

Create a Productivity Goals page. Add a 'Daily Goal' input where I can set a target number of productive hours (saved to Supabase). Fetch the past 30 days of RescueTime daily summary data via the Edge Function. Display a calendar grid for the current month where each day shows the actual productive hours and is colored green if the goal was met, yellow if within 30 minutes of the goal, and red if missed. Below the calendar show the current streak of consecutive days meeting the goal and the all-time best streak. Show the goal completion percentage for the current month.

Copy this prompt to try it in Lovable

Troubleshooting

Edge Function returns 'Error 400: Bad Request' from the RescueTime API

Cause: The request parameters are malformed. Common causes include missing required parameters (key, format), invalid date formats (RescueTime requires YYYY-MM-DD), or an unsupported combination of perspective and restrict_kind parameters.

Solution: Verify that date parameters are formatted as YYYY-MM-DD strings with no time component. Check that perspective is set to either 'interval' or 'rank' — these are the only two supported values. If using restrict_kind, confirm the value is one of: 'activity', 'category', 'productivity', 'document', 'efficiency'. Review the full URL being constructed in the Edge Function by logging it temporarily.

typescript
1const date = new Date(inputDate).toISOString().split('T')[0]; // Ensures YYYY-MM-DD format

API returns 'premium required' error for category or application data

Cause: Your RescueTime account is on the free plan. The Analytic Data API's restrict_kind=category and restrict_kind=activity endpoints require a RescueTime Premium subscription. Free accounts can only access the basic daily summary data.

Solution: Upgrade to RescueTime Premium to access full API capabilities, or limit your integration to the basic daily summary endpoint (get_daily_summary and get_date_range_summary) which work on free accounts. You can build a useful productivity trend dashboard using only the daily summary data even on the free tier.

Dashboard shows no data for today even though RescueTime is actively running

Cause: RescueTime processes and syncs activity data with a delay. Data for the current day may not be fully available until a sync occurs, which typically happens every few hours but can be delayed. Additionally, the API uses your account's timezone, which may differ from the UTC dates your Edge Function is generating.

Solution: Add a manual 'Sync' button in your app that triggers a RescueTime manual sync via the API endpoint GET /anapi/start_focustime (premium). For the timezone issue, ensure you are generating date strings in the user's local timezone rather than UTC. You can pass the date as a parameter from the frontend where the browser knows the local date.

typescript
1const localDate = new Date().toLocaleDateString('en-CA'); // Returns YYYY-MM-DD in local timezone

The productivity data rows array is empty even with correct dates

Cause: RescueTime only returns data for days where the client was active and logged activity. If the RescueTime desktop or mobile app was not running on a particular day, no data exists for that date and the API returns an empty rows array rather than an error.

Solution: Add null-checking and empty-state handling in your frontend for every data fetch. When rows is empty, display a message like 'No data recorded for this period — make sure RescueTime is running on your device.' Also verify that the RescueTime client is installed and enabled on the device generating the data you expect to see.

Best practices

  • Always store your RescueTime API key in Cloud → Secrets, never in source code or Lovable's chat prompt — the key grants full read access to all your tracked activity data.
  • Cache RescueTime data in your Supabase database nightly using a scheduled Edge Function or pg_cron, since historical data does not change and caching eliminates repeated API calls for trend charts.
  • Handle the RescueTime API's rows/columns response format by building a reusable parser that maps row arrays to named objects before passing data to React components.
  • Show an informative empty state when no data is available for a date range — RescueTime only has data for days when the client was actively running on a device.
  • Display the Productivity Pulse score with contextual benchmarks (e.g., 'Your average is 68, above the 60 typical for knowledge workers') to make the score meaningful to users who are new to the concept.
  • Respect that RescueTime data is personal and often sensitive — if building a shared team dashboard, clearly communicate what data is being displayed and ensure each user only sees their own data using Supabase RLS policies.
  • Use date range queries rather than single-day queries whenever possible to minimize API calls — fetching 30 days in one request is more efficient than 30 individual daily requests.

Alternatives

Frequently asked questions

Does RescueTime integration require premium?

The basic daily summary and productivity pulse data are available on the free RescueTime plan via the API. However, detailed category breakdowns, application-level data, and the restrict_kind=activity endpoint require RescueTime Premium. If you are on the free plan, you can still build a useful trend dashboard using daily totals and productivity scores.

Can I track multiple users' RescueTime data in a shared team dashboard?

RescueTime's Analytic Data API is personal — each API key only accesses the data for the account that generated it. For a team dashboard, each team member would need to provide their own API key, which you would store as separate secrets. RescueTime does not offer a multi-user API for aggregating team data unless you are using their enterprise plan with admin API access.

How current is the data returned by the RescueTime API?

RescueTime syncs activity data from the desktop client periodically — typically every few hours, but the frequency depends on your plan and settings. Data for today may be incomplete until the next sync. Historical data from previous days is fully synced and accurate. There is no real-time streaming API, so RescueTime integration is best suited for daily summary views rather than minute-by-minute activity feeds.

Is it possible to write data back to RescueTime from Lovable?

The RescueTime Analytic Data API is primarily read-only for time tracking data. You can use the API to start and stop FocusTime sessions (premium feature) which blocks distracting sites. Manual time entries via the API are not supported — RescueTime is designed around automatic passive tracking. If you need writeable time tracking, consider Toggl Track or Clockify which both support creating time entries via their APIs.

Can I combine RescueTime data with other metrics in my Lovable app?

Yes, this is one of the most powerful reasons to build a custom dashboard. You can fetch RescueTime data via the Edge Function, store it in a Supabase table, and join it with other metrics like GitHub commits, calendar events, or manual mood entries to build a holistic personal performance dashboard. For complex multi-source integrations, RapidDev's team can help design the data aggregation architecture.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.