11- [ ] Have any other email login ping me for approval or make a private val with a list of approved emails
12
13## Switchbot API
14
15This val authenticates to the switchbot API with `SWITCHBOT_TOKEN` and `SWITCHBOT_KEY`.
16
17Learn how to get your own Switchbot API keys here: [Switchbot Docs](https://github.com/OpenWonderLabs/SwitchBotAPI).
18
19Migrated from folder: Archive/switchbot
2 const readmeVals: any = await (await fetch("https://janpaul123-readmevals.web.val.run/")).json();
3
4 const API_URL = "https://api.val.town";
5
6 const sections = [
118 {
119 prompt: "Write a val that accesses environment variables",
120 code: `const res = await fetch("${API_URL}/v1/me", {
121 headers: {
122 Authorization: \`Bearer \${Deno.env.get("valtown")}\`,
130 code: `import process from "node:process";
131
132 const res = await fetch("${API_URL}/v1/me", {
133 headers: {
134 Authorization: \`Bearer \${process.env.valtown}\`,
299 You can attach files to your emails by using the \`attachments\` field.
300 Attachments need to be [Base64](https://en.wikipedia.org/wiki/Base64) encoded,
301 which is that the [btoa](https://developer.mozilla.org/en-US/docs/Web/API/btoa)
302 method is doing in this example:
303
401 \`\`\`
402
403 ### Lower-level API
404
405 We 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.
406
407 - \`async get(key: string)\`: Retrieves a blob for a given key.
408 - \`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).
409
410 ### Limitations
533 role: "assistant",
534 content:
535 "```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```",
536 },
537 {
3
4const BOT_TOKEN = Deno.env.get("TELEGRAM_TOKEN");
5const TELEGRAM_API_URL = `https://api.telegram.org/bot${BOT_TOKEN}`;
6
7useHTTP(async (req, res) => {
26async function sendMessage(chatId, text) {
27 try {
28 const url = `${TELEGRAM_API_URL}/sendMessage`;
29 const payload = {
30 chat_id: chatId,
1// This implementation uses SQLite to store blob data instead of the Val Town API.
2// It creates a 'blobs' table to store key-value pairs, where the key is the blob key
3// and the value is the blob data stored as TEXT. This approach allows for persistence
13 }
14
15 // Check that your valtown API key is sent in the 'x-authorization' header
16 // Delete this line if you don't mind other parties hitting this endpoint
17 if (req.headers.get("x-authorization") !== Deno.env.get("valtown")) {
24 try {
25 const body = await req.json();
26 const apiKey = req.headers.get("x-api-key");
27
28 if (!body) {
30 }
31
32 if (!apiKey) {
33 throw new Error("No API key provided");
34 }
35
36 const anthropic = new Anthropic({ apiKey });
37
38 if (body?.stream) {
57 }
58 } catch (e) {
59 if (e instanceof Anthropic.APIError) {
60 return Response.json(e.error, { status: e.status });
61 }
3THIS IS NO LONGER NECESSARY
4
5This Val will proxy anthropic HTTP requests from some frontend client, like langchain, so that you can utilize anthropic apis from the browser.
6
7Convert it to an HTTP val in order to use it (you may want to setup an ENV var / header to protect the endpoint with a secret key)
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## 3. Notification
3Speech-to-text and chapter summaries powered by [Substrate](https://substrate.run)
4
5🪩 To fork, [sign up for Substrate](https://substrate.run/signin) to get your own API key and $50 free credits
6
7Migrated from folder: Archive/subaudio
45
46async function getGithubReleases(repo: string): Promise<GithubRelease[]> {
47 const response = await fetch(`https://api.github.com/repos/${repo}/releases`);
48 if (!response.ok) {
49 throw new Error(`Failed to fetch releases from ${repo}`);
5 <title>TLDraw React Example</title>
6 <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
7 <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@500;700&display=swap"/>
8 <link rel="stylesheet" href="https://esm.sh/tldraw@2.3.0/tldraw.css"/>
9 <style> body { font-family: "Inter"; } </style>