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=189&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 16029 results for "api"(1028ms)

yeahREADME.md2 matches

@lulu12โ€ขUpdated 1 week ago
29โ”‚ โ””โ”€โ”€ script.js # Interactive features
30โ”œโ”€โ”€ backend/
31โ”‚ โ””โ”€โ”€ index.ts # API endpoints (newsletter, contact, tracking)
32โ””โ”€โ”€ README.md
33```
37### Immediate Setup:
381. **Replace affiliate links** in the product cards with your actual Amazon/partner links
392. **Connect email service** - Update the newsletter API to integrate with MailerLite/ConvertKit
403. **Add Google Analytics** - Insert your tracking code in the HTML head
414. **Upload free resources** - Host your guides on Google Drive/Gumroad and update download links

yeahindex.ts10 matches

@lulu12โ€ขUpdated 1 week ago
82});
83
84// API Routes
85
86// Newsletter signup
87app.post("/api/newsletter", async c => {
88 try {
89 const { email, source = "website" } = await c.req.json();
97 console.log(`New subscriber: ${email} from ${source}`);
98
99 // Simulate API delay
100 await new Promise(resolve => setTimeout(resolve, 1000));
101
111
112// Contact form
113app.post("/api/contact", async c => {
114 try {
115 const { name, email, message, type = "general" } = await c.req.json();
136
137// Product tracking (for analytics)
138app.post("/api/track", async c => {
139 try {
140 const { event, product_id, category, value } = await c.req.json();
150
151// Get featured products
152app.get("/api/products/featured", async c => {
153 // TODO: Fetch from database or external API
154 const products = [
155 {
183
184// Get products by category
185app.get("/api/products/:category", async c => {
186 const category = c.req.param("category");
187
194
195// Download free resource
196app.post("/api/download/:resource", async c => {
197 try {
198 const resource = c.req.param("resource");
240
241// Health check
242app.get("/api/health", c => {
243 return c.json({
244 status: "healthy",

yeahblog.html1 match

@lulu12โ€ขUpdated 1 week ago
7 <script src="https://cdn.twind.style" crossorigin></script>
8 <link rel="stylesheet" href="/frontend/style.css">
9 <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
10</head>
11<body class="font-inter bg-gray-50">

yeahscript.js1 match

@lulu12โ€ขUpdated 1 week ago
43 button.disabled = true;
44
45 // Simulate API call (replace with actual endpoint)
46 setTimeout(() => {
47 // Success state

chefREADME.md2 matches

@akemyโ€ขUpdated 1 week ago
91- Adjusting colors and styling via TailwindCSS classes
92- Adding new sections or modifying existing ones
93- Integrating with real backend APIs
94
95## ๐ŸŒ Deployment
96
97This is a frontend prototype designed to demonstrate UI/UX concepts. For production use:
981. Replace sample data with real API calls
992. Implement proper authentication
1003. Add form validation and error handling

chefindex.ts1 match

@akemyโ€ขUpdated 1 week ago
19
20// Health check endpoint
21app.get("/api/health", c => {
22 return c.json({ status: "ok", timestamp: new Date().toISOString() });
23});

urban-institutenew-file-1295.tsx9 matches

@sawyeraltmanโ€ขUpdated 1 week ago
1interface ApiParams {
2 var: string;
3 stat: string;
8}
9
10interface ApiResponse {
11 results: any[];
12 count?: number;
18 states?: string[];
19 delay?: number;
20 baseParams: ApiParams;
21}
22
75];
76
77function buildUrl(baseUrl: string, params: ApiParams): string {
78 const url = new URL(baseUrl);
79 Object.entries(params).forEach(([key, value]) => {
98 }
99
100 const data: ApiResponse = await response.json();
101 return data.results || [];
102 } catch (error) {
114async function chunkByState(
115 baseUrl: string,
116 baseParams: ApiParams,
117 states: string[] = STATE_FIPS_CODES,
118 delay = 100,
167async function chunkByYearAndState(
168 baseUrl: string,
169 baseParams: ApiParams,
170 years: string[],
171 states: string[] = STATE_FIPS_CODES,
277 }
278
279 const baseUrl = "https://educationdata.urban.org/api/v1/school-districts/ccd/directory/summaries";
280
281 // Choose chunking strategy
312 });
313 } catch (error) {
314 console.error("API Error:", error);
315
316 return Response.json({

pioREADME.md27 matches

@bartdebโ€ขUpdated 1 week ago
12
13### Advanced Version (`/alternative.ts`)
14Multiple scraping methods including proxy support:
15```
16GET /?keyword=laptop&method=test
17GET /?keyword=laptop&method=scrapingbee # Requires API key
18GET /?keyword=laptop&method=direct # May be blocked
19```
25- ๐Ÿ“„ Support for multiple pages
26- ๐Ÿท๏ธ Detect sponsored products
27- ๐Ÿš€ Fast JSON API response
28- ๐ŸŒ CORS enabled for web apps
29- ๐Ÿ”„ Multiple scraping methods
30- ๐Ÿงช Test mode with sample data
31- ๐Ÿ›ก๏ธ Proxy support via ScrapingBee
32
33## ๐ŸŽฏ Usage Examples
42```
43
44### Real Scraping
45```bash
46# Basic direct scraping (may be blocked)
47curl "https://your-val.web.val.run/?keyword=headphones&pages=2"
48
49# Using ScrapingBee proxy (requires API key)
50curl "https://your-val.web.val.run/alternative?keyword=laptop&method=scrapingbee"
51```
52
76### Environment Variables
77
78For the advanced version with ScrapingBee support:
79
80```bash
81SCRAPINGBEE_API_KEY=your_api_key_here
82```
83
84Get a free API key at [ScrapingBee](https://www.scrapingbee.com/)
85
86### Parameters
91| `pages` | number | No | Number of pages to scrape | 1 |
92| `test` | boolean | No | Use test mode (basic version) | false |
93| `method` | string | No | Scraping method (alternative version) | scrapingbee |
94
95### Scraping Methods (Alternative Version)
96
97- **`test`**: Returns sample data for development
98- **`scrapingbee`**: Uses ScrapingBee proxy service (requires API key)
99- **`direct`**: Direct scraping (often blocked by Amazon)
100
101## ๐Ÿ“‹ Product Data Fields
113- Basic version: 1-second delay between pages
114- Alternative version: 0.5-2 second delays depending on method
115- ScrapingBee method is most reliable for production use
116- Test mode is perfect for development and demos
117
118## ๐Ÿ› ๏ธ Error Handling
119
120The API returns appropriate HTTP status codes:
121- `400`: Missing keyword parameter
122- `500`: Scraping failed (network issues, parsing errors, etc.)
123
124Common error responses include helpful suggestions:
129 "suggestions": [
130 "Try method=test for sample data",
131 "Set SCRAPINGBEE_API_KEY for proxy scraping",
132 "Use method=direct for basic scraping (may be blocked)"
133 ]
134}
138
1391. **Start with test mode** to understand the data structure
1402. **Use ScrapingBee** for reliable production scraping
1413. **Monitor rate limits** and add delays between requests
1424. **Handle errors gracefully** as Amazon actively blocks scrapers
147
148- Review Amazon's robots.txt and terms of service
149- Consider using Amazon's official Product Advertising API for commercial use
150- Respect rate limits and don't overload Amazon's servers
151- Use proxy services like ScrapingBee for production applications
152
153## ๐Ÿ”— Related Services
154
155- [Amazon Product Advertising API](https://webservices.amazon.com/paapi5/documentation/) - Official API
156- [ScrapingBee](https://www.scrapingbee.com/) - Proxy scraping service
157- [Rainforest API](https://www.rainforestapi.com/) - Amazon API alternative

pioalternative.ts30 matches

@bartdebโ€ขUpdated 1 week ago
1/**
2 * Alternative Amazon Scraper using ScrapingBee API
3 *
4 * This version uses ScrapingBee's proxy service to bypass Amazon's anti-bot measures.
5 * You'll need to set SCRAPINGBEE_API_KEY environment variable.
6 *
7 * Get a free API key at: https://www.scrapingbee.com/
8 */
9
30 const keyword = url.searchParams.get('keyword');
31 const pages = parseInt(url.searchParams.get('pages') || '1');
32 const method = url.searchParams.get('method') || 'scrapingbee';
33
34 if (!keyword) {
35 return new Response(JSON.stringify({
36 error: 'Missing keyword parameter',
37 usage: 'GET /?keyword=your+search+term&pages=1&method=scrapingbee',
38 methods: ['scrapingbee', 'direct', 'test'],
39 note: 'Set SCRAPINGBEE_API_KEY environment variable for scrapingbee method'
40 }), {
41 status: 400,
48
49 switch (method) {
50 case 'scrapingbee':
51 results = await scrapeWithScrapingBee(keyword, pages);
52 break;
53 case 'direct':
58 break;
59 default:
60 throw new Error('Invalid method. Use: scrapingbee, direct, or test');
61 }
62
68 });
69 } catch (error) {
70 console.error('Scraping error:', error);
71 return new Response(JSON.stringify({
72 error: 'Failed to scrape Amazon',
74 suggestions: [
75 'Try method=test for sample data',
76 'Set SCRAPINGBEE_API_KEY for proxy scraping',
77 'Use method=direct for basic scraping (may be blocked)'
78 ]
79 }), {
84}
85
86async function scrapeWithScrapingBee(keyword: string, maxPages: number): Promise<ScrapedData> {
87 const apiKey = Deno.env.get('SCRAPINGBEE_API_KEY');
88
89 if (!apiKey) {
90 throw new Error('SCRAPINGBEE_API_KEY environment variable not set. Get one at https://www.scrapingbee.com/');
91 }
92
96 const amazonUrl = buildAmazonSearchUrl(keyword, page);
97
98 const scrapingBeeUrl = new URL('https://app.scrapingbee.com/api/v1/');
99 scrapingBeeUrl.searchParams.set('api_key', apiKey);
100 scrapingBeeUrl.searchParams.set('url', amazonUrl);
101 scrapingBeeUrl.searchParams.set('render_js', 'false');
102 scrapingBeeUrl.searchParams.set('premium_proxy', 'true');
103 scrapingBeeUrl.searchParams.set('country_code', 'us');
104
105 console.log(`Scraping page ${page} via ScrapingBee...`);
106
107 const response = await fetch(scrapingBeeUrl.toString());
108
109 if (!response.ok) {
110 throw new Error(`ScrapingBee API error: ${response.status} ${response.statusText}`);
111 }
112
126 products: allProducts,
127 scrapedAt: new Date().toISOString(),
128 method: 'scrapingbee'
129 };
130}
135 for (let page = 1; page <= maxPages; page++) {
136 const searchUrl = buildAmazonSearchUrl(keyword, page);
137 console.log(`Direct scraping page ${page}: ${searchUrl}`);
138
139 const response = await fetch(searchUrl, {
163 allProducts.push(...products);
164
165 // Longer delay for direct scraping
166 if (page < maxPages) {
167 await new Promise(resolve => setTimeout(resolve, 2000));

pioindex.ts3 matches

@bartdebโ€ขUpdated 1 week ago
98 });
99 } catch (error) {
100 console.error('Scraping error:', error);
101 return new Response(JSON.stringify({
102 error: 'Failed to scrape Amazon',
103 message: error.message,
104 tip: 'Amazon may be blocking requests. Try using a different approach or the official Amazon API.',
105 testMode: 'Add &test=true to see sample data structure'
106 }), {
116 for (let page = 1; page <= maxPages; page++) {
117 const searchUrl = buildAmazonSearchUrl(keyword, page);
118 console.log(`Scraping page ${page}: ${searchUrl}`);
119
120 const response = await fetch(searchUrl, {

googleGeminiAPI2 file matches

@michaelwschultzโ€ขUpdated 16 hours ago

HN-fetch-call2 file matches

@ImGqbโ€ขUpdated 3 days ago
fetch HackerNews by API
Kapil01
apiv1