• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
dcm31

dcm31

expected-work

Work hours probability calculator
Public
Like
1
expected-work
Home
Code
11
components
5
utils
4
API_README.md
COMPLETE_PACKAGE_SUMMARY.md
CUSTOM_GPT_INSTRUCTIONS.md
CUSTOM_GPT_SETUP_GUIDE.md
images.md
H
index.ts
moi.md
openapi-custom-gpt.yaml
openapi.yaml
Branches
3
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
API_README.md
Code
/
API_README.md
Search
8/11/2025
API_README.md

Expected Value Goal Setting (EVGS) API

An API for optimizing work goals using expected value theory and integrating with Fatebook for prediction tracking.

🚀 Quick Start

The API is now live at: https://dcm31--019899c30691716293d39932f5c6be80.web.val.run/api/

API Documentation

  • Interactive API Docs: /api/docs
  • OpenAPI Spec: /api/openapi.yaml

Authentication

Most endpoints require your Fatebook API key. Get yours at: https://fatebook.io/api-setup

📋 Available Endpoints

Core Functionality

1. Calculate Optimal Goal

POST /api/calculate-optimal-goal

Calculate the optimal work goal based on probability assessments.

Example Request:

{ "settings": { "minValue": 1, "maxValue": 6, "increment": 0.5, "usePomodoros": false }, "probabilities": { "2": 0.9, "3": 0.7, "4": 0.5, "5": 0.3 } }

2. Quick Goal Workflow

POST /api/quick-goal

One-shot endpoint that calculates optimal goal AND creates it in Fatebook.

Example Request:

{ "fatebookApiKey": "your-api-key", "probabilities": { "2": 0.9, "3": 0.7, "4": 0.5 }, "settings": { "usePomodoros": true } }

Fatebook Integration

3. Get Goals

GET /api/fatebook-goals?apiKey=your-key&limit=50&resolved=false

4. Create Goal

POST /api/fatebook-goals
{ "fatebookApiKey": "your-key", "goalValue": 3, "unit": "hours", "confidence": 0.7 }

5. Resolve Goal

POST /api/fatebook-goals/{questionId}/resolve
{ "fatebookApiKey": "your-key", "resolution": "YES" }

6. Update Forecast

POST /api/fatebook-goals/{questionId}/forecast
{ "fatebookApiKey": "your-key", "forecast": 0.8 }

Analytics

7. Performance Analysis

GET /api/analyze-performance?fatebookApiKey=your-key&timeframe=month

Returns calibration metrics, success rates, trends, and recommendations.

🔧 Usage Examples

Using with curl

# Calculate optimal goal curl -X POST https://dcm31--019899c30691716293d39932f5c6be80.web.val.run/api/calculate-optimal-goal \ -H "Content-Type: application/json" \ -d '{ "settings": {"minValue": 1, "maxValue": 4, "increment": 0.5, "usePomodoros": false}, "probabilities": {"1": 0.95, "1.5": 0.8, "2": 0.6, "2.5": 0.4} }' # Quick workflow - calculate and create goal curl -X POST https://dcm31--019899c30691716293d39932f5c6be80.web.val.run/api/quick-goal \ -H "Content-Type: application/json" \ -d '{ "fatebookApiKey": "your-api-key", "probabilities": {"2": 0.8, "3": 0.6, "4": 0.4} }'

Using with JavaScript/fetch

// Calculate optimal goal const response = await fetch('/api/calculate-optimal-goal', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ settings: { minValue: 1, maxValue: 6, increment: 0.5, usePomodoros: false }, probabilities: { "2": 0.9, "3": 0.7, "4": 0.5 } }) }); const result = await response.json(); console.log('Optimal goal:', result.optimalGoal); // Get performance analysis const analysis = await fetch(`/api/analyze-performance?fatebookApiKey=${apiKey}&timeframe=month`); const data = await analysis.json(); console.log('Success rate:', data.successRate + '%');

Using with Python

import requests # Calculate optimal goal response = requests.post( 'https://dcm31--019899c30691716293d39932f5c6be80.web.val.run/api/calculate-optimal-goal', json={ 'settings': {'minValue': 1, 'maxValue': 6, 'increment': 0.5, 'usePomodoros': False}, 'probabilities': {'2': 0.9, '3': 0.7, '4': 0.5} } ) result = response.json() print(f"Optimal goal: {result['optimalGoal']['value']} {result['optimalGoal']['unit']}") # Quick workflow quick_response = requests.post( 'https://dcm31--019899c30691716293d39932f5c6be80.web.val.run/api/quick-goal', json={ 'fatebookApiKey': 'your-api-key', 'probabilities': {'2': 0.8, '3': 0.6, '4': 0.4} } ) print(quick_response.json()['recommendation'])

🎯 Testing the API Right Now

Let's test this API right here! Try the quick goal workflow:

// Test the API with your actual Fatebook key const testQuickGoal = async () => { const response = await fetch('https://dcm31--019899c30691716293d39932f5c6be80.web.val.run/api/quick-goal', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ fatebookApiKey: 'hgyrqtq5ube7daowumtog6', // Your key from the documents probabilities: { "1": 0.95, "2": 0.85, "3": 0.7, "4": 0.5 }, settings: { usePomodoros: false } }) }); const result = await response.json(); console.log('API Test Result:', result); return result; }; // Run the test testQuickGoal();

🏗️ Integration Ideas

Now that you have a full API, you can:

  1. CLI Tool: Create a command-line tool that asks for probabilities and creates goals
  2. Slack Bot: Integrate with Slack for team goal setting
  3. Mobile App: Build a mobile app that uses the API
  4. Browser Extension: Chrome extension for quick goal setting
  5. Automation: Set up cron jobs to analyze performance and send reports
  6. Integration with other tools: Connect with Toggl, RescueTime, etc.

📊 Features

  • ✅ Calculate optimal goals using expected value theory
  • ✅ Full Fatebook integration (create, resolve, update forecasts)
  • ✅ Performance analysis with calibration metrics
  • ✅ RESTful API with comprehensive error handling
  • ✅ OpenAPI specification with interactive docs
  • ✅ Backward compatibility with existing frontend
  • ✅ Rate limiting and input validation
  • ✅ Detailed analytics and recommendations

🔍 Error Handling

All endpoints return consistent error responses:

{ "error": "Human-readable error message", "details": "Technical details for debugging", "code": "ERROR_CODE_FOR_PROGRAMMATIC_HANDLING" }

📈 Next Steps

With this API in place, you can now:

  1. Use the /api/quick-goal endpoint for automated goal setting
  2. Build integrations with other productivity tools
  3. Create automated workflows for goal tracking and analysis
  4. Develop mobile or desktop applications
  5. Set up monitoring and alerting based on performance metrics

The API is fully functional and ready for production use!

FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.