0

Get Repository

by
Published today

Get a repository's details: default branch, visibility, star and fork counts, topics and permissions.

Script github Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 1 hour ago
1
//native
2

3
/**
4
 * Get Repository
5
 * Get a repository's details: default branch, visibility, star and fork counts, topics and permissions.
6
 */
7
export async function main(auth: RT.Github, owner: string, repo: string) {
8
  const response = await fetch(
9
    `https://api.github.com/repos/${owner}/${repo}`,
10
    {
11
      headers: {
12
        Authorization: `Bearer ${auth.token}`,
13
        Accept: "application/vnd.github+json",
14
        "X-GitHub-Api-Version": "2022-11-28",
15
      },
16
    }
17
  )
18

19
  if (!response.ok) {
20
    throw new Error(`${response.status} ${await response.text()}`)
21
  }
22

23
  return await response.json()
24
}
25