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/$%7Burl%7D?q=api&page=927&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 13254 results for "api"(1724ms)

sqlitemain.tsx4 matches

@alexandrephUpdated 6 months ago
1import { API_URL } from "https://esm.town/v/std/API_URL";
2import { LibsqlError, type ResultSet, type Row, type TransactionMode } from "npm:@libsql/client";
3import { z } from "npm:zod";
35
36async function execute(statement: InStatement, args?: InArgs): Promise<ResultSet> {
37 const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38 method: "POST",
39 headers: {
50
51async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
52 const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
53 method: "POST",
54 headers: {
78
79/* Val Town's Turso Proxy returns rows as an array of values
80 * Yet the LibSQL API has a Row type which behave as an array or object,
81 * ie you can access it via numerical index or string
82 */

handleDiscordNewUsermain.tsx1 match

@buttondownUpdated 6 months ago
23
24 try {
25 const response = await fetch(`https://www.shovel.report/api/domains/${domain}`);
26 if (!response.ok) {
27 throw new Error(`HTTP error! status: ${response.status}`);

giftSuggestionAppmain.tsx5 matches

@trollishkaUpdated 6 months ago
40
41 try {
42 const response = await fetch("/api/shopping-assistant", {
43 method: "POST",
44 headers: { "Content-Type": "application/json" },
48 if (!response.ok) {
49 const errorData = await response.json().catch(() => ({}));
50 console.error("API error response:", errorData);
51 throw new Error(errorData.error || `HTTP error! status: ${response.status}`);
52 }
53
54 const data = await response.json();
55 console.log("API response:", data);
56 if (!data.suggestions || !Array.isArray(data.suggestions)) {
57 throw new Error("No suggestions received from the server");
229 const url = new URL(req.url);
230
231 if (url.pathname === "/api/shopping-assistant") {
232 try {
233 const { age, budget, shownSuggestions } = await req.json();
310 <meta charset="utf-8">
311 <meta name="viewport" content="width=device-width, initial-scale=1">
312 <link href="https://fonts.googleapis.com/css2?family=Mountains+of+Christmas:wght@400;700&family=Poppins:wght@400;700&display=swap" rel="stylesheet">
313 <style>${css}</style>
314 </head>

sanguineCyanMastodonREADME.md10 matches

@mikehigginsUpdated 6 months ago
9Fun fact generation about the text (e.g., average word length)
10Summary generation
11The tool is implemented in JavaScript using Hono as a lightweight framework and integrates web APIs for fetching external content and analyzing it in real-time.
12
13Code Structure
14Imports
15
16Hono: Used for routing and handling API requests.
17encode (from JS Base64): Utility for encoding data.
18parse (from Node HTML Parser): Parses HTML content, used in fetchUrlContent to clean and extract text.
99
100Verify that cleanText removes sensitive information from fetched URLs to prevent accidental disclosure.
101Rate Limits and API Usage
102
103Consider implementing rate limiting or caching mechanisms to manage heavy usage or repeated requests for the same content.
111Advanced Sentiment Analysis
112
113Implement a sentiment analysis library or API for more nuanced scoring and classification.
114
115Multilingual Support
117Extend stop words, sentiment analysis, and cleaning functions to support languages beyond English.
118
119The Radical Text Analyser code primarily uses the following APIs:
1201. Hono Framework API
121 * Purpose: Used to set up routing and serve responses for different endpoints (GET /, POST /analyse, and POST /fetch-url).
122 * Usage: The Hono framework handles HTTP requests and responses, forming the backbone of the server-side API.
1232. External Content Fetching API (via fetch)
124 * Purpose: Retrieves HTML content from external URLs when users input a URL for analysis.
125 * Usage: The fetchUrlContent function uses fetch to make a GET request to the user-provided URL, which allows the application to process content from web pages.
126 * Error Handling: Includes logic to check response status and handle various network errors.
1273. Google Fonts API
128 * Purpose: Loads the "VT323" font for styling the front-end.
129 * Usage: Linked in the HTML <head> section via <link href="https://fonts.googleapis.com/css2?family=VT323&display=swap">.
1304. jQCloud Library (via CDN)
131 * Purpose: Used for generating a word cloud from frequency data on the client side.

twitterAlertREADME.md3 matches

@samwhoUpdated 6 months ago
4
5This val gets Twitter data via [SocialData](https://socialdata.tools) via
6@stevekrouse/socialDataProxy. Val Town Pro users can call this API
7100 times per day, so be sure not to set this cron to run more than once every 15 min.
8If you want to use it more, get your own [SocialData](https://socialdata.tools)
9API token and pay for it directly.
10
11## 1. Query
13Change the `query` variable for what you want to get notified for.
14
15You can use [Twitter's search operators](https://developer.twitter.com/en/docs/twitter-api/v1/rules-and-filtering/search-operators) to customize your query, for some collection of keywords, filtering out others, and much more!
16
17## 2. Notification

gptmemoryREADME.md21 matches

@toowiredUpdated 6 months ago
1A simple Rest API that allows for you GPT to save and recall snippets of data (memories). You can read my blog post explaining it in detail here: [xkonti.tech](https://xkonti.tech/blog/giving-gpt-memory/)
2
3# Demonstration
7![FirstConversation.png](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/78c48b8b-8a1b-4caf-ef23-2ad78be3a100/public)
8
9What GPT sent do the API:
10
11```json
24# Setup
25
26There are several steps to set up the API:
27- deploy and configure the API
28- create the API key for your GPT
29- add an action for the API in you GPT
30- add prompt section to your GPT so that it can use it properly
31
32## Deploying the API on Val Town
33
34Deploy your own memory API. You can fork the following Val to do it: https://www.val.town/v/xkonti/memoryApiExample
35
36In the code configure the appropriate values:
37
38- `apiName` the name of your API - used in the Privacy Policy (eg. `Memory API`)
39- `contactEmail` - the email to provide for contact in the Privacy Policy (eg. `some@email.com`)
40- `lastPolicyUpdate` - the date the Privacy Policy was last updated (eg. `2023-11-28`)
41- `blobKeyPrefix` - the prefix for the blob storage keys used by your API - more info below (eg. `gpt:memories:`)
42- `apiKeyPrefix` - the prefix for you API Keys secrets - more info below (eg. `GPTMEMORYAPI_KEY_`)
43
44## Create API keys
45
46The Memory API is designed to serve multiple GPTs at the same time. Each GPT should have it's own unique **name** and **API key**.
47
48The **name** is used for identifying the specific GPT and appended to both:
49- `blobKeyPrefix`- to maintain separate memory storage from other GPTs
50- `apiKeyPrefix` - to maintain separate API key for each GPT
51
521. Please pick a unique alphanumeric name for your GPT. For example `personaltrainer`.
532. Generate some alphanumeric API key for your GPT. For example `Wrangle-Chapped-Monkhood4-Domain-Suspend`
543. Add a new secret to your Val.town secrets storage. The Key should be the picked name prefixed by `apiKeyPrefix`. Using the default it would be `GPTMEMORYAPI_KEY_personaltrainer`. The value of the secret should be the API key itself.
55
56The memories of the GPT will be stored in the blob storage under the key `blobKeyPrefix + name`, for example: `gpt:memories:personaltrainer`.
59
601. Add a new action in your GPT.
612. Get the OpenAPI spefication by calling the `/openapi` endpoint of your API
623. Change all `<APIURL>` instances within the specification to the url of your deployed API. For example `https://xkonti-memoryapiexample.web.val.run`
634. Set the authentication method to basic and provide a [base64 encoded](https://www.base64encode.org/) version of the `<name>:<apiKey>`. For example: `personaltrainer:Wrangle-Chapped-Monkhood4-Domain-Suspend` -> `cGVyc29uYWx0cmFpbmVyOldyYW5nbGUtQ2hhcHBlZC1Nb25raG9vZDQtRG9tYWluLVN1c3BlbmQ=`
645. Add the link to the privacy policy, which is the `/privacy` endpoint of your API. For example: `https://xkonti-memoryapiexample.web.val.run/privacy`
65
66## Adding the prompt section
86```
87
88Migrated from folder: APIs/gptmemory

basicAuthREADME.md1 match

@a4v2d4Updated 6 months ago
17```
18
19If you want to use an apiToken as a password:
20
21```ts

assertiveTanMeadowlarkREADME.md1 match

@gwthompsonUpdated 6 months ago
8
91. Click `Fork`
102. Change `location` (Line 4) to describe your location. It accepts fairly flexible English descriptions which it turns into locations via [nominatim's geocoder API](https://www.val.town/v/stevekrouse/nominatimSearch).
113. Click `Run`
12

passwordGenmain.tsx11 matches

@allUpdated 6 months ago
157 const [policy, setPolicy] = useState({
158 minLength: 12,
159 requireCapital: true,
160 requireSpecial: true,
161 allowedSpecial: "!@#$%^&*()_+-=[]{}|;:,.<>?",
174 ...policy,
175 minLength: 8,
176 requireCapital: false,
177 requireSpecial: false,
178 });
182 ...policy,
183 minLength: 12,
184 requireCapital: true,
185 requireSpecial: true,
186 });
190 ...policy,
191 minLength: 16,
192 requireCapital: true,
193 requireSpecial: true,
194 });
292 <input
293 type="checkbox"
294 id="requireCapital"
295 checked={policy.requireCapital}
296 onChange={(e) => setPolicy({ ...policy, requireCapital: e.target.checked })}
297 className="w-5 h-5 text-green-600"
298 />
299 <label htmlFor="requireCapital" className="text-lg">Require Capital Letter</label>
300 </div>
301 <div className="flex items-center space-x-2">
453 <meta name="viewport" content="width=device-width, initial-scale=1.0">
454 <title>Advanced Password Generation System</title>
455 <link href="https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@400;700&display=swap" rel="stylesheet">
456 <script src="https://cdn.tailwindcss.com"></script>
457 <script>
586 password = password.slice(0, insertIndex) + securePhrase + password.slice(insertIndex);
587
588 // Ensure capital letter if required
589 if (policy.requireCapital && !/[A-Z]/.test(password)) {
590 const index = Math.floor(Math.random() * password.length);
591 password = password.slice(0, index) + password[index].toUpperCase() + password.slice(index + 1);

fullPageWebsiteScrapermain.tsx4 matches

@willthereaderUpdated 6 months ago
78 console.log("Debug - Full query being sent:", query);
79
80 console.log(`Making LSD API request for ${websiteUrl}`);
81 const response = await fetch(
82 `https://lsd.so/api?query=${encodeURIComponent(query)}`,
83 );
84
161 a`;
162
163 console.log(`Making LSD API request for ${pageUrl}`);
164 const response = await fetch(
165 `https://lsd.so/api?query=${encodeURIComponent(pageQuery)}`,
166 );
167

vapi-minutes-db1 file match

@henrywilliamsUpdated 3 days ago

vapi-minutes-db2 file matches

@henrywilliamsUpdated 3 days ago
socialdata
Affordable & reliable alternative to Twitter API: ➡️ Access user profiles, tweets, followers & timeline data in real-time ➡️ Monitor profiles with nearly instant alerts for new tweets, follows & profile updates ➡️ Simple integration
artivilla
founder @outapint.io vibe coding on val.town. dm me to build custom vals: https://artivilla.com