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=1228&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 18778 results for "api"(7669ms)

HONChome.tsx2 matches

@cameronpak•Updated 3 months ago
37 </head>
38 <body class={bodyStyles}>
39 <h1>🪿 Welcome to my HONC API! 🪿</h1>
40 <p>
41 Visit <a href="/fp" class={linkStyles}>/fp</a> to view the Fiberplane API explorer.
42 </p>
43 </body>

HONCfiberplane.ts2 matches

@cameronpak•Updated 3 months ago
1import { createFiberplane, createOpenAPISpec } from "https://esm.sh/@fiberplane/hono@0.4.4";
2
3export { createFiberplane, createOpenAPISpec };

HONChome.tsx2 matches

@fiberplane•Updated 3 months ago
37 </head>
38 <body class={bodyStyles}>
39 <h1>🪿 Welcome to my HONC API! 🪿</h1>
40 <p>
41 Visit <a href="/fp" class={linkStyles}>/fp</a> to view the Fiberplane API explorer.
42 </p>
43 </body>

telegramBotStarterindex.ts1 match

@std•Updated 3 months ago
30 // This is a no-op if nothing's changed
31 if (!isEndpointSet) {
32 await bot.api.setWebhook(req.url, {
33 secret_token: SECRET_TOKEN,
34 });

queryParamsREADME.md1 match

@charmaine•Updated 3 months ago
1# Handling query params in requests
2
3Using the standard [URL#searchParams](https://developer.mozilla.org/en-US/docs/Web/API/URL/searchParams) method, you can grab query parameters out of any val that is operating using the [Web API](https://docs.val.town/api/web).
4
5This val demonstrates how to grab one or more query parameters. It returns the all the query parameters found as a json response.

htmlExampleREADME.md2 matches

@charmaine•Updated 3 months ago
1# Returning HTML from the Val Town Web API
2
3This just lets you use the standard [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) object with our [Web API](https://docs.val.town/api/web) to return an HTML response from this Val.

gracefulVioletTunavt3 matches

@charmaine•Updated 3 months ago
1export default async function createProject(projectName) {
2 const apiToken = Deno.env.get("VAL_TOWN_RW_PROJECTS");
3
4 const response = await fetch("https://api.val.town/v1/projects", {
5 method: "POST",
6 headers: {
7 "Content-Type": "application/json",
8 "Authorization": `Bearer ${apiToken}`,
9 },
10 body: JSON.stringify({

aqiREADME.md1 match

@charmaine•Updated 3 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

discordWebhookWeatherHydmain.tsx1 match

@charmaine•Updated 3 months ago
9const getForecast = async () => {
10 const forecastData = await fetchJSON(
11 `http://dataservice.accuweather.com/forecasts/v1/daily/1day/${accuweatherCityCode}?apikey=${process.env.accuWeather}&details=true&metric=true`,
12 );
13 return forecastData.DailyForecasts[0];

projectConverterDraftconverter.ts15 matches

@charmaine•Updated 3 months ago
3}
4
5async function convertValToProject(input: string, apiToken: string): Promise<string> {
6 try {
7 const projectName = generateProjectName();
8
9 // Create a new project
10 const projectResponse = await fetch("https://api.val.town/v1/projects", {
11 method: "POST",
12 headers: {
13 "Content-Type": "application/json",
14 "Authorization": `Bearer ${apiToken}`,
15 },
16 body: JSON.stringify({
37 const directories = getUniqueDirectories(files);
38 for (const dir of directories) {
39 await createDirectory(project.id, dir, apiToken);
40 }
41
42 // Create all files
43 for (const file of files) {
44 await createFile(project.id, file, apiToken);
45 }
46
138}
139
140async function createDirectory(projectId: string, directoryPath: string, apiToken: string): Promise<void> {
141 const encodedPath = encodeURIComponent(directoryPath);
142 const response = await fetch(`https://api.val.town/v1/projects/${projectId}/files/${encodedPath}`, {
143 method: "POST",
144 headers: {
145 "Content-Type": "application/json",
146 "Authorization": `Bearer ${apiToken}`,
147 },
148 body: JSON.stringify({ type: "directory" }),
158 projectId: string,
159 file: { path: string; content: string; type: string },
160 apiToken: string,
161): Promise<void> {
162 const validTypes = ["script", "file", "directory", "http"];
167
168 const encodedPath = encodeURIComponent(file.path);
169 const fileResponse = await fetch(`https://api.val.town/v1/projects/${projectId}/files/${encodedPath}`, {
170 method: "POST",
171 headers: {
172 "Content-Type": "application/json",
173 "Authorization": `Bearer ${apiToken}`,
174 },
175 body: JSON.stringify({
443app.post("/convert", async (c) => {
444 try {
445 const { valCode, apiToken } = await c.req.json();
446
447 if (!apiToken) {
448 return c.json({ message: "Error: API token is required" }, 400);
449 }
450
451 const result = await convertValToProject(valCode, apiToken);
452 return c.json({ message: result });
453 } catch (error) {

helloEffectHttpApi1 file match

@mattrossman•Updated 6 hours ago

html-to-pdf-api2 file matches

@prashamtrivedi•Updated 18 hours ago
HTML to PDF converter API with blob storage
apiry
snartapi