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=616&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 11605 results for "api"(1584ms)

ReactStaticREADME.md4 matches

@jxnblkUpdated 3 months ago
29
30Custom middleware can be added in an array as the second argument.
31Middleware can add data to the `req.data` object or return a response for things like API endpoints.
32
33```tsx
55```tsx
56// example middleware
57async function api (req: Request, res: Response, next): Promise<Response> {
58 if (req.pathname !== "/api") return next();
59 if (req.method === "POST") {
60 return Repsonse.json({ message: "Hello POST request" });
63}
64
65export default render(App, [ api ]);
66```
67

ReactStream_migratedmain.tsx7 matches

@jxnblkUpdated 3 months ago
34 const useMiddleware = Array.isArray(opts); // for backwards compat
35 const options: ReactStreamOptions = !Array.isArray(opts) ? opts : {};
36 const { api, getInitialProps } = options;
37
38 if (typeof document !== "undefined" && module) {
48 // DEPRECATED (for backwards compat)
49 options.robots && robots(options.robots),
50 options.api && deprecatedCustomAPI(options.api),
51 options.getInitialProps && deprecatedGetInitiaProps(options.getInitialProps),
52 // New custom middleware
127// DEPRECATED
128// DEPRECATE (for backwards compat)
129const deprecatedCustomAPI = (api?: RequestHandler): Middleware => async (req, res, next) => {
130 if (!api) return next();
131 if (req.method === "GET") return next();
132 return api(req);
133};
134const deprecatedGetInitiaProps = (getProps: DataFetcher<any>): Middleware => async (req, res, next) => {
142 /** DEPRECATED: Optional text response for robots.txt */
143 robots?: string;
144 /** DEPRECATED: Optional API request handler for all non-GET methods */
145 api?: RequestHandler;
146 /** DEPRECATED: data fetcher to set initial props based on request */
147 getInitialProps?: DataFetcher<any>;

myBookmarkManagermain.tsx11 matches

@arfanUpdated 3 months ago
181 // ----------------- Data Loading -----------------
182 async function fetchSavedBookmarks() {
183 const response = await fetch("/api/bookmarks");
184 const data = await response.json();
185 setAllSavedBookmarks(data);
232 e.preventDefault();
233 if (editBookmarkId === null) {
234 const response = await fetch("/api/bookmarks", {
235 method: "POST",
236 headers: { "Content-Type": "application/json" },
251 }
252 } else {
253 const response = await fetch(`/api/bookmarks/${editBookmarkId}`, {
254 method: "PUT",
255 headers: { "Content-Type": "application/json" },
274 // ----------------- Export / Import -----------------
275 async function saveAllBookmarks() {
276 const response = await fetch("/api/bookmarks/export");
277 const bookmarkData = await response.text(); // Get as text instead of blob
278 const blob = new Blob([bookmarkData], { type: "application/json" });
297 try {
298 const loadedBookmarks = JSON.parse(fileContent);
299 const response = await fetch("/api/bookmarks/import", {
300 method: "POST",
301 headers: { "Content-Type": "application/json" },
1294 <title>My Bookmark Manager</title>
1295 <link
1296 href="https://fonts.googleapis.com/css2?family=Quicksand:wght@300;400;500;600;700&display=swap"
1297 rel="stylesheet"
1298 />
1342});
1343
1344app.get("/api/bookmarks", async (c) => {
1345 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1346 await sqlite.execute(`
1363});
1364
1365app.post("/api/bookmarks", async (c) => {
1366 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1367 const {
1394});
1395
1396app.put("/api/bookmarks/:id", async (c) => {
1397 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1398 const id = c.req.param("id");
1473});
1474
1475app.get("/api/bookmarks/export", async (c) => {
1476 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1477 const bookmarks = await sqlite.execute(`
1488});
1489
1490app.post("/api/bookmarks/import", async (c) => {
1491 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1492 const importedBookmarks = await c.req.json();

falDemoAppmain.tsx2 matches

@ben5mills5Updated 3 months ago
15 try {
16 const fal = createFalClient({
17 proxyUrl: "/api/fal/proxy",
18 });
19
139 }
140
141 if (url.pathname === "/api/fal/proxy") {
142 return falProxyRequest(req);
143 }

twitterAlertREADME.md4 matches

@ben5mills5Updated 3 months ago
31Refer to [Twitter's search operators](https://socialdata.gitbook.io/docs/twitter-tweets/retrieve-search-results-by-keyword#endpoint-parameters) to fine-tune your query.
32
33### 4. Test API call
34Set `isProd = false` in the code if you are testing, to ensure there are enough tweets to display. <br>
35Toggle it back to `true` when you're ready to run this cron job in production and actuall send notifications.
60
61### NOTE: Usage Limits
62This val uses the SocialData API for Twitter data:
63
64- **Proxies via Val Town's [SocialDataProxy](https://www.val.town/v/stevekrouse/socialDataProxy)**: Limited to 10 cents per day for [**Val Town Pro users**](https://www.val.town/pricing). This API is *only* for Pro users.
65- **Need more calls?** Sign up for your own [SocialData API token](https://socialdata.tools) and configure the [`socialDataSearch`](https://www.val.town/v/stevekrouse/socialDataSearch) function.

cerebras_coderREADME.md2 matches

@GoldGuyUpdated 3 months ago
6
71. Sign up for [Cerebras](https://cloud.cerebras.ai/)
82. Get a Cerebras API Key
93. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
10
11# Todos

cerebras_codermain.tsx5 matches

@GoldGuyUpdated 3 months ago
212 } catch (error) {
213 Toastify({
214 text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
215 position: "center",
216 duration: 3000,
1024 };
1025 } else {
1026 const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
1027 const completion = await client.chat.completions.create({
1028 messages: [
1149 <meta name="viewport" content="width=device-width, initial-scale=1.0">
1150 <title>CerebrasCoder</title>
1151 <link rel="preconnect" href="https://fonts.googleapis.com" />
1152 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1153 <link
1154 href="https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap"
1155 rel="stylesheet"
1156 />
1165 <meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166 <meta property="og:type" content="website">
1167 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169

twitterSearchmain.tsx1 match

@sboesenUpdated 3 months ago
14}): Promise<TweetResult[]> {
15 const res = await twitterJSON({
16 url: `https://api.twitter.com/2/tweets/search/recent?query=${await searchParams(
17 {
18 query,

cerebras_coderREADME.md2 matches

@a10minutedraftUpdated 3 months ago
6
71. Sign up for [Cerebras](https://cloud.cerebras.ai/)
82. Get a Cerebras API Key
93. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
10
11# Todos

cerebras_codermain.tsx5 matches

@a10minutedraftUpdated 3 months ago
212 } catch (error) {
213 Toastify({
214 text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
215 position: "center",
216 duration: 3000,
1024 };
1025 } else {
1026 const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
1027 const completion = await client.chat.completions.create({
1028 messages: [
1149 <meta name="viewport" content="width=device-width, initial-scale=1.0">
1150 <title>CerebrasCoder</title>
1151 <link rel="preconnect" href="https://fonts.googleapis.com" />
1152 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1153 <link
1154 href="https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap"
1155 rel="stylesheet"
1156 />
1165 <meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166 <meta property="og:type" content="website">
1167 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169

new-val-api-21 file match

@shouserUpdated 14 hours ago
This is an example of using the API to create a val.

gptApiTemplate2 file matches

@charmaineUpdated 1 day ago
papimark21
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