Public
Very incomplete collection of useful GitHub API adapters
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

github-api

A collection of GitHub adapters and an HTTP API for reading and writing GitHub issues and repository files, built on Val Town.

This page is served at the root of the app (Try the app): GET / renders this README as markdown.

HTTP Endpoints

The API lives at backend/index.tsx (Hono) and is served at https://github-api-demo.val.run/.

GET /api/public/issues

Returns open GitHub issues for a repository that are tagged with the public label. No authentication required.

Query paramTypeRequiredDescription
ownerstringyesRepository owner (user or org)
repostringyesRepository name

Behavior:

  • Fetches up to 50 open issues, sorted by last updated (descending).
  • Only returns issues carrying the public label.
  • Filters out pull requests (GitHub folds PRs into the issues endpoint).
  • Returns the raw GitHub issue JSON array.

Example:

curl 'https://github-api-demo.val.run/api/public/issues?owner=oguzhanogreden&repo=notes'

Errors: 400 when owner/repo are missing, 500 when the GitHub fetch fails.

POST /api/files/create-or-update

Creates or updates a file in a GitHub repository, wrapping its content in YAML frontmatter (createdAt / updatedAt / source / llm metadata, plus any extra keys).

Authentication: requires a GitHub-Token header carrying a GitHub token with write access to the target repo. Returns 401 if the header is missing.

JSON body fields:

FieldTypeRequiredDescription
pathstringyesRepo path of the file to create/update
commitMessagestringyesMessage for the commit
source{ url: string }yesThe originating GitHub issue URL, etc.
llmobjectyesStructured LLM payload (see below)
repoOwnerstringnoDefaults to oguzhanogreden
repoNamestringnoDefaults to notes
branchstringnoDefaults to main
frontmatterobjectnoExtra keys merged into the YAML frontmatter

llm payload:

FieldTypeDescription
modelstringe.g. gpt-4.1-mini
contentstringMarkdown/text body to write to the file
tokensnumberOptional total token count
temperaturenumberOptional sampling temperature
promptHashstringOptional hash/id of the exact prompt
extrasobjectOptional model-specific fields

If the file already exists it is overwritten (new sha); otherwise it is created.

Example:

curl -X POST 'https://github-api-demo.val.run/api/files/create-or-update' \ -H 'Content-Type: application/json' \ -H 'GitHub-Token: <your-token>' \ -d '{ "path": "notes/hello.md", "commitMessage": "Add hello note", "source": { "url": "https://github.com/oguzhanogreden/notes/issues/124" }, "llm": { "model": "gpt-4.1-mini", "content": "# Hello\n\nThanks!" } }'

Importable Library

The val also exports reusable TypeScript functions (import from https://esm.town/v/cricks_unmixed4u/github-api/api/index.tsx). Highlights:

  • getIssue({ issueNumber, repoOwner?, repoName? }) — fetch a single issue.
  • getIssueComments({ issueNumber, perPage?, ... }) — async-generator over an issue's comments.
  • readFileContent({ repoOwner, repoName, path }) — read a raw file from a repo.
  • getStalestGitHubIssues(options) / getGitHubIssuesUpdatedSinceLastRun(options) — issue monitors backed by SQLite.
  • getIssueContentAsMarkdown(issueNumber, options) — render an issue + comments + extracted URLs as markdown.
  • createOrUpdateFile(params) — the same logic behind the create-or-update endpoint, callable directly.

All library functions require a GitHub token and repo identity, provided either via options or the GITHUB_TOKEN, GITHUB_REPO_OWNER, and GITHUB_REPO_NAME environment variables (see backend/create-or-update usage in main.tsx).