Skip to main content

Get Chart Data

Retrieve data formatted for visualizations, with optional month filtering.
curl http://127.0.0.1:5000/api/insights/charts

Query Parameters

year
integer
Filter by year (e.g., 2024)
month
integer
Filter by month (1-12). Requires year parameter.

Response

{
  "has_data": true,
  "month_name": "March 2024",
  "mood_trend": [
    {"date": "1", "score": 0.45, "has_entry": true},
    {"date": "2", "score": null, "has_entry": false},
    {"date": "3", "score": 0.62, "has_entry": true}
  ],
  "day_distribution": {
    "days": ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
    "counts": [2, 5, 4, 6, 5, 3, 1],
    "avg_moods": [0.15, 0.32, -0.05, 0.48, 0.22, 0.61, -0.12]
  },
  "themes": {
    "labels": ["Work", "Health", "Learning", "Family"],
    "counts": [15, 12, 8, 6]
  },
  "mood_distribution": {
    "very_positive": 5,
    "positive": 12,
    "neutral": 6,
    "negative": 2,
    "very_negative": 0
  },
  "weekly_entries": [
    {"week": "Week 1", "count": 5},
    {"week": "Week 2", "count": 7},
    {"week": "Week 3", "count": 6},
    {"week": "Week 4", "count": 4}
  ],
  "weekly_words": [
    {"week": "Week 1", "avg_words": 245},
    {"week": "Week 2", "avg_words": 312},
    {"week": "Week 3", "avg_words": 267},
    {"week": "Week 4", "avg_words": 289}
  ],
  "total_entries": 22,
  "insights": [
    "Your mood has been improving recently.",
    "You tend to feel best on Wednesdays.",
    "You've been reflecting on: Work, Health, Learning."
  ],
  "best_day": "Wednesday"
}
has_data
boolean
Whether sufficient data exists for insights
month_name
string
Display name (e.g., “March 2024” or “All Time”)
mood_trend
array
Daily mood scores for the period
day_distribution
object
Breakdown by day of week
themes
object
Most common themes
mood_distribution
object
Count of entries by mood category (see Stats API for details)
weekly_entries
array
Entry count by week
weekly_words
array
Average word count by week
insights
array
Human-readable insights generated from the data
best_day
string | null
Day of week with highest average mood

Get Pattern Insights

Analyze activity-mood correlations and thematic patterns.
curl http://127.0.0.1:5000/api/insights
{
  "insights": [
    {
      "type": "activity_correlation",
      "title": "Activity Pattern",
      "description": "You seem most energized on days involving morning walk.",
      "emoji": "🔗",
      "confidence": "high"
    },
    {
      "type": "weekly_pattern",
      "title": "Weekly Rhythm",
      "description": "Wednesdays tend to be your best days, while Mondays are more challenging.",
      "emoji": "📅"
    },
    {
      "type": "mood_trend",
      "title": "Mood Trend",
      "description": "Your overall mood has been improving over the past entries.",
      "emoji": "📈"
    },
    {
      "type": "themes",
      "title": "Common Themes",
      "description": "You write most about: work, health, learning",
      "emoji": "🎯"
    },
    {
      "type": "theme_mood",
      "title": "Positive Triggers",
      "description": "Writing about health and creativity often coincides with better moods.",
      "emoji": "✨"
    }
  ],
  "mood_trend": "improving",
  "average_sentiment": 0.32,
  "top_themes": [
    ["work", 15],
    ["health", 12],
    ["learning", 8]
  ],
  "activity_correlations": [
    {
      "activity": "morning_walk",
      "avg_mood": 0.612,
      "occurrences": 8,
      "positive": true,
      "negative": false
    },
    {
      "activity": "exercise",
      "avg_mood": 0.548,
      "occurrences": 12,
      "positive": true,
      "negative": false
    },
    {
      "activity": "stressed",
      "avg_mood": -0.342,
      "occurrences": 5,
      "positive": false,
      "negative": true
    }
  ],
  "entries_analyzed": 14
}

Minimum Requirements

Requires at least 3 entries to generate insights.

Response Fields

insights
array
List of discovered patterns and insights
mood_trend
string
Overall trend: improving, declining, or stable
average_sentiment
number
Average sentiment score across analyzed entries
activity_correlations
array
Correlations between activities and mood scores

Get Weekly Summary

AI-generated weekly reflection with pattern connections (requires Groq API key).
curl http://127.0.0.1:5000/api/insights/weekly
{
  "summary": "You wrote 5 entries this week with a notably positive tone. Your energy seemed highest on days when you mentioned morning walks or exercise—you brought up feeling refreshed and productive after physical activity. Writing about health and creative projects also coincided with upbeat entries. Consider building on that momentum: those morning routines seem to set a strong foundation for your day.",
  "entries_count": 5,
  "pattern_insights": [
    "You mentioned morning walk 3 times this week, and those entries had notably positive energy.",
    "Writing about health seemed to coincide with better moods."
  ],
  "activity_correlations": [
    {"activity": "morning_walk", "avg_mood": 0.68, "occurrences": 3, "positive": true}
  ],
  "ai_available": true
}

AI vs Non-AI Response

With Groq API key:
  • Personalized narrative summary
  • References specific activities and patterns
  • Actionable suggestions
Without Groq API key:
  • Basic statistics summary
  • Pattern insights (local analysis)
  • No personalized narrative

Get Monthly Summary

AI-generated monthly reflection (last 30 days).
curl http://127.0.0.1:5000/api/insights/monthly
{
  "summary": "You wrote 22 entries this month—impressive consistency! Your mood trajectory has been improving, especially in the second half of the month. A clear pattern emerged: days involving morning walks or exercise correlated with more positive entries...",
  "entries_count": 22,
  "mood_trajectory": "improving",
  "insights": [
    {"type": "activity", "text": "You seem most energized on days involving exercise.", "emoji": "🔗"},
    {"type": "positive_triggers", "text": "Activities that boosted your mood: morning walk, creative work", "emoji": "⚡"}
  ],
  "activity_correlations": [...],
  "ai_available": true
}

Minimum Requirements

Requires at least 5 entries in the last 30 days.

Get Month-Specific Summary

AI summary for a specific calendar month.
curl "http://127.0.0.1:5000/api/insights/summary?year=2024&month=3"

Query Parameters

year
integer
required
Year (e.g., 2024)
month
integer
required
Month (1-12)
{
  "summary": "In March 2024, you wrote 18 journal entries showing strong consistency. Your mood started neutral early in the month but shifted noticeably positive as you wrote more about outdoor activities and creative projects...",
  "month_name": "March 2024",
  "entries_count": 18,
  "mood_trajectory": "improving",
  "avg_mood": 0.28,
  "top_themes": ["work", "health", "learning"],
  "insights": [...],
  "ai_available": true
}

Minimum Requirements

Requires at least 3 entries in the specified month.

Activity Detection

The insights engine detects these activities automatically:
  • morning_walk - morning walk, walked early
  • exercise - gym, workout, ran, yoga
  • meditation - meditate, mindful, breathing
  • good_sleep - slept well, rested, refreshed
  • poor_sleep - couldn’t sleep, tired, exhausted
  • social_time - met friends, hung out, party
  • nature - park, hiking, outdoors, fresh air
  • creative_work - wrote, painted, created
  • reading - read, book, article
  • productive_day - productive, accomplished
  • stressed - stressed, overwhelmed, anxious
  • grateful - grateful, thankful, blessed
And many more. These are correlated with mood scores to find patterns.

Privacy Note

AI summaries (weekly, monthly, month-specific) send entry previews to Groq API if configured. See Groq API Integration for details.
Local-only features (no AI):
  • Chart data generation
  • Pattern insights (activity correlations)
  • Theme detection
  • Day-of-week analysis

Next Steps

Greeting API

Personalized daily greetings

Export/Import

Backup your journal data

Build docs developers (and LLMs) love