Expand description
HTTP client for the GitHub REST API.
Scoped to the surface sandogasa-report needs for activity
reports: user identity lookup, token validation, paginated
user events (to find which repos a user touched in a window),
the Search API for pull requests, per-repo authored-commit
counts, and through GraphQL, a user’s contributions over a period
and their comments on issues and pull requests.
Mirrors sandogasa-gitlab in shape so downstream tools can
treat the two forges the same way structurally — host-keyed
tokens and identities, optional org/group filter, etc.
use sandogasa_github::Client;
let client = Client::new("https://api.github.com", "ghp_token")?;
let user = client.user_by_username("octocat")?.expect("user exists");
let prs = client.search_pull_requests(
&format!("type:pr author:{} created:2026-01-01..2026-03-31", user.login),
)?;
for pr in prs {
println!("{}: {}", pr.number, pr.title);
}Structs§
- Annotated
Tag - An annotated-tag object from
/repos/{owner}/{repo}/git/tags/{sha}. Only annotated tags carry tagger metadata; lightweight tags don’t have an addressable tag object. - Client
- Blocking GitHub REST client.
- Comments
- A user’s comments on issues and pull requests.
- Commit
Author - A commit’s author as git recorded it.
- Commit
Body - The git-level part of a commit.
- Commit
Counts - Commits per repository, and the queries that failed.
- Contributions
- What a user contributed over a period, as GitHub’s contribution
graph counts it: commits on a repository’s default branch (or
gh-pages), and pull requests reviewed. - Event
- One entry from
/users/{username}/events. Fields are sparse; we keep just enough to identify the event type, associated repo, and the actor. - GitObject
- The thing a Git ref points at.
object_typeis"commit"for lightweight tags and"tag"for annotated ones. - GitRef
- One side of a pull request: the branch name and the commit it points at.
- GitTag
Ref - One entry from
/repos/{owner}/{repo}/git/refs/tags. The underlyingobjectdistinguishes lightweight tags (point directly to a commit) from annotated tags (point to a Tag object that carries tagger info). - Issue
Comment - A comment of the user’s on an issue or a pull request.
- Item
Node - An issue or pull request as GraphQL gives it.
- Login
- An account named only by its login.
- Pull
Request - A pull request as returned by the Search Issues endpoint
when filtering on
type:pr. The Search API actually returns “issue” objects with PR-specific fields populated, so we shape this around the union of useful fields rather than the fuller/repos/{owner}/{repo}/pulls/{number}model. - Pull
Request Detail - The fuller pull-request object from
/repos/{owner}/{repo}/pulls/{n}: the head and base refs the search result omits, and whether it merged. - Pull
Request Ref - Auxiliary block on a search-result issue when it’s actually a pull request. The Search Issues endpoint signals “is PR” by populating this; merged state lives here too.
- Recent
Tags - Repositories’ recent annotated tags, and the queries that failed.
- Repo
Commit - A commit from
/pulls/{n}/commitsor/commits: the sha, the message and the author of the commit itself (not the GitHub account). - Repo
Node - A repository as GraphQL names it.
- Repository
- A repository as returned by event payloads and PR responses.
- Tagger
name+email+datetriple stamped on annotated-tag creation.dateis ISO 8601 (e.g.2026-05-15T17:03:15Z).- Unreadable
- Items GitHub withheld from an answer, such as those in an organization that refuses classic personal access tokens.
- User
- A GitHub user as returned by
/users/{username}. Only the fields downstream tools currently consume.
Functions§
- validate_
token - Check whether
tokenworks againstbase_urlby hitting/user. ReturnsOk(true)for valid tokens,Ok(false)for 401s, andErrfor other transport / server errors so callers can distinguish “tried and was rejected” from “couldn’t reach the server”.