github-pinned-repo-sdk
v1.0.3
Published
SDK to simply fetch a GitHub user's pinned repositories and general data.
Maintainers
Readme
GitHub Pinned Repository SDK
Fetch GitHub user profile + pinned repositories with full TypeScript support.
Based on better-github-api
🚀 Installation
npm i github-pinned-repo-sdk
// OR using yarn
yarn add github-pinned-repo-sdk📖 Usage
import { getPinnedRepos } from 'github-pinned-repo-sdk';
const data = await getPinnedRepos('sindresorhus');TypeScript
Define types:
import { getPinnedRepos, type PinnedRepo, type GithubUser } from 'github-pinned-repo-sdk';
type ApiResponse = {
user: GithubUser;
pinned_repos: PinnedRepo[];
pinned_repos_total_stars: number;
};
const data: ApiResponse = await getPinnedRepos('sindresorhus');🧪 Testing
Run tests using vitest:
npm testIn node console
node -e "import('./dist/index.js').then(m => m.getPinnedRepos('luisoos').then(console.log))"🌐 Astro Example
---
import { getPinnedRepos } from 'github-pinned-repo-sdk';
const { user, pinned_repos } = await getPinnedRepos('torvalds');
***
<h1>{user.login}</h1>
<ul>
{pinned_repos.map(repo => (
<li>
<a href={repo.link}>{repo.repo}</a>
<span>⭐ {repo.stars.toLocaleString()}</span>
</li>
))}
</ul>📦 Features
- ✅ Extremely Lightweight (pure
fetch+jsdom) - ✅ Robust Parsing (uses
jsdomfor reliable scraping) - ✅ Full TypeScript (IntelliSense ready)
- ✅ Node.js & SSR optimized (perfect for Astro/Next.js)
- ✅ GitHub API + HTML scraping hybrid
- ✅ Rate-limit safe (User-Agent headers)
🙌 Credits
Inspired by better-github-api
📄 License
MIT © luisoos
