Fync
Providers

GitHub

Access repositories, users, issues, pull requests, and more

GitHub API

Quick Setup

import { GitHub } from '@remcostoeten/fync';
const github = GitHub({ token: process.env.GITHUB_TOKEN! });

👥 Users & Organizations

User Information

// Get user profile
const user = await github.getUser('octocat');

// User's repositories and activity
const repos = await github.users.getUserRepos({ username: 'octocat', per_page: 50 });
const events = await github.getUserActivity('octocat', { per_page: 30 });

// User statistics and analytics
const stats = await github.getUserStats('octocat');
const starredCount = await github.getUserStarredCount('octocat');

Organization Data

// Organization info
const org = await github.orgs.getOrg({ org: 'github' });

// Organization repositories and members
const orgRepos = await github.orgs.getOrgRepos({ org: 'github' });
const orgMembers = await github.orgs.getOrgMembers({ org: 'github' });

Repository Operations

Repository Information

// Get repository details
const repo = await github.getRepository('facebook', 'react');

// Repository contents and files
const readme = await github.repos.getRepoReadme({ owner: 'facebook', repo: 'react' });
const contents = await github.repos.getRepoContents({
  owner: 'facebook',
  repo: 'react',
  path: 'package.json'
});

// Repository analytics
const stars = await github.getRepositoryStars('facebook', 'react');
const contributors = await github.repos.getRepoContributors({ owner: 'facebook', repo: 'react' });

Commits & Branches

// Get commits and branches
const commits = await github.repos.getRepoCommits({ owner: 'facebook', repo: 'react' });
const branches = await github.repos.getRepoBranches({ owner: 'facebook', repo: 'react' });

// User commit activity
const userCommits = await github.getUserCommits('octocat');
const latestCommit = await github.getUserLatestCommit('octocat');
const commitsInTimeframe = await github.getUserCommitsInTimeframe('octocat', '7D');

Issues & Pull Requests

// Issues
const issues = await github.repos.getRepoIssues({ owner: 'facebook', repo: 'react' });
const issue = await github.repos.getRepoIssue({
  owner: 'facebook',
  repo: 'react',
  issue_number: 12345
});

// Create and update issues
await github.repos.createRepoIssue(
  { title: 'Bug found', body: 'Description of the issue' },
  { owner: 'facebook', repo: 'react' }
);

// Pull requests
const pullRequests = await github.repos.getRepoPulls({ owner: 'facebook', repo: 'react' });
const pullRequest = await github.repos.getRepoPull({
  owner: 'facebook',
  repo: 'react',
  pull_number: 678
});

// Create pull request
await github.repos.createRepoPull({
  title: 'Fix: Important bug',
  head: 'bugfix-branch',
  base: 'main',
  body: 'Fixes the critical bug in...'
}, { owner: 'facebook', repo: 'react' });

Search & Discovery

// Basic search
const results = await github.searchRepositories('language:typescript');

// Advanced search with filters
const advancedResults = await github.searchRepositories(
  'language:typescript stars:>1000 pushed:>2024-01-01',
  { per_page: 20, sort: 'stars' }
);

// Search by URL
const repoFromUrl = await github.getRepositoryFromUrl('https://github.com/facebook/react');

Other Search Types

// Search code
const codeResults = await github.search.code({ q: 'useState react' });

// Search users
const userResults = await github.search.users({ q: 'location:san-francisco' });

// Search issues
const issueResults = await github.search.issues({ q: 'repo:facebook/react bug' });

⭐ Activity & Interactions

Starring & Watching

// Star a repository
await github.activity.starRepo({}, { owner: 'facebook', repo: 'react' });
await github.activity.unstarRepo({}, { owner: 'facebook', repo: 'react' });

// Watch a repository
await github.activity.watchRepo({}, { owner: 'facebook', repo: 'react' });
await github.activity.unwatchRepo({}, { owner: 'facebook', repo: 'react' });

// Get starred/watched repos
const starred = await github.activity.getStarred();
const watching = await github.activity.getWatching();

Following Users

// Follow/unfollow users
await github.me.followUser({}, { username: 'octocat' });
await github.me.unfollowUser({}, { username: 'octocat' });

// Get followers/following
const followers = await github.users.getUserFollowers({ username: 'octocat' });
const following = await github.users.getUserFollowing({ username: 'octocat' });

🔐 Authenticated User Actions

Profile Management

// Get current user info
const currentUser = await github.me.getAuthenticatedUser();

// Update profile
await github.me.updateAuthenticatedUser({
  name: 'New Name',
  bio: 'Software Developer',
  location: 'San Francisco'
});

// Get user's data
const myRepos = await github.me.getMyRepos();
const myOrgs = await github.me.getMyOrgs();
const myGists = await github.me.getMyGists();

SSH Keys & Emails

// Manage SSH keys
const sshKeys = await github.me.getMySSHKeys();
await github.me.addSSHKey({
  title: 'My Laptop',
  key: 'ssh-rsa AAAAB3NzaC1yc2E...'
});

// Get emails
const emails = await github.me.getMyEmails();

Repository Analytics

Statistics

// Get repository statistics
const contributorStats = await github.stats.getContributorStats({ owner: 'facebook', repo: 'react' });
const commitActivity = await github.stats.getCommitActivity({ owner: 'facebook', repo: 'react' });
const codeFrequency = await github.stats.getCodeFrequency({ owner: 'facebook', repo: 'react' });
const participation = await github.stats.getParticipation({ owner: 'facebook', repo: 'react' });

📋 Quick Reference

CategoryKey Methods
UsersgetUser(), getUserStats(), getUserCommits()
RepositoriesgetRepository(), getRepositoryStars(), getRepositoryFromUrl()
SearchsearchRepositories(), search.code(), search.users()
Issues/PRsrepos.getRepoIssues(), repos.createRepoIssue(), repos.getRepoPulls()
Activityactivity.starRepo(), activity.getStarred(), me.followUser()
Auth Userme.getAuthenticatedUser(), me.getMyRepos(), me.getMyGists()
Statisticsstats.getContributorStats(), stats.getCommitActivity()

Low-Level Resource Access

For more control, access resources directly:

// Direct resource access
const repo = await github.repos.getRepo({ owner: 'facebook', repo: 'react' });
const commits = await github.repos.getRepoCommits({
  owner: 'facebook',
  repo: 'react',
  per_page: 50
});

// Search with full control
const searchResults = await github.search.searchRepos({
  q: 'language:typescript stars:>1000',
  sort: 'stars',
  order: 'desc',
  per_page: 20
});