valleBlogV0main.tsx1 match
38model: openai("gpt-4o", {
39baseURL: "https://std-openaiproxy.web.val.run/v1",
40apiKey: Deno.env.get("valtown"),
41} as any),
42messages: [
linearStandupmain.tsx9 matches
5758export async function exec(interval: Interval) {
59const apiKey = Deno.env.get("LINEAR_API_KEY");
60if (!apiKey) {
61console.error("LINEAR_API_KEY not found in environment variables");
62Deno.exit(1);
63}
65const { startDate, endDate } = getYesterdayDateRange();
6667const response = await fetch("https://api.linear.app/graphql", {
68method: "POST",
69headers: {
70"Content-Type": "application/json",
71Authorization: apiKey,
72},
73body: JSON.stringify({
8081if (data.errors) {
82console.error("Error fetching data from Linear API:", data.errors);
83Deno.exit(1);
84}
94}
9596const historyResponse = await fetch("https://api.linear.app/graphql", {
97method: "POST",
98headers: {
99"Content-Type": "application/json",
100Authorization: apiKey,
101},
102body: JSON.stringify({
190}
191192const slackResponse = await fetch("https://slack.com/api/chat.postMessage", {
193method: "POST",
194headers: {
45[LastLogin](https://lastlogin.io/) is a decentralized hosted auth provider
6that enables login to any app through email, Google, Github, etc without API keys.
78This val exports middleware that can be added to any HTTP val.
23export let currency = async (desired, base = "usd", amount = 1) => {
4let { rates } = await fetchJSON(`https://open.er-api.com/v6/latest/${base}`);
5if (rates && rates[desired.toUpperCase()]) return amount * (rates[desired.toUpperCase()]);
6else {
7let { rates } = await fetchJSON(
8`https://api.coingecko.com/api/v3/exchange_rates?&x_cg_demo_api_key=${Deno.env.get("COINGECKO_API_KEY")}`,
9);
10return amount * rates[desired.toLowerCase()]?.value / rates[base.toLowerCase()]?.value;
211Make an HTTP val (other vals are currently not supported to run, even though we have examples for them).
212Start your response with a comment explaining how your approach will work, what libraries or
213API calls you will use, and any tradeoffs you're making. Then write the code in a consise way,
214the simplest way to achieve the goal, though you can add some inline comments to explain your
215reasoning (not for every line, but for major groups of lines). Don't use any environment variables
216unless strictly necessary, for example use APIs that don't require a key, prefer internal function
217imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
218functions where possible. Unless specified, don't add error handling,
219make sure that errors bubble up to the caller.
220Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's
221not practical for the user's request (e.g. if they ask for a particular animated gif).
222If the user asks for something that requires persistence, use the Val Town Blob storage API, unless
223explicitly specified otherwise. Use the current val name for the storage key, which you can get
224using the "pomdtr/extractValInfo" val, which you can call like this:
273Make an HTTP val (other vals are currently not supported to run, even though we have examples for them).
274Add comments at the top of the file explaining how your approach works, what libraries or
275API calls you will use, and any tradeoffs you're making. Then write the code in a consise way,
276the simplest way to achieve the goal, though you can add some inline comments to explain your
277reasoning (not for every line, but for major groups of lines). Don't use any environment variables
278unless strictly necessary, for example use APIs that don't require a key, prefer internal function
279imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
280functions where possible. Unless specified, don't add error handling,
281make sure that errors bubble up to the caller.
282Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's
283not practical for the user's request (e.g. if they ask for a particular animated gif).
284If the user asks for something that requires persistence, use the Val Town Blob storage API, unless
285explicitly specified otherwise. Use the current val name for the storage key, which you can get
286using the "pomdtr/extractValInfo" val, which you can call like this:
389\`\`\`
390
391### Lower-level API
392
393We do provide access to the lower-level getter and setters, which are useful if you are storing non-JSON or binary data, need to stream in your response or request data, or do anything else lower-level.
394
395- \`async get(key: string)\`: Retrieves a blob for a given key.
396- \`async set(key: string, value: string | BodyInit)\`: Sets the blob value for a given key. See [BodyInit](https://deno.land/api@v1.38.1?s=BodyInit).
397
398### Limitations
12041205const tempValName = `valle_tmp_${Math.random() * 10}`.replaceAll(".", "");
1206// Errors in running the val bubble up through this API, so ignore them.
1207await vt.vals.create({ name: tempValName, code: newCode, type: "http" as any, privacy: "unlisted" }).catch(
1208(error) => {
1import { fetch } from "https://esm.town/v/std/fetch";
2import { resyPublicAPIKey } from "https://esm.town/v/vtdocs/resyPublicAPIKey";
34export const resyAuth = async (email: string, password: string): Promise<{
9}[];
10}> => {
11const authRes = await fetch("https://api.resy.com/3/auth/password", {
12"headers": {
13"authorization":
14`ResyAPI api_key="${resyPublicAPIKey}"`,
15"content-type": "application/x-www-form-urlencoded",
16},
twitterSearchmain.tsx1 match
14}): Promise<TweetResult[]> {
15const res = await twitterJSON({
16url: `https://api.twitter.com/2/tweets/search/recent?query=${await searchParams(
17{
18query,
distinctGoldLarkmain.tsx3 matches
10formData.append("file", blob, "data.json");
1112// URL of your API
13const apiUrl = "https://filehaus.top/api/upload/data.json"; // Replace with your API URL
1415// Send the file using fetch
16try {
17const response = await fetch(apiUrl, {
18method: "POST",
19body: formData,
valleGetValsContextWindowmain.tsx7 matches
13const readmeVals: any = await (await fetch("https://janpaul123-readmevals.web.val.run/")).json();
1415const API_URL = "https://api.val.town";
1617const sections = [
129{
130prompt: "Write a val that accesses environment variables",
131code: `const res = await fetch("${API_URL}/v1/me", {
132headers: {
133Authorization: \`Bearer \${Deno.env.get("valtown")}\`,
141code: `import process from "node:process";
142
143const res = await fetch("${API_URL}/v1/me", {
144headers: {
145Authorization: \`Bearer \${process.env.valtown}\`,
310You can attach files to your emails by using the \`attachments\` field.
311Attachments need to be [Base64](https://en.wikipedia.org/wiki/Base64) encoded,
312which is that the [btoa](https://developer.mozilla.org/en-US/docs/Web/API/btoa)
313method is doing in this example:
314
412\`\`\`
413
414### Lower-level API
415
416We do provide access to the lower-level getter and setters, which are useful if you are storing non-JSON or binary data, need to stream in your response or request data, or do anything else lower-level.
417
418- \`async get(key: string)\`: Retrieves a blob for a given key.
419- \`async set(key: string, value: string | BodyInit)\`: Sets the blob value for a given key. See [BodyInit](https://deno.land/api@v1.38.1?s=BodyInit).
420
421### Limitations
458role: "assistant",
459content:
460"```ts\nexport default async function(req: Request): Promise<Response> {\n const apiKey = Deno.env.get(\"METEO_KEY\");\n const apiUrl = `https://api.open-meteo.com/v1/forecast?latitude=40.6782&longitude=-73.9442&hourly=temperature_2m¤t_weather=true&apikey=${apiKey}`;\n\n const response = await fetch(apiUrl);\n const weatherData = await response.json();\n\n return new Response(JSON.stringify(weatherData), { headers: { \"Content-Type\": \"application/json\" } });\n}\n```",
461},
462{
valleBlogV0README.md1 match
1* Fork this val to your own profile.
2* Create a [Val Town API token](https://www.val.town/settings/api), open the browser preview of this val, and use the API token as the password to log in.
3