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/$%7Bsuccess?q=api&page=147&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"(1427ms)

GitHub-Release-Notes

GitHub-Release-Notesgithub.ts20 matches

@charmaineUpdated 1 week ago
26 let hasMorePages = true;
27
28 // GitHub API headers
29 const headers = {
30 "Accept": "application/vnd.github.v3+json",
31 "Authorization": `Bearer ${token}`,
32 "User-Agent": "GitHub-Release-Notes-Generator",
33 "X-GitHub-Api-Version": "2022-11-28",
34 };
35
39 while (hasMorePages) {
40 const url =
41 `https://api.github.com/repos/${owner}/${repo}/commits?since=${sinceISO}&until=${untilISO}&per_page=100&page=${page}`;
42 console.log(`Fetching page ${page}...`);
43
46 if (!response.ok) {
47 const error = await response.text();
48 throw new Error(`GitHub API error: ${response.status} - ${error}`);
49 }
50
77 prNumber: number,
78): Promise<GitHubPR | null> {
79 const url = `https://api.github.com/repos/${owner}/${repo}/pulls/${prNumber}`;
80
81 const response = await fetch(url, {
84 "Authorization": `Bearer ${token}`,
85 "User-Agent": "GitHub-Release-Notes-Generator",
86 "X-GitHub-Api-Version": "2022-11-28",
87 },
88 });
94 if (!response.ok) {
95 const error = await response.text();
96 throw new Error(`GitHub API error: ${response.status} - ${error}`);
97 }
98
109 commitSha: string,
110): Promise<GitHubPR[]> {
111 const url = `https://api.github.com/repos/${owner}/${repo}/commits/${commitSha}/pulls`;
112
113 const response = await fetch(url, {
116 "Authorization": `Bearer ${token}`,
117 "User-Agent": "GitHub-Release-Notes-Generator",
118 "X-GitHub-Api-Version": "2022-11-28",
119 },
120 });
126 if (!response.ok) {
127 const error = await response.text();
128 throw new Error(`GitHub API error: ${response.status} - ${error}`);
129 }
130
133
134/**
135 * Fetches issues referenced by a commit or PR using GitHub API
136 */
137async function fetchIssueReferences(
147 // If we have a PR number, check for issues closed by the PR
148 if (prNumber) {
149 const prIssuesUrl = `https://api.github.com/repos/${owner}/${repo}/pulls/${prNumber}/commits`;
150
151 const prResponse = await fetch(prIssuesUrl, {
154 "Authorization": `Bearer ${token}`,
155 "User-Agent": "GitHub-Release-Notes-Generator",
156 "X-GitHub-Api-Version": "2022-11-28",
157 },
158 });
161 const prCommits = await prResponse.json();
162
163 // Extract issue numbers from commit messages using the GitHub API pattern
164 for (const commit of prCommits) {
165 // Look for "Fixes #X", "Closes #X", "Resolves #X" patterns that GitHub recognizes
180 // Also check the timeline of the PR to find linked issues
181 if (prNumber) {
182 const timelineUrl = `https://api.github.com/repos/${owner}/${repo}/issues/${prNumber}/timeline`;
183
184 const timelineResponse = await fetch(timelineUrl, {
187 "Authorization": `Bearer ${token}`,
188 "User-Agent": "GitHub-Release-Notes-Generator",
189 "X-GitHub-Api-Version": "2022-11-28",
190 },
191 });
213 * Fetches commits and their associated PRs
214 * Includes progress tracking for large repositories
215 * Uses GitHub API to find PR and issue references
216 */
217export async function fetchCommitsWithPRs(
231
232 // Process commits in batches to not get rate limited
233 const BATCH_SIZE = 5; // Reduced batch size since we're making more API calls per commit
234 for (let i = 0; i < commits.length; i += BATCH_SIZE) {
235 const batch = commits.slice(i, i + BATCH_SIZE);
236 const batchPromises = batch.map(async (commit) => {
237 // Use GitHub API to find associated PRs for this commit
238 const associatedPRs = await fetchPRsForCommit(token, owner, repo, commit.sha);
239
245 pr = associatedPRs[0]; // Use the first PR if multiple exist
246
247 // Get issue references using the GitHub API
248 const prIssueRefs = await fetchIssueReferences(token, owner, repo, commit.sha, pr.number);
249 issueRefs = [...prIssueRefs];
GitHub-Release-Notes

GitHub-Release-Notesllm.ts1 match

@charmaineUpdated 1 week ago
186`;
187
188 // Call the OpenAI API
189 const completion = await openai.chat.completions.create({
190 model: "gpt-4o",

Townieuser-summary.ts1 match

@jxnblkUpdated 1 week ago
20 SUM(num_images) as total_images
21 FROM ${USAGE_TABLE}
22 WHERE our_api_token = 1
23 GROUP BY user_id, username
24 ORDER BY total_price DESC

TownieuseProject.tsx2 matches

@jxnblkUpdated 1 week ago
2import { useAuth } from "./useAuth.tsx";
3
4const PROJECT_ENDPOINT = "/api/project";
5const FILES_ENDPOINT = "/api/project-files";
6
7export function useProject (projectId: string, branchId?: string) {

TownieuseProjects.tsx1 match

@jxnblkUpdated 1 week ago
2import { useAuth } from "./useAuth.tsx";
3
4const ENDPOINT = "/api/projects-loader";
5
6export function useProjects () {

TownieuseCreateProject.tsx1 match

@jxnblkUpdated 1 week ago
3import { useAuth } from "./useAuth.tsx";
4
5const ENDPOINT = "/api/create-project";
6
7export function useCreateProject () {

TownieuseCreateBranch.tsx1 match

@jxnblkUpdated 1 week ago
2import { useAuth } from "./useAuth.tsx";
3
4const ENDPOINT = "/api/create-branch";
5
6export function useCreateBranch (projectId: string) {

TownieuseChatLogic.ts4 matches

@jxnblkUpdated 1 week ago
6 project: any;
7 branchId: string | undefined;
8 anthropicApiKey: string;
9 bearerToken: string;
10 selectedFiles: string[];
16 project,
17 branchId,
18 anthropicApiKey,
19 bearerToken,
20 selectedFiles,
37 status,
38 } = useChat({
39 api: "/api/send-message",
40 body: {
41 project,
42 branchId,
43 anthropicApiKey,
44 selectedFiles,
45 images: images

TownieuseBranches.tsx1 match

@jxnblkUpdated 1 week ago
2import { useAuth } from "./useAuth.tsx";
3
4const ENDPOINT = "/api/project-branches";
5
6export function useBranches (projectId: string) {

TownieuseAuth.tsx11 matches

@jxnblkUpdated 1 week 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}

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