gh-tree

A minimalist API for fetching recursive file trees from public GitHub repositories.

Usage

GET https://gh.kaf.sh/api/:user/:repo

Example

Fetch the file tree for facebook/react:

curl https://gh.kaf.sh/api/facebook/react
{
  "repository": {
    "owner": "facebook",
    "name": "react",
    "description": "The library for web and native user interfaces.",
    "stars": 232000,
    "forks": 47000,
    "watchers": 232000,
    "language": "JavaScript",
    "default_branch": "main",
    "html_url": "https://github.com/facebook/react",
    "updated_at": "2026-01-22T14:30:00Z"
  },
  "tree": [
    { "path": "README.md", "type": "file", "size": 1234 },
    { "path": "package.json", "type": "file", "size": 2500 },
    { "path": "src", "type": "directory" }
  ],
  "meta": {
    "cached": true,
    "generated_at": "2026-01-23T08:00:00Z",
    "truncated": false
  }
}

Features

  • Recursive file tree fetching
  • Repository metadata included
  • Global CDN caching (Cloudflare)
  • CORS enabled for all origins