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=130&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 14267 results for "api"(1159ms)

FloodAppREADME.md11 matches

@excel•Updated 6 days ago
5## Structure
6
7- `index.ts` - Main entry point for the HTTP API
8- `cron.ts` - Scheduled job to check for floods and send alerts
9- `database/` - Database schema and queries
10- `routes/` - API route handlers
11- `services/` - Business logic services
12
13## API Endpoints
14
15### Authentication
16
17- `POST /api/auth/signup` - Create a new user account
18- `POST /api/auth/login` - Log in to an existing account
19- `GET /api/auth/me` - Get current user information
20
21### Locations
22
23- `GET /api/locations` - Get all locations for the current user
24- `POST /api/locations` - Add a new location
25- `GET /api/locations/:id` - Get a specific location
26- `DELETE /api/locations/:id` - Delete a location
27
28### Flood Checking
29
30- `POST /api/check-floods` - Check for potential floods for a user's locations
31
32## Cron Job

FloodAppindex.js9 matches

@excel•Updated 6 days ago
11};
12
13// API base URL
14const API_BASE_URL = '';
15
16// DOM Elements
150
151 try {
152 const response = await fetch(`${API_BASE_URL}/api/auth/login`, {
153 method: 'POST',
154 headers: {
191
192 try {
193 const response = await fetch(`${API_BASE_URL}/api/auth/signup`, {
194 method: 'POST',
195 headers: {
247async function loadLocations() {
248 try {
249 const response = await fetch(`${API_BASE_URL}/api/locations`, {
250 headers: {
251 'Authorization': `Bearer ${state.token}`
304
305 try {
306 const response = await fetch(`${API_BASE_URL}/api/locations/${locationId}`, {
307 method: 'DELETE',
308 headers: {
326// Load alerts
327async function loadAlerts() {
328 // This would be an API call to get alerts
329 // For now, we'll just use a placeholder
330 state.alerts = [];
455
456 try {
457 const response = await fetch(`${API_BASE_URL}/api/locations`, {
458 method: 'POST',
459 headers: {
500 elements.checkFloodsBtn.innerHTML = '<i class="fas fa-spinner fa-spin mr-2"></i> Checking...';
501
502 const response = await fetch(`${API_BASE_URL}/api/check-floods`, {
503 method: 'POST',
504 headers: {

FloodAppindex.ts4 matches

@excel•Updated 6 days ago
29});
30
31// API routes
32app.route("/api/auth", auth);
33app.route("/api/locations", locations);
34
35// Check for floods for a specific user
36app.post("/api/check-floods", async (c) => {
37 try {
38 const { userId } = await c.req.json();

FloodAppfloodPredictor.ts4 matches

@excel•Updated 6 days ago
5const RAINFALL_THRESHOLD = 50; // Adjust based on local conditions
6
7// Open-Meteo API for weather forecasts
8const WEATHER_API_URL = "https://api.open-meteo.com/v1/forecast";
9
10interface WeatherForecast {
17// Get weather forecast for a location
18async function getWeatherForecast(latitude: number, longitude: number): Promise<WeatherForecast> {
19 const url = new URL(WEATHER_API_URL);
20 url.searchParams.append("latitude", latitude.toString());
21 url.searchParams.append("longitude", longitude.toString());
27
28 if (!response.ok) {
29 throw new Error(`Weather API error: ${response.statusText}`);
30 }
31

FloodAppREADME.md2 matches

@excel•Updated 6 days ago
12## Project Structure
13
14- `/backend` - Server-side code and API endpoints
15- `/frontend` - User interface and client-side code
16- `/shared` - Shared types and utilities
21- Database: SQLite
22- Frontend: HTML, JavaScript, Tailwind CSS
23- Weather Data: Open-Meteo API
24- Notifications: Email
25

JobAppindex.ts5 matches

@excel•Updated 6 days ago
56setupDatabase().catch(console.error);
57
58// API Routes
59
60// Get all job postings
61app.get("/api/jobs", async (c) => {
62 const jobs = await sqlite.execute(`SELECT * FROM ${JOBS_TABLE} ORDER BY created_at DESC`);
63 return c.json(jobs);
65
66// Create a new job posting
67app.post("/api/jobs", async (c) => {
68 const body = await c.req.json();
69 const { title, description, company, location, salary, contact } = body;
85
86// Get chat messages
87app.get("/api/chat", async (c) => {
88 const messages = await sqlite.execute(
89 `SELECT * FROM ${CHAT_TABLE} ORDER BY created_at DESC LIMIT 100`
93
94// Post a chat message
95app.post("/api/chat", async (c) => {
96 const body = await c.req.json();
97 const { username, message } = body;

GodinoMawabankAuthContext.tsx11 matches

@Godino•Updated 6 days ago
2import React, { createContext, useContext, useState, useEffect } from "https://esm.sh/react@18.2.0";
3import { useNavigate } from "https://esm.sh/react-router-dom@6.16.0?deps=react@18.2.0";
4import { User, AuthResponse, ApiResponse } from "../../../shared/types";
5
6interface AuthContextType {
8 isAuthenticated: boolean;
9 isLoading: boolean;
10 login: (email: string, password: string) => Promise<ApiResponse<AuthResponse>>;
11 register: (formData: any) => Promise<ApiResponse<AuthResponse>>;
12 logout: () => void;
13 checkAuth: () => Promise<boolean>;
42
43 try {
44 const response = await fetch("/api/auth/me", {
45 headers: {
46 Authorization: `Bearer ${token}`
52 }
53
54 const data: ApiResponse<User> = await response.json();
55
56 if (data.success && data.data) {
70 };
71
72 const login = async (email: string, password: string): Promise<ApiResponse<AuthResponse>> => {
73 try {
74 const response = await fetch("/api/auth/login", {
75 method: "POST",
76 headers: {
80 });
81
82 const data: ApiResponse<AuthResponse> = await response.json();
83
84 if (data.success && data.data) {
98 };
99
100 const register = async (formData: any): Promise<ApiResponse<AuthResponse>> => {
101 try {
102 const response = await fetch("/api/auth/register", {
103 method: "POST",
104 headers: {
108 });
109
110 const data: ApiResponse<AuthResponse> = await response.json();
111
112 if (data.success && data.data) {

GodinoMawabankindex.ts4 matches

@Godino•Updated 6 days ago
21app.use("*", cors());
22
23// Mount API routes
24app.route("/api/auth", authRoutes);
25app.route("/api/kyc", kycRoutes);
26app.route("/api/accounts", accountRoutes);
27
28// Mount static routes (should be last)

GodinoMawabankstatic.ts1 match

@Godino•Updated 6 days ago
37
38// Serve KYC document images
39staticRoutes.get("/api/images/:key", async (c) => {
40 try {
41 const key = c.req.param("key");

GodinoMawabankaccounts.ts13 matches

@Godino•Updated 6 days ago
7 getUserById
8} from "../database/queries";
9import { createApiResponse, generateAccountNumber } from "../../shared/utils";
10import {
11 Account,
34 const user = await getUserById(userId);
35 if (!user) {
36 return c.json(createApiResponse(false, undefined, "User not found"), 404);
37 }
38
39 if (user.kycStatus !== KYCStatus.APPROVED) {
40 return c.json(
41 createApiResponse(
42 false,
43 undefined,
52 if (existingAccounts.length > 0) {
53 return c.json(
54 createApiResponse<AccountGenerationResponse>(
55 true,
56 { accounts: existingAccounts },
114 // Return the generated accounts
115 return c.json(
116 createApiResponse<AccountGenerationResponse>(
117 true,
118 { accounts: generatedAccounts }
122 } catch (error) {
123 console.error("Account generation error:", error);
124 return c.json(createApiResponse(false, undefined, "Account generation failed"), 500);
125 }
126});
135 const accounts = await getAccountsByUserId(userId);
136
137 return c.json(createApiResponse(true, { accounts }));
138 } catch (error) {
139 console.error("Get accounts error:", error);
140 return c.json(createApiResponse(false, undefined, "Failed to get accounts"), 500);
141 }
142});
150
151 if (isNaN(accountId)) {
152 return c.json(createApiResponse(false, undefined, "Invalid account ID"), 400);
153 }
154
157
158 if (!account) {
159 return c.json(createApiResponse(false, undefined, "Account not found"), 404);
160 }
161
162 // Check if account belongs to user
163 if (account.userId !== userId) {
164 return c.json(createApiResponse(false, undefined, "Unauthorized"), 403);
165 }
166
167 return c.json(createApiResponse(true, { account }));
168 } catch (error) {
169 console.error("Get account error:", error);
170 return c.json(createApiResponse(false, undefined, "Failed to get account"), 500);
171 }
172});

waec_api6 file matches

@seyistry•Updated 3 hours ago

book-lookup5 file matches

@nucky•Updated 2 days ago
use google book api to look up bibliographic metadata elements
snartapi
mux
Your friendly, neighborhood video API.