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.
neverstew avatar
neverstew
githubRestClient
Script
githubRestClient Does what it says! Defaults to using GITHUB_TOKEN env var if none is passed to the function.
0
tzq avatar
tzq
monitoringGitHubRepository
Script
An interactive, runnable TypeScript val by tzq
0
cpgo avatar
cpgo
githubUser
Script
An interactive, runnable TypeScript val by cpgo
0
vtdocs avatar
vtdocs
emailGithubReactions
Script
An interactive, runnable TypeScript val by vtdocs
1
tgrecojs avatar
tgrecojs
gistFetcher
Script
An interactive, runnable TypeScript val by tgrecojs
0
ramkarthik avatar
ramkarthik
reposStaleGithubPRs
Script
An interactive, runnable TypeScript val by ramkarthik
1
cas avatar
cas
githubFollowing
Script
An interactive, runnable TypeScript val by cas
0
stevekrouse avatar
stevekrouse
githubEvents
Script
An interactive, runnable TypeScript val by stevekrouse
0
joshmock avatar
joshmock
githubStarsRSS
Script
An interactive, runnable TypeScript val by joshmock
0
cathy avatar
cathy
githubEvents
Script
An interactive, runnable TypeScript val by cathy
0
vtdocs avatar
vtdocs
getGithubUserViaOctokit
Script
An interactive, runnable TypeScript val by vtdocs
0
eagle251 avatar
eagle251
githubFollowers
Script
An interactive, runnable TypeScript val by eagle251
0
elsif_maj avatar
elsif_maj
topHNThreadByHour
Email
// set at Thu Nov 30 2023 14:22:53 GMT+0000 (Coordinated Universal Time)
0
andreterron avatar
andreterron
codeOnValTown
Script
Code on Val Town Adds a "Code on Val Town" ribbon to your page. This lets your website visitors navigate to the code behind it. This uses github-fork-ribbon-css under the hood. Usage Here are 2 different ways to add the "Code on Val Town" ribbon: 1. Wrap your fetch handler (recommended) import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50"; import { html } from "https://esm.town/v/stevekrouse/html?v=5"; export default modifyFetchHandler(async (req: Request): Promise<Response> => { return html(`<h2>Hello world!</h2>`); }); Example: @andreterron/openable_handler 2. Wrap your HTML string import { modifyHtmlString } from "https://esm.town/v/andreterron/codeOnValTown?v=50"; import { html } from "https://esm.town/v/stevekrouse/html?v=5"; export default async (req: Request): Promise<Response> => { return html(modifyHtmlString(`<h2>Hello world!</h2>`)); }; Example: @andreterron/openable_html Other ways We made sure this was very modular, so you can also add the ribbon using these methods: Get the element string directly: @andreterron/codeOnVT_ribbonElement Modify an HTTP Response: @andreterron/codeOnVT_modifyResponse Use .pipeThrough to append to a stream: @andreterron/InjectCodeOnValTownStream Customization Linking to the val These functions infer the val using the call stack or the request URL. If the inference isn't working, or if you want to ensure it links to a specific val, pass the val argument: modifyFetchHandler(handler, {val: { handle: "andre", name: "foo" }}) modifyHtmlString("<html>...", {val: { handle: "andre", name: "foo" }}) Styling You can set the style parameter to a css string to customize the ribbon. Check out github-fork-ribbon-css to learn more about how to style the element. modifyFetchHandler(handler, {style: ".github-fork-ribbon:before { background-color: #333; }"}) modifyHtmlString("<html>...", {style: ".github-fork-ribbon:before { background-color: #333; }"}) Here's how you can hide the ribbon on small screens: modifyFetchHandler(handler, {style: `@media (max-width: 768px) { .github-fork-ribbon { display: none !important; } }`}) To-dos [ ] Let users customize the ribbon. Some ideas are the text, color or placement.
5
feb avatar
feb
githubUser
Script
An interactive, runnable TypeScript val by feb
0
maxmix avatar
maxmix
githubFollowers
Script
An interactive, runnable TypeScript val by maxmix
0