github-rust
A lightweight Rust library for GitHub API interactions with dual GraphQL/REST support.
Features
- Dual API Support: GraphQL primary with automatic REST fallback
- Repository Search: Find repositories by date, stars, and language
- Stargazer Tracking: Get repository stargazers with timestamps
- Rate Limiting: Built-in rate limit checking with helper methods
- Error Handling: Comprehensive error types with actionable messages
- Security: Token stored securely with automatic zeroization on drop
Installation
Add to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["rt-multi-thread", "macros"] }
Quick Start
use ;
async
API Overview
GitHubService
The main entry point for all GitHub operations.
use GitHubService;
let service = new?;
// Check if authenticated
if service.has_token else
Repository Information
// Get full repository details (uses GraphQL, falls back to REST)
let repo = service.get_repository_info.await?;
println!;
println!;
println!;
println!;
println!;
Search Repositories
// Search for recent repositories
// Parameters: days_back, limit, language (optional), min_stars
let repos = service.search_repositories.await?;
for repo in repos
Stargazers
// Get stargazers with timestamps
let stargazers = service.get_repository_stargazers.await?;
for stargazer in stargazers
Rate Limits
let limits = service.check_rate_limit.await?;
println!;
println!;
println!;
if limits.is_exceeded
User Profile
// Requires authentication
let profile = service.get_user_profile.await?;
println!;
// Get user's starred repositories
let starred = service.get_user_starred_repositories.await?;
println!;
Error Handling
The library provides comprehensive error types:
use ;
match service.get_repository_info.await
Types
SearchRepository
Returned by search_repositories():
RateLimit
Authentication
Set GITHUB_TOKEN environment variable to get access to private repositories and higher rate limits:
Or use a .env file in your project root.
License
Apache-2.0