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/image-url.jpg%20%22Image%20title%22?q=api&page=5&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 11519 results for "api"(3788ms)

untitled-2604new-file-9513.tsx24 matches

@al0•Updated 19 hours ago
1// Creado por Alfonso Boldo
2// Sistema Completo de Prueba de APIs de LLMs para ValTown
3// Fecha: 05 de mayo de 2025
4
26 }
27
28 // Para solicitudes POST, procesar la llamada a la API
29 if (req.method === 'POST') {
30 try {
57
58 // Extraer parámetros
59 const { provider, apiKey, prompt, model, temperature, maxTokens } = body || {};
60
61 // Validar parámetros requeridos
62 if (!provider || !apiKey || !prompt) {
63 return new Response(
64 JSON.stringify({
65 error: 'Se requieren los parámetros: provider, apiKey y prompt'
66 }),
67 { status: 400, headers }
74 switch (provider.toLowerCase()) {
75 case 'openai':
76 result = await callOpenAI(apiKey, prompt, model || 'gpt-4o', temperature || 0.7, maxTokens || 1000);
77 break;
78 case 'anthropic':
79 result = await callClaude(apiKey, prompt, model || 'claude-3-5-sonnet-20240521', temperature || 0.7, maxTokens || 1000);
80 break;
81 default:
111}
112
113// Función para llamar a la API de OpenAI
114async function callOpenAI(apiKey, prompt, model, temperature, maxTokens) {
115 const url = 'https://api.openai.com/v1/chat/completions';
116
117 console.log(`Llamando a OpenAI con modelo: ${model}`);
122 headers: {
123 'Content-Type': 'application/json',
124 'Authorization': `Bearer ${apiKey}`
125 },
126 body: JSON.stringify({
170}
171
172// Función para llamar a la API de Claude (Anthropic)
173async function callClaude(apiKey, prompt, model, temperature, maxTokens) {
174 const url = 'https://api.anthropic.com/v1/messages';
175
176 console.log(`Llamando a Claude con modelo: ${model}`);
181 headers: {
182 'Content-Type': 'application/json',
183 'x-api-key': apiKey,
184 'anthropic-version': '2023-06-01'
185 },
244 <meta charset="UTF-8">
245 <meta name="viewport" content="width=device-width, initial-scale=1.0">
246 <title>Probador de APIs de LLMs</title>
247 <style>
248 body {
329 </head>
330 <body>
331 <h1>Probador de APIs de LLMs</h1>
332 <p>Esta herramienta te permite probar diferentes APIs de modelos de lenguaje como OpenAI (ChatGPT) y Claude (Anthropic).</p>
333
334 <div class="container">
342
343 <div class="form-group">
344 <label for="apiKey">API Key:</label>
345 <input type="password" id="apiKey" placeholder="Ingresa tu API key aquí">
346 </div>
347
465 submitBtn.addEventListener('click', async function() {
466 const provider = document.getElementById('provider').value;
467 const apiKey = document.getElementById('apiKey').value;
468 const model = document.getElementById('model').value;
469 const temperature = parseFloat(document.getElementById('temperature').value);
472
473 // Validar campos
474 if (!apiKey || !prompt) {
475 alert('Por favor completa todos los campos requeridos.');
476 return;
482 rawResult.textContent = 'Cargando...';
483
484 // Obtener la URL actual para la API
485 // Como ahora todo está en un solo endpoint, simplemente usamos la misma URL
486 const endpointUrl = window.location.href;
492 const requestBody = {
493 provider,
494 apiKey,
495 prompt,
496 model,

morningmailmain.tsx1 match

@flymaster•Updated 19 hours ago
19async function wikitext(): string {
20 const randomArticle = await fetch(
21 "https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&exintro&explaintext&redirects=1&generator=random&formatversion=2&grnnamespace=0&grnlimit=3",
22 );
23 const articleJson = await randomArticle.json();

LEDStrain-Discussion-To-PlainTextapp.tsx2 matches

@tyler71•Updated 20 hours ago
81async function getDiscussionPosts(discussionId: string): Promise<PostT[]> {
82 // Used to get the list of post id's for the discussion.
83 const discussionRes = await fetch(`${server}/api/discussions/${discussionId}`);
84 const discussionResJson = await discussionRes.json();
85
93
94 await Promise.all(chunks.map(async (c: string[]) => {
95 const postRes = await fetch(`${server}/api/posts?filter[id]=${c.join(",")}`);
96 const postJson = await postRes.json();
97

TownieuseAuth.tsx11 matches

@valdottown•Updated 21 hours ago
3
4const TOKEN_KEY = "bearer";
5const ANTHROPIC_KEY = "anthropic_api_key";
6
7export function useAuth() {
8 const [token, setToken, removeToken] = useLocalStorage(TOKEN_KEY, "");
9 const [anthropicApiKey, setAnthropicApiKey, removeAnthropicApiKey] = useLocalStorage(ANTHROPIC_KEY, "");
10 const [error, setError] = useState(null);
11
12 const isAuthenticated = !!token;
13
14 const authenticate = async (valTownAPIKey: string, anthropicKey: string) => {
15 // replace all this with oauth when it's ready
16 try {
17 const res = await fetch("/api/user", {
18 headers: {
19 "Authorization": "Bearer " + valTownAPIKey,
20 },
21 });
25 setError(data.error);
26 removeToken();
27 removeAnthropicApiKey();
28 return;
29 }
30 setError(null);
31 setToken(valTownAPIKey);
32 setAnthropicApiKey(anthropicKey);
33 } catch (e) {
34 console.error(e);
35 setError(e.error);
36 removeToken();
37 removeAnthropicApiKey();
38 }
39 };
41 const logOut = () => {
42 removeToken();
43 removeAnthropicApiKey();
44 };
45
50 logOut,
51 token,
52 anthropicApiKey,
53 };
54}

helloooooooindex.ts4 matches

@charmaine•Updated 1 day ago
87});
88
89// API endpoint to get all posts
90app.get('/api/posts', async (c) => {
91 const posts = await getAllPosts();
92 return c.json(posts);
93});
94
95// API endpoint to get a single post
96app.get('/api/posts/:slug', async (c) => {
97 const slug = c.req.param('slug');
98 const post = await getPost(slug);

helloooooooindex.html2 matches

@charmaine•Updated 1 day ago
116 posts = window.INITIAL_DATA.posts;
117 } else {
118 const response = await fetch('/api/posts');
119 posts = await response.json();
120 }
156
157 try {
158 const response = await fetch(`/api/posts/${params.slug}`);
159
160 if (!response.ok) {

sqliteExplorerApp2README.md1 match

@shouser•Updated 1 day ago
13## Authentication
14
15Login to your SQLite Explorer with [password authentication](https://www.val.town/v/pomdtr/password_auth) with your [Val Town API Token](https://www.val.town/settings/api) as the password.
16
17## Todos / Plans

sqliteExplorerApp2main.tsx2 matches

@shouser•Updated 1 day ago
27 <head>
28 <title>SQLite Explorer</title>
29 <link rel="preconnect" href="https://fonts.googleapis.com" />
30
31 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
32 <link
33 href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@300..700&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap"
34 rel="stylesheet"
35 />

hellooooooofuture-of-blogging.md1 match

@charmaine•Updated 1 day ago
3date: 2023-12-10
4author: Alex Johnson
5summary: Exploring emerging trends and technologies shaping the future of blogging
6---
7

blogggggindex.ts2 matches

@charmaine•Updated 1 day ago
14
15// Get list of blog posts
16app.get("/api/posts", async (c) => {
17 try {
18 const posts = await listBlogPosts();
25
26// Get a specific blog post
27app.get("/api/posts/:slug", async (c) => {
28 const slug = c.req.param("slug");
29 try {

gptApiTemplate2 file matches

@charmaine•Updated 1 day ago

mod-interview-api1 file match

@twschiller•Updated 1 day ago
aquapi
apiv1