Wordle of the day
by RFour · Jul 25, 2026 ·javascript
Le wordle of the day stuff, I'm bored because the canvas stuff is having an issue and it looks horrible because of the issue🥹, yes I use this code for my le api that only the ones that are in my discord server knows🤓
WordleWordGame
| 1 | export async function wordle(req) { |
| 2 | const { searchParams: sp } = new URL(req.url); |
| 3 | const date = sp.get('date'); |
| 4 | |
| 5 | if (!date) { |
| 6 | const today = new Date().toISOString().split('T')[0]; |
| 7 | try { |
| 8 | const res = await fetch(`https://www.nytimes.com/svc/wordle/v2/${today}.json`); |
| 9 | if (!res.ok) throw new Error("not out yet"); |
| 10 | const data = await res.json(); |
| 11 | return { |
| 12 | date: data.print_date || today, |
| 13 | solution: data.solution || null, |
| 14 | id: data.id || null, |
| 15 | days_since_launch: data.days_since_launch || null, |
| 16 | editor: data.editor || null |
| 17 | }; |
| 18 | } catch { |
| 19 | return { |
| 20 | error: "today's wordle not available yet, try again later", |
| 21 | usage: "/wordle?date=2026-07-25" |
| 22 | }; |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | try { |
| 27 | const res = await fetch(`https://www.nytimes.com/svc/wordle/v2/${date}.json`); |
| 28 | if (!res.ok) throw new Error("not found"); |
| 29 | const data = await res.json(); |
| 30 | return { |
| 31 | date: data.print_date || date, |
| 32 | solution: data.solution || null, |
| 33 | id: data.id || null, |
| 34 | days_since_launch: data.days_since_launch || null, |
| 35 | editor: data.editor || null |
| 36 | }; |
| 37 | } catch { |
| 38 | return { error: `no wordle for ${date}` }; |
| 39 | } |
| 40 | } |