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=212&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 13013 results for "api"(825ms)

hn_job_analyzerhnService.ts1 match

@prashamtrivedi•Updated 2 weeks ago
74}
75
76// Helper function to fetch an item from the HN API
77async function fetchItem(id: number): Promise<any> {
78 const response = await fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`);

hn_job_analyzeraiAnalyzer.ts1 match

@prashamtrivedi•Updated 2 weeks ago
3
4// Initialize the Google Gemini model
5const GEMINI_API_KEY = Deno.env.get('GEMINI_API_KEY') || '';
6const model = google('gemini-2.5-flash', {
7 structuredOutputs: true,

discord-botapi-server.js10 matches

@boucher•Updated 2 weeks ago
1import express from 'express';
2import { getMessages, getLinks, getCategories, updateLinkCategory } from './database.js';
3import { Configuration, OpenAIApi } from 'openai';
4import 'dotenv/config';
5
10// Initialize OpenAI for AI-powered queries
11const configuration = new Configuration({
12 apiKey: process.env.OPENAI_API_KEY,
13});
14const openai = new OpenAIApi(configuration);
15
16/**
37 `;
38
39 // Call OpenAI API
40 const response = await openai.createCompletion({
41 model: "gpt-3.5-turbo-instruct",
52}
53
54// API routes
55
56// Health check endpoint
60
61// Get messages with optional filters
62app.get('/api/messages', (req, res) => {
63 try {
64 const filters = {
79
80// Get links with optional filters
81app.get('/api/links', (req, res) => {
82 try {
83 const filters = {
98
99// Get all categories
100app.get('/api/categories', (req, res) => {
101 try {
102 const categories = getCategories();
109
110// Update link category
111app.put('/api/links/:id/category', (req, res) => {
112 try {
113 const { id } = req.params;
127
128// AI-powered query endpoint
129app.post('/api/query', async (req, res) => {
130 try {
131 const { query, filters } = req.body;

discord-botanthropic-service.js1 match

@boucher•Updated 2 weeks ago
4// Initialize Anthropic client
5const anthropic = new Anthropic({
6 apiKey: process.env.ANTHROPIC_API_KEY,
7});
8

discord-botdiscord-client.js1 match

@boucher•Updated 2 weeks ago
49 let keepFetching = true;
50
51 // Fetch messages in batches of 100 (Discord API limit)
52 while (keepFetching) {
53 const options = { limit: 100 };

discord-botinteractions-endpoint.js1 match

@boucher•Updated 2 weeks ago
28
29// Discord interaction endpoint
30app.post('/api/interactions', async (req, res) => {
31 const { type, data } = req.body;
32

discord-bot.env.example3 matches

@boucher•Updated 2 weeks ago
1# Discord API credentials
2DISCORD_TOKEN=your_discord_token_here
3DISCORD_CLIENT_ID=your_client_id_here
5SPOUSE_USER_ID=spouse_user_id_here
6
7# OpenAI API key (for AI-powered querying)
8OPENAI_API_KEY=your_openai_api_key_here
9
10# Val.town settings

discord-botREADME.md8 matches

@boucher•Updated 2 weeks ago
25- Node.js 16+ and npm
26- Discord account with Bot token
27- OpenAI API key (for AI-powered queries)
28- Val.town account (for deployment)
29
51 - `DISCORD_USER_ID`: Your Discord user ID
52 - `SPOUSE_USER_ID`: Your partner's Discord user ID
53 - `OPENAI_API_KEY`: Your OpenAI API key
54
555. Initialize the database
1037. Start a DM with your partner to create the DM channel the bot will monitor
104
105## API Endpoints
106
107The application exposes the following HTTP endpoints:
108
109- `GET /health`: Health check endpoint
110- `POST /api/fetch-dms`: Manually trigger DM fetching
111- `POST /api/process-links`: Manually trigger link processing
112- `POST /api/query`: Submit a query about your message history
113 - Body: `{ "query": "your question here", "filters": { optional filters } }`
114- `POST /api/commands/search`: Discord command endpoint for searching
115 - Body: `{ "query": "your search term" }`
116
145## Acknowledgements
146
147- Discord.js for Discord API integration
148- OpenAI for AI-powered querying
149- Val.town for hosting and scheduling

discord-bot.cursorrules10 matches

@boucher•Updated 2 weeks ago
13- Generate code in TypeScript or TSX
14- Add appropriate TypeScript types and interfaces for all data structures
15- Prefer official SDKs or libraries than writing API calls directly
16- Ask the user to supply API or library documentation if you are at all unsure about it
17- **Never bake in secrets into the code** - always use environment variables
18- Include comments explaining complex logic (avoid commenting obvious operations)
23### 1. HTTP Trigger
24
25- Create web APIs and endpoints
26- Handle HTTP requests and responses
27- Example structure:
173However, it's *extremely importing* to note that `parseProject` and other Standard Library utilities ONLY RUN ON THE SERVER.
174If you need access to this data on the client, run it in the server and pass it to the client by splicing it into the HTML page
175or by making an API request for it.
176
177## Val Town Platform Specifics
181- **AI Image:** To inline generate an AI image use: `<img src="https://maxm-imggenurl.web.val.run/the-description-of-your-image" />`
182- **Storage:** DO NOT use the Deno KV module for storage
183- **Browser APIs:** DO NOT use the `alert()`, `prompt()`, or `confirm()` methods
184- **Weather Data:** Use open-meteo for weather data (doesn't require API keys) unless otherwise specified
185- **View Source:** Add a view source link by importing & using `import.meta.url.replace("ems.sh", "val.town)"` (or passing this data to the client) and include `target="_top"` attribute
186- **Error Debugging:** Add `<script src="https://esm.town/v/std/catch"></script>` to HTML to capture client-side errors
187- **Error Handling:** Only use try...catch when there's a clear local resolution; Avoid catches that merely log or return 500s. Let errors bubble up with full context
188- **Environment Variables:** Use `Deno.env.get('keyname')` when you need to, but generally prefer APIs that don't require keys
189- **Imports:** Use `https://esm.sh` for npm and Deno dependencies to ensure compatibility on server and browser
190- **Storage Strategy:** Only use backend storage if explicitly required; prefer simple static client-side sites
224### Backend (Hono) Best Practices
225
226- Hono is the recommended API framework
227- Main entry point should be `backend/index.ts`
228- **Static asset serving:** Use the utility functions to read and serve project files:
248 });
249 ```
250- Create RESTful API routes for CRUD operations
251- Always include this snippet at the top-level Hono app to re-throwing errors to see full stack traces:
252 ```ts
285 - For files in the project, use `readFile` helpers
286
2875. **API Design:**
288 - `fetch` handler is the entry point for HTTP vals
289 - Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`

discord-botindex.js5 matches

@boucher•Updated 2 weeks ago
13initializeDatabase();
14
15// API routes
16
17// Health check endpoint
21
22// Manual trigger for fetching DMs
23app.post('/api/fetch-dms', async (req, res) => {
24 try {
25 console.log('Manually triggering DM fetch...');
33
34// Manual trigger for processing links
35app.post('/api/process-links', async (req, res) => {
36 try {
37 console.log('Manually triggering link processing...');
45
46// Query endpoint
47app.post('/api/query', async (req, res) => {
48 try {
49 const { query, filters } = req.body;
62
63// Discord command endpoints
64app.post('/api/commands/search', async (req, res) => {
65 try {
66 const { query } = req.body;

vapi-minutes-db1 file match

@henrywilliams•Updated 2 days ago

vapi-minutes-db2 file matches

@henrywilliams•Updated 2 days ago
snartapi
mux
Your friendly, neighborhood video API.