Skip to main content
Connect GitHub repositories to sync documentation files into your Supermemory knowledge base with OAuth authentication, webhook support, and automatic incremental syncing.

Quick Setup

1. Create GitHub Connection

  • TypeScript
  • Python
  • cURL
import Supermemory from 'supermemory';

const client = new Supermemory({
  apiKey: process.env.SUPERMEMORY_API_KEY!
});

const connection = await client.connections.create('github', {
  redirectUrl: 'https://yourapp.com/auth/github/callback',
  containerTags: ['user-123', 'github-sync'],
  documentLimit: 5000,
  metadata: {
    source: 'github',
    team: 'engineering'
  }
});

// Redirect user to GitHub OAuth
window.location.href = connection.authLink;
console.log('Auth expires in:', connection.expiresIn);
OAuth Scopes: The GitHub connector requires these scopes:
  • repo - Access to private and public repositories
  • user:email - Access to user’s email address
  • admin:repo_hook - Manage webhooks for incremental sync

2. Handle OAuth Callback

After the user grants permissions, GitHub redirects to your callback URL. The connection is automatically established, and the user can now select which repositories to sync.

3. List and Configure Repositories

Unlike other connectors, GitHub requires repository selection before syncing begins. This gives your users control over which repositories to index.
  • TypeScript
  • Python
  • cURL
// List available repositories for the user
const repositories = await client.connections.github.listRepositories(
  connectionId,
  {
    page: 1,
    perPage: 100
  }
);

// Display repositories in your UI
repositories.forEach(repo => {
  console.log(`${repo.full_name} - ${repo.description}`);
  console.log(`Private: ${repo.private}`);
  console.log(`Default branch: ${repo.default_branch}`);
  console.log(`Last updated: ${repo.updated_at}`);
});

// After user selects repositories, configure them
await client.connections.github.configure(connectionId, {
  repositories: [
    {
      id: repo.id,
      name: repo.full_name,
      defaultBranch: repo.default_branch
    }
  ]
});

console.log('Repository sync initiated');
API-First Design:Supermemory provides the API endpoints to list and configure repositories. As a Supermemory customer, you need to build the UI in your application where your end-users can:
  1. View their available GitHub repositories
  2. Select which repositories to sync
  3. Confirm the selection
This gives you complete control over the user experience and allows you to integrate repository selection seamlessly into your application’s workflow.

Supported Document Types

The GitHub connector syncs documentation and text files with the following extensions:
  • Markdown files: .md, .mdx, .markdown
  • Text files: .txt
  • reStructuredText: .rst
  • AsciiDoc: .adoc
  • Org-mode: .org
Files are indexed as github_markdown document type in Supermemory.
Only text-based documentation files are synced. Binary files, images, and code files (.js, .py, .go, etc.) are excluded by default to focus on searchable documentation content.

Incremental Sync with Webhooks

The GitHub connector automatically sets up webhooks for real-time incremental syncing. When files are pushed or deleted in configured repositories, Supermemory is notified immediately.
Batch Processing: Webhook events are processed in batches with a 10-minute delay to optimize performance and prevent excessive syncing during rapid commits. This means changes pushed to your repository will be reflected in Supermemory within approximately 10 minutes.

How It Works

  1. Webhook Setup: When you configure repositories, a webhook is automatically installed in each repository
  2. Push Events: When commits are pushed to the default branch, changed documentation files are synced
  3. Delete Events: When documentation files are deleted, they’re removed from your Supermemory knowledge base
  4. Incremental Updates: Only changed files are processed, keeping sync fast and efficient

Webhook Security

Webhooks are secured using HMAC-SHA256 signature validation with constant-time comparison. Supermemory automatically validates that webhook events come from GitHub before processing them. Each repository gets a unique webhook secret for maximum security.
  • TypeScript
  • Python
  • cURL
// Check webhook status
const connection = await client.connections.get(connectionId);

console.log('Webhooks configured:', connection.metadata.webhooks?.length);
console.log('Last sync:', new Date(connection.metadata.lastSyncedAt));
console.log('Repositories:', connection.metadata.repositories);

Connection Management

List All Connections

  • TypeScript
  • Python
  • cURL
// List all GitHub connections for specific container tags
const connections = await client.connections.list({
  containerTags: ['user-123'],
  provider: 'github'
});

connections.forEach(conn => {
  console.log(`Provider: ${conn.provider}`);
  console.log(`ID: ${conn.id}`);
  console.log(`Email: ${conn.email}`);
  console.log(`Created: ${conn.createdAt}`);
  console.log(`Document limit: ${conn.documentLimit}`);
  console.log(`Repositories: ${conn.metadata.repositories?.length || 0}`);
  console.log('---');
});

Update Repository Configuration

You can update which repositories are synced at any time:
  • TypeScript
  • Python
  • cURL
// Add or remove repositories
await client.connections.github.configure(connectionId, {
  repositories: [
    {
      id: 123456789,
      name: 'your-org/documentation',
      defaultBranch: 'main'
    },
    {
      id: 987654321,
      name: 'your-org/new-repo',
      defaultBranch: 'develop'  // Can specify different branch
    }
  ]
});

console.log('Repository configuration updated');
When you update the repository configuration:
  • New repositories are added and synced immediately
  • Removed repositories have their webhooks deleted
  • Existing documents from removed repositories remain in Supermemory unless you delete them manually

Delete Connection

  • TypeScript
  • Python
  • cURL
// Delete by connection ID
const result = await client.connections.delete(connectionId);
console.log('Deleted connection:', result.id);
Deleting a GitHub connection will:
  • Stop all future syncs from configured repositories
  • Remove all webhooks from the repositories
  • Revoke the OAuth authorization
  • Permanently delete all synced documents from your Supermemory knowledge base

Manual Sync

Trigger a manual synchronization for all configured repositories:
  • TypeScript
  • Python
  • cURL
// Trigger sync for GitHub connections
await client.connections.import('github');

// Trigger sync for specific container tags
await client.connections.import('github', {
  containerTags: ['user-123']
});

console.log('Manual sync initiated');

Advanced Configuration

Custom OAuth Application

For white-label deployments or custom branding, configure your own GitHub OAuth app using the settings API:
  • TypeScript
  • Python
  • cURL
// Update organization settings with your GitHub OAuth app
await client.settings.update({
  githubCustomKeyEnabled: true,
  githubClientId: 'Iv1.1234567890abcdef',
  githubClientSecret: 'your-github-client-secret'
});

// Get current settings
const settings = await client.settings.get();
console.log('GitHub custom key enabled:', settings.githubCustomKeyEnabled);
console.log('Client ID configured:', !!settings.githubClientId);
Setting up a GitHub OAuth App:
  1. Go to GitHub Settings → Developer settings → OAuth Apps
  2. Click “New OAuth App”
  3. Set Authorization callback URL to: https://api.supermemory.ai/v3/connections/auth/callback/github
  4. Copy the Client ID and generate a Client Secret
  5. Configure them in Supermemory using the settings API above
After configuration, all new GitHub connections will use your custom OAuth app instead of Supermemory’s default app.