Loudaily_lineup_scheduler.tsx24 matches
22}
2324export interface YahooAPIConfig {
25access_token: string;
26refresh_token: string;
99}
100101// Initialize Yahoo Fantasy API client
102const yahooAPI = new YahooFantasyAPIClient(tokenData, this.tokenStorage, userId);
103104// Get user's leagues
105const leagues = await yahooAPI.getUserLeagues(userId);
106console.log(`🏟️ Found ${leagues.length} leagues for user ${userId}`);
107111112// Get user's team in this league
113const teamKey = await yahooAPI.getTeamKey(userId, league.league_id);
114if (!teamKey) {
115throw new Error(`Could not find team key for league ${league.league_id}`);
117118// Schedule pitchers for today
119const scheduleResult = await this.schedulePitchersForTeam(yahooAPI, teamKey, date);
120121results.leagues_processed.push({
139}
140141private async schedulePitchersForTeam(yahooAPI: YahooFantasyAPIClient, teamKey: string, date: Date) {
142// Get today's probable pitchers from MLB API
143const probablePitchers = await this.getTodaysProbablePitchers(date);
144console.log(`🎯 Found ${probablePitchers.length} probable pitchers for ${date.toDateString()}`);
145146// Get current team roster
147const roster = await yahooAPI.getTeamRoster(teamKey);
148console.log(`👥 Team roster has ${roster.length} players`);
149166for (const change of optimization.changes) {
167try {
168await yahooAPI.setPlayerPosition(teamKey, change.playerId, change.newPosition);
169results.pitchers_scheduled.push(change.playerId);
170results.changes_made.push(change);
186): Promise<Array<{ name: string; team: string; game_time?: string }>> {
187try {
188// Call MLB Stats API for probable pitchers
189const dateStr = date.toISOString().split("T")[0];
190const response = await fetch(
191`https://statsapi.mlb.com/api/v1/schedule?sportId=1&date=${dateStr}&hydrate=probablePitcher`,
192);
193194if (!response.ok) {
195throw new Error(`MLB API error: ${response.status}`);
196}
197440}
441442// Simplified Yahoo Fantasy API client for Val.town
443class YahooFantasyAPIClient {
444private config: YahooAPIConfig;
445private baseUrl = "https://fantasysports.yahooapis.com/fantasy/v2";
446private tokenStorage: LouTokenStorage;
447private userId: string;
448449constructor(config: YahooAPIConfig, tokenStorage: LouTokenStorage, userId: string) {
450this.config = config;
451this.tokenStorage = tokenStorage;
465private async refreshAccessToken(): Promise<void> {
466try {
467const response = await fetch("https://api.login.yahoo.com/oauth2/get_token", {
468method: "POST",
469headers: {
551552if (!retryResponse.ok) {
553throw new Error(`Yahoo API error after refresh: ${retryResponse.status} ${retryResponse.statusText}`);
554}
555558559if (!response.ok) {
560throw new Error(`Yahoo API error: ${response.status} ${response.statusText}`);
561}
562744await this.ensureValidToken();
745746// Yahoo Fantasy API requires XML for roster changes
747const dateStr = new Date().toISOString().split("T")[0];
748776if (!response.ok) {
777const responseText = await response.text();
778console.error(`❌ Yahoo API error response: ${responseText}`);
779throw new Error(`Failed to set player position: ${response.status} ${response.statusText}`);
780}
796797// Store results in Val.town's blob storage for history
798await fetch("https://api.val.town/v1/blob/scheduler_results", {
799method: "POST",
800headers: {
NewPerspctovologyAppmain.tsx2 matches
1// val.js
23const OPENAI_API_KEY = process.env.OPENAI_API_KEY; // set this later
45export default async (req, res) => {
13}
1415// 🧠 Optional: Call your GPT API here (if you want real answers)
16// Example:
17// const response = await fetch("https://YOUR-GPT-ENDPOINT", ...)
9/* 1 ▸ fetch 10 freshest business headlines that mention our coins */
10const q = encodeURIComponent(COINS.slice(0, 3).join(" OR "));
11const url = `https://newsdata.io/api/1/latest?apikey=${KEY}`
12+ `&q=${q}&language=en&size=10&category=business`;
13
untitled-6658HTTP.tsx2 matches
10/>
11<link
12href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap"
13rel="stylesheet"
14/>
64class="rounded-md w-[120px] h-[180px] object-cover flex-shrink-0"
65height="180"
66src="https://storage.googleapis.com/a1aa/image/da09cbc2-570f-460a-05bb-9836a9055c79.jpg"
67width="120"
68/>
invest-trackermacro_news_daily.tsx3 matches
1import { blob } from "https://esm.town/v/std/blob";
2const KEY = Deno.env.get("NEWSAPI");
34export default async function run() {
5const query = `https://newsapi.org/v2/everything?`
6+ `q=(${
7encodeURIComponent(`
9AND (United States OR Australia OR Europe OR China)
10`)
11})&language=en&sortBy=publishedAt&pageSize=10&apiKey=${KEY}`;
1213const arts = (await fetch(query).then(r => r.json())).articles ?? [];
beeminder-apicall_beeminder_api.sh0 matches
1#!/bin/sh
2# Write JSON payload to file
3# cat <<EOF > datapoint.json
4# {"value": 2.5, "comment": "Test from file", "goal": "walk"}
5# EOF
beeminder-apimain.tsx6 matches
1// Beeminder API Handler for Val Town
2// Requires environment variables: BEEMINDER_TOKEN
3// Goal slug can be provided via environment variable BEEMINDER_GOAL_SLUG or JSON request parameter
52const authToken = token || Deno.env.get('BEEMINDER_TOKEN');
53const goalSlug = datapoint.goal || defaultGoalSlug || Deno.env.get('BEEMINDER_GOAL_SLUG');
54const baseUrl = 'https://www.beeminder.com/api/v1';
5556if (!authToken) {
100): Promise<any> {
101const authToken = token || Deno.env.get('BEEMINDER_TOKEN');
102const baseUrl = 'https://www.beeminder.com/api/v1';
103104if (!authToken) {
176}
177
178const baseUrl = 'https://www.beeminder.com/api/v1';
179
180try {
181// Handle different API endpoints
182switch (path) {
183case '/':
184return new Response(JSON.stringify({
185message: 'Beeminder API Handler',
186endpoints: {
187'GET /goal': 'Get goal information (requires goal parameter in JSON body or BEEMINDER_GOAL_SLUG env var)',
gissue-rolodexApp.tsx1 match
2122try {
23const response = await fetch("/api/config", {
24method: "POST",
25headers: {
mcp-starterREADME.md1 match
30## What is the adapter for?
3132The MCP TypeScript SDK uses Node-specific APIs that don't play nicely with Deno
33or edge functions:
34
gissue-rolodexindex.ts3 matches
17});
1819// API endpoint to handle refresh frequency configuration
20app.post("/api/config", async c => {
21try {
22const body = await c.req.json();
4344// Health check endpoint
45app.get("/api/health", c => {
46return c.json({ status: "ok", timestamp: new Date().toISOString() });
47});