Back to APIs list

Github API examples & templates

Use these vals as a playground to view and fork Github API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
nico avatar
handleSanguineGithubWebhook
@nico
Script
Forked from stevekrouse/handleDiscordNewUser
horatiothomas avatar
dot_com
@horatiothomas
HTTP (deprecated)
Forked from stevekrouse/dot_com
stevekrouse avatar
dot_com
@stevekrouse
HTTP
Forked from stevekrouse/stevekrouse_minimal
vpontis avatar
dot_com
@vpontis
HTTP
Forked from stevekrouse/dot_com
tmcw avatar
blocks
@tmcw
Express
Unfancy blocks In the old days, there was a website called bl.ocks.org which re-hosted content on GitHub Gists and displayed visualizations made in those gists. It wasn't shiny but it was well-crafted and for the little community that used it, it was very nice. This is a much worse, but very small, version of the same kind of program. This also shows you stuff from blocks. It displays readmes, with Titus's lovely micromark . It uses Ian's collected search index of bl.ocks.org to show you examples and thumbnails. It uses Alpine to pull together a little interface. And, of course, Val Town to make it all work.
kyle avatar
githubKeys
@kyle
Script
An interactive, runnable TypeScript val by kyle
endingwithali avatar
githubEvents
@endingwithali
Script
An interactive, runnable TypeScript val by endingwithali
iamseeley avatar
valcontributionchart
@iamseeley
HTTP
Forked from ejfox/valcontributionchart
pomdtr avatar
code_search_is_easy
@pomdtr
HTTP (deprecated)
Code Search is Easy Earlier this week, Tom MacWright posted Code Search is Hard . He describes the research he his doing to improve the code search experience of Val Town . It was a great read, and you might have seen it trending on Hacker News . As Val Town's most active user (behind Steve Krouse, one of the founders of Val Town), I for sure agree with Tom that the search feature needs improvements. But while reading his post, I immediately thought of a different approach to the problem. And a few hours later, Val Town Search was born. Do things that don't scale How does this new shiny search engine work? Well, it's quite simple. I wrote a Deno script that fetches all vals from the Val Town API. #!/usr/bin/env -S deno run -A import * as path from "https://deno.land/std/path/mod.ts"; const dir = path.join(import.meta.dirname!, "..", "vals"); const blocklist = Deno.readTextFileSync( path.join(import.meta.dirname!, "blocklist.txt") ) .split("\n") .map((line) => line.trim()) .filter((line) => line.length > 0); let url = `https://api.val.town/v1/search/vals?limit=100&query=+`; const vals = []; while (true) { console.log("fetching", url); const resp = await fetch(url); if (!resp.ok) { console.error(resp.statusText); Deno.exit(1); } const { data, links } = await resp.json(); vals.push(...data); if (!links.next) { break; } url = links.next; } Deno.removeSync(dir, { recursive: true }); Deno.mkdirSync(dir, { recursive: true }); for (const val of vals) { const slug = `${val.author.username}/${val.name}`; if (blocklist.includes(slug)) { console.log("skipping", slug); continue; } const userDir = path.join(dir, val.author.username); Deno.mkdirSync(userDir, { recursive: true }); Deno.writeTextFileSync(path.join(userDir, `${val.name}.tsx`), val.code); } I pushed the data to a Github Repository (now private) I added a Github Action that runs the script every hour to refresh the data. #!/usr/bin/env -S deno run -A import * as path from "https://deno.land/std/path/mod.ts"; const dir = path.join(import.meta.dirname!, "..", "vals"); const blocklist = Deno.readTextFileSync( path.join(import.meta.dirname!, "blocklist.txt") ) .split("\n") .map((line) => line.trim()) .filter((line) => line.length > 0); let url = `https://api.val.town/v1/search/vals?limit=100&query=+`; const vals = []; while (true) { console.log("fetching", url); const resp = await fetch(url); if (!resp.ok) { console.error(resp.statusText); Deno.exit(1); } const { data, links } = await resp.json(); vals.push(...data); if (!links.next) { break; } url = links.next; } Deno.removeSync(dir, { recursive: true }); Deno.mkdirSync(dir, { recursive: true }); for (const val of vals) { const slug = `${val.author.username}/${val.name}`; if (blocklist.includes(slug)) { console.log("skipping", slug); continue; } const userDir = path.join(dir, val.author.username); Deno.mkdirSync(userDir, { recursive: true }); Deno.writeTextFileSync(path.join(userDir, `${val.name}.tsx`), val.code); } I created a simple frontend on top of the Github Search API that allows you to search the data. It's hosted on Val Town (obviously). That was it. I didn't have to build a complex search engine, I just used the tools that were available to me. Is this a scalable solution for Val Town? Probably not. Am I abusing the Github API? Maybe. Does it work better than the current search feature of Val Town? Absolutely! I hope that the val.town engineers will come up with a search feature that will put my little project to shame. But for now, you won't find a better way to search for vals than Val Town Search . PS: This post was written / is served from Val Town
rlesser avatar
gfm
@rlesser
Script
Forked from pomdtr/gfm
byjp avatar
addShortlink
@byjp
Express
Shortlinks for the decentralised web This is a script to allow API-based updating of the shortlinks/redirects in an IPFS-based shortlink repo (using val.town). I've written up how all this works on my blog at https://byjp.me/posts/link-shortener
ski avatar
github_avatar
@ski
Script
An interactive, runnable TypeScript val by ski
adisbanda avatar
githubWebhookApproveSmallPRs
@adisbanda
HTTP (deprecated)
An interactive, runnable TypeScript val by adisbanda
maxm avatar
verifiedGithubStarWebhookExample
@maxm
HTTP (deprecated)
An interactive, runnable TypeScript val by maxm
vtdocs avatar
getSteve
@vtdocs
Script
An interactive, runnable TypeScript val by vtdocs
envl avatar
qq_svg
@envl
HTTP (deprecated)
把 GitHub stars 数量转换为 QQ 等级 SVG 图片 Convert GitHub stars into SVG of QQ level QQ is a popular icq alternative from China 用法 Usage https://envl-qq_svg.web.val.run/:user/:repo?font_size=24&px=4&py=3 repo 选填 Optional px 选填 Optional py 选填 Optional font_size 选填 Optional 举例 Example: https://envl-qq_svg.web.val.run/envl https://envl-qq_svg.web.val.run/freecodecamp/freecodecamp