Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/?q=api&page=3&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=api

Returns an array of strings in format "username" or "username/projectName"

Found 18780 results for "api"(1934ms)

Snotel-AnalyzerREADME.md6 matches

@bjtitusUpdated 12 hours ago
1# SNOTEL Data Viewer
2
3A web application that displays the latest SNOTEL (Snow Telemetry) data from USDA's AWDB REST API.
4
5## Features
7- Displays latest snow and weather data from SNOTEL sites
8- Interactive table with site information
9- Real-time data fetching from USDA AWDB API
10
11## Project Structure
12
13- `backend/index.ts` - Main Hono server with API endpoints
14- `frontend/index.html` - Main HTML template
15- `frontend/index.tsx` - React frontend application
16- `shared/types.ts` - Shared TypeScript types
17
18## API Endpoints
19
20- `GET /` - Serves the main application
21- `GET /api/sites` - Fetches SNOTEL site data
22- `GET /api/data/:stationId` - Fetches latest data for a specific station
23
24## Usage

Glancerapi.ts0 matches

@lightweightUpdated 13 hours ago
1import { Hono } from "npm:hono";
2
3// Import route modules
4import cobrowse from "./getCobrowseStatus.ts";
5import database from "./getDatabase.ts";

osindex.ts14 matches

@dinavinterUpdated 13 hours ago
15});
16
17// Gigya API Configuration
18const GIGYA_DOMAIN = Deno.env.get("GIGYA_DOMAIN") || "accounts.eu1.gigya.com";
19const GIGYA_API_KEY = Deno.env.get("GIGYA_API_KEY") || "";
20const GIGYA_APP_KEY = Deno.env.get("GIGYA_APP_KEY") || "";
21const GIGYA_APP_SECRET = Deno.env.get("GIGYA_APP_SECRET") || "";
22
23if (!GIGYA_API_KEY || !GIGYA_APP_KEY || !GIGYA_APP_SECRET) {
24 console.warn("Missing Gigya environment variables. Some features may not work.");
25}
26
27// Direct Gigya API functions
28async function makeGigyaRequest(endpoint: string, params: Record<string, any>): Promise<any> {
29 const url = `https://${GIGYA_DOMAIN}/${endpoint}?httpStatusCodes=true`;
30
31 const body = new URLSearchParams({
32 apiKey: GIGYA_API_KEY,
33 userKey: GIGYA_APP_KEY,
34 secret: GIGYA_APP_SECRET,
50
51 if (result.errorCode !== 0) {
52 throw new Error(`Gigya API Error ${result.errorCode}: ${result.errorMessage || "Unknown error"}`);
53 }
54
394});
395
396// API Routes
397
398// Get account info
399app.get("/api/account/:uid", async (c) => {
400 try {
401 const uid = c.req.param("uid");
413
414// Search accounts
415app.get("/api/search", async (c) => {
416 try {
417 const query = c.req.query("q") || "";
430
431// Update account
432app.put("/api/account/:uid", async (c) => {
433 try {
434 const uid = c.req.param("uid");
443
444// Import account
445app.post("/api/account/import", async (c) => {
446 try {
447 const body = await c.req.json();
454
455// Get schema
456app.get("/api/schema", async (c) => {
457 try {
458 const schema = await getSchema();
464
465// Update schema
466app.put("/api/schema", async (c) => {
467 try {
468 const body = await c.req.json();
475
476// Health check
477app.get("/api/health", (c) => {
478 return c.json({
479 success: true,

Loudaily_lineup_scheduler.tsx23 matches

@jeffvincentUpdated 13 hours ago
22}
23
24export interface YahooAPIConfig {
25 access_token: string;
26 refresh_token: string;
94 }
95
96 // Initialize Yahoo Fantasy API client
97 const yahooAPI = new YahooFantasyAPIClient(tokenData, this.tokenStorage, userId);
98
99 // Get user's leagues
100 const leagues = await yahooAPI.getUserLeagues(userId);
101 console.log(`🏟️ Found ${leagues.length} leagues for user ${userId}`);
102
106
107 // Get user's team in this league
108 const teamKey = await yahooAPI.getTeamKey(userId, league.league_id);
109 if (!teamKey) {
110 throw new Error(`Could not find team key for league ${league.league_id}`);
112
113 // Schedule pitchers for today
114 const scheduleResult = await this.schedulePitchersForTeam(yahooAPI, teamKey, date);
115
116 results.leagues_processed.push({
134 }
135
136 private async schedulePitchersForTeam(yahooAPI: YahooFantasyAPIClient, teamKey: string, date: Date) {
137 // Get today's probable pitchers from MLB API
138 const probablePitchers = await this.getTodaysProbablePitchers(date);
139 console.log(`🎯 Found ${probablePitchers.length} probable pitchers for ${date.toDateString()}`);
140
141 // Get current team roster
142 const roster = await yahooAPI.getTeamRoster(teamKey);
143 console.log(`👥 Team roster has ${roster.length} players`);
144
161 for (const change of optimization.changes) {
162 try {
163 await yahooAPI.setPlayerPosition(teamKey, change.playerId, change.newPosition);
164 results.pitchers_scheduled.push(change.playerId);
165 results.changes_made.push(change);
181 ): Promise<Array<{ name: string; team: string; game_time?: string }>> {
182 try {
183 // Call MLB Stats API for probable pitchers
184 const dateStr = date.toISOString().split("T")[0];
185 const response = await fetch(
186 `https://statsapi.mlb.com/api/v1/schedule?sportId=1&date=${dateStr}&hydrate=probablePitcher`,
187 );
188
189 if (!response.ok) {
190 throw new Error(`MLB API error: ${response.status}`);
191 }
192
326}
327
328// Simplified Yahoo Fantasy API client for Val.town
329class YahooFantasyAPIClient {
330 private config: YahooAPIConfig;
331 private baseUrl = "https://fantasysports.yahooapis.com/fantasy/v2";
332 private tokenStorage: LouTokenStorage;
333 private userId: string;
334
335 constructor(config: YahooAPIConfig, tokenStorage: LouTokenStorage, userId: string) {
336 this.config = config;
337 this.tokenStorage = tokenStorage;
351 private async refreshAccessToken(): Promise<void> {
352 try {
353 const response = await fetch("https://api.login.yahoo.com/oauth2/get_token", {
354 method: "POST",
355 headers: {
419
420 if (!retryResponse.ok) {
421 throw new Error(`Yahoo API error after refresh: ${retryResponse.status} ${retryResponse.statusText}`);
422 }
423
426
427 if (!response.ok) {
428 throw new Error(`Yahoo API error: ${response.status} ${response.statusText}`);
429 }
430
513
514 async setPlayerPosition(teamKey: string, playerId: string, position: string): Promise<void> {
515 // Yahoo Fantasy API requires PUT/POST for roster changes
516 const response = await fetch(`${this.baseUrl}/teams;team_keys=${teamKey}/roster/players;player_keys=${playerId}`, {
517 method: "PUT",
558
559 // Store results in Val.town's blob storage for history
560 await fetch("https://api.val.town/v1/blob/scheduler_results", {
561 method: "POST",
562 headers: {

osAccountViewer.tsx1 match

@dinavinterUpdated 14 hours ago
169 {Object.entries(account.profile).map(([key, value]) => (
170 <div key={key}>
171 <dt class="text-sm font-medium text-gray-500 capitalize">
172 {key.replace(/([A-Z])/g, ' $1').trim()}
173 </dt>

osAccountForm.tsx1 match

@dinavinterUpdated 14 hours ago
51export function AccountForm({ schema, account, isImport = false }: AccountFormProps) {
52 const formId = isImport ? "import-form" : "edit-form";
53 const submitUrl = isImport ? "/api/account/import" : `/api/account/${account?.UID}`;
54 const method = isImport ? "POST" : "PUT";
55

townie-126val-summary.ts3 matches

@dinavinterUpdated 14 hours ago
18 SUM(num_images) as total_images
19 FROM ${USAGE_TABLE}
20 WHERE val_id = ? AND our_api_token = 1
21 GROUP BY val_id
22 `, [valId]);
34 FROM ${INFERENCE_CALLS_TABLE} i
35 JOIN ${USAGE_TABLE} u ON i.usage_id = u.id
36 WHERE u.val_id = ? AND u.our_api_token = 1
37 GROUP BY u.val_id
38 `, [valId]);
41 const requestsResult = await sqlite.execute(`
42 SELECT * FROM ${USAGE_TABLE}
43 WHERE val_id = ? AND our_api_token = 1
44 ORDER BY timestamp DESC
45 `, [valId]);

townie-126val-detail.ts1 match

@dinavinterUpdated 14 hours ago
18 finish_reason?: string;
19 num_images?: number;
20 our_api_token: boolean;
21}
22

townie-126useUser.tsx1 match

@dinavinterUpdated 14 hours ago
1import { useState, useEffect } from "react";
2
3const USER_ENDPOINT = "/api/user";
4
5export function useUser() {

townie-126user-summary.ts2 matches

@dinavinterUpdated 14 hours ago
20 SUM(num_images) as total_images
21 FROM ${USAGE_TABLE}
22 WHERE our_api_token = 1
23 `;
24
41 FROM ${INFERENCE_CALLS_TABLE} i
42 JOIN ${USAGE_TABLE} u ON i.usage_id = u.id
43 WHERE u.our_api_token = 1
44 `;
45

helloEffectHttpApi1 file match

@mattrossmanUpdated 8 hours ago

html-to-pdf-api2 file matches

@prashamtrivediUpdated 20 hours ago
HTML to PDF converter API with blob storage
apiry
snartapi