1Migrated from folder: val_backup/ValTownAPI
25
26export let spotifyRequestToken = ({ client_id, client_secret, code, redirect_uri }) =>
27 fetchJSON("https://accounts.spotify.com/api/token", {
28 method: "POST",
29 body: querystring({
39
40export let spotifyRefreshToken = async ({ refresh_token, client_id, client_secret }) =>
41 fetch("https://accounts.spotify.com/api/token", {
42 method: "POST",
43 body: new URLSearchParams({
193
194 try {
195 const currentlyPlaying = await fetch("https://api.spotify.com/v1/me/player/currently-playing", {
196 method: "GET",
197 headers: {
209
210 if (!mostRecentTrack) {
211 const recentTracks = await fetch("https://api.spotify.com/v1/me/player/recently-played", {
212 method: "GET",
213 headers: {
234
235 try {
236 const playStateResponse = await fetch("https://api.spotify.com/v1/me/player?market=US", {
237 method: "GET",
238 headers: {
25
26export let spotifyRequestToken = ({ client_id, client_secret, code, redirect_uri }) =>
27 fetchJSON("https://accounts.spotify.com/api/token", {
28 method: "POST",
29 body: querystring({
39
40export let spotifyRefreshToken = async ({ refresh_token, client_id, client_secret }) =>
41 fetch("https://accounts.spotify.com/api/token", {
42 method: "POST",
43 body: new URLSearchParams({
193
194 try {
195 const currentlyPlaying = await fetch("https://api.spotify.com/v1/me/player/currently-playing", {
196 method: "GET",
197 headers: {
209
210 if (!mostRecentTrack) {
211 const recentTracks = await fetch("https://api.spotify.com/v1/me/player/recently-played", {
212 method: "GET",
213 headers: {
234
235 try {
236 const playStateResponse = await fetch("https://api.spotify.com/v1/me/player?market=US", {
237 method: "GET",
238 headers: {
2Use the Vercel AI SDK in your Vals.
3
4**Note**: you must add your OpenAI key to your Val Town [Env variables](https://www.val.town/settings/environment-variables) under `OPENAI_API_KEY`. If you would like to specify a different name for your API Key, you can [create a custom OpenAI provider](https://sdk.vercel.ai/providers/ai-sdk-providers/openai#provider-instance) with the `createOpenAI` function.
5
6Prefer another AI provider? Use [any supported provider](https://sdk.vercel.ai/providers/ai-sdk-providers) by changing just two lines of code!
1# [Translator](https://yieldray-translate.web.val.run)
2using a [public deepl api](https://deepl.deno.dev)
3
4Migrated from folder: ExamplesAndForks/translate
3const tokenBucket = new TokenBucket(5, 1/12);
4
5export async function convertToResumeJSON(resume, apiKey) {
6 if (!tokenBucket.consume()) {
7 throw new Error("Rate limit reached. Please try again later.");
8 }
9
10 const endpoint = 'https://api.openai.com/v1/chat/completions';
11 const model = 'gpt-4';
12
138 method: 'POST',
139 headers: {
140 'Authorization': `Bearer ${apiKey}`,
141 'Content-Type': 'application/json',
142 },
7export async function loadPageContent(url: string, options: LoadPageOptions = { textContent: false }) {
8 const browser = await puppeteer.connect({
9 browserWSEndpoint: `wss://connect.browserbase.com?apiKey=${Deno.env.get("BROWSERBASE_API_KEY")}`,
10 });
11
37export async function screenshotPage(url: string, options: ScreenshotOptions = { fullPage: true }) {
38 const browser = await puppeteer.connect({
39 browserWSEndpoint: `wss://connect.browserbase.com?apiKey=${Deno.env.get("BROWSERBASE_API_KEY")}`,
40 });
41
3import { renderToString } from "npm:react-dom/server";
4
5// This uses by personal API key, you'll need to provide your own if
6// you fork this. We'll be adding support to the std/openai lib soon!
7const openai = new OpenAI();
10assistant > Here are a few fun Val ideas you could build on Val Town:
11
121. **Random Joke Generator:** Fetch a random joke from an API and display it.
132. **Daily Weather Update:** Pull weather data for your location using an API and create a daily summary.
143. **Mini Todo List:** Create a simple to-do list app with add, edit, and delete functionalities.
154. **Chuck Norris Facts:** Display a random Chuck Norris fact sourced from an API.
165. **Motivational Quote of the Day:** Fetch and display a random motivational quote each day.
17
72 "https://openvsxorg.blob.core.windows.net/resources/{publisher}/{name}/{version}/{path}",
73 },
74 "extensionEnabledApiProposals": {
75 "vscode.vscode-web-playground": [
76 "fileSearchProvider",