Fetch a GitHub repository's details: stars, forks, language, topics, license and activity.
{"full_name":"string 'owner/repo' (e.g. 'facebook/react'). Or pass owner and repo separately.","owner":"string optional (if not using full_name)","repo":"string optional (if not using full_name)"}{"full_name":"string","description":"string|null","stars":"int","forks":"int","watchers":"int","openIssues":"int","language":"string|null","topics":"array","license":"string|null","homepage":"string|null","defaultBranch":"string","createdAt":"string","pushedAt":"string","url":"url"}Fetch one GitHub repository's metadata via the public REST API (api.github.com). Pass full_name as 'owner/repo' (e.g. 'facebook/react'), or owner and repo separately. Returns {full_name, description, stars, forks, watchers, openIssues, language, topics, license, homepage, defaultBranch, createdAt, pushedAt, url}. Read-only, no auth needed for public repos.
params. It does the in-page work and returns the JSON in returns.( async (root, params) => { let full = String((params && params.full_name) || '').trim().replace(/^https?://github.com//, '').replace(//$/, ''); if (!full && params && params.owner && params.repo) full = params.owner + '/' + params.repo; full = full.split('/').slice(0, 2).join('/'); if (!/^[^/]+/[^/]+$/.test(full)) throw new Error('missing full_name (owner/repo)'); const H = { 'accept': 'application/vnd.github+json', 'x-github-api-version': '2022-11-28' }; const r = await fetch('https://api.github.com/repos/' + full, { headers: H }); if (r.status === 404) return { error: 'repo not found: ' + full }; if (r.status === 403) return { error: 'rate limited. Try again in a minute.' }; const d = await r.json(); return { full_name: d.full_name, description: d.description || null, stars: d.stargazers_count, forks: d.forks_count, watchers: d.subscribers_count != null ? d.subscribers_count : d.watchers_count, openIssues: d.open_issues_count, language: d.language || null, topics: d.topics || [], license: (d.license && d.license.spdx_id) || null, homepage: d.homepage || null, defaultBranch: d.default_branch, createdAt: d.created_at, pushedAt: d.pushed_at, url: d.html_url }; } )
{
"expr": "typeof result === 'object' && (result.full_name || result.error)",
"type": "value"
}