SDKs

Official client libraries that wrap the GitForge REST API with typed interfaces, automatic pagination, and built-in error handling.

TypeScript

@gitforge/sdk

npm / Bun / Deno

Python

gitforge-sdk

PyPI

Go

github.com/gitforge/gitforge-go

Go modules

TypeScript SDK

Installation

npm
npm install @gitforge/sdk
Bun
bun add @gitforge/sdk

Configuration

Initialize
import { GitForge } from "@gitforge/sdk";

const gf = new GitForge({
  token: "gf_YOUR_PAT",
  // Optional: override base URL for self-hosted instances
  baseUrl: "https://api.gitforge.dev",
});

Examples

List repositories
const repos = await gf.repos.list();
for (const repo of repos) {
  console.log(`${repo.name} — ${repo.description}`);
}
Create a repository
const repo = await gf.repos.create({
  name: "my-project",
  description: "Created via SDK",
  visibility: "private",
});
console.log(repo.id);
List branches
const branches = await gf.repos.branches.list(repo.id);
for (const branch of branches) {
  console.log(`${branch.name} — ${branch.sha}`);
}
Create a pull request
const pr = await gf.repos.prs.create(repo.id, {
  title: "Add feature",
  description: "Implements new feature",
  sourceBranch: "feature/new-thing",
  targetBranch: "main",
});
console.log(`PR #${pr.number}: ${pr.title}`);

Python SDK

Installation

pip
pip install gitforge-sdk
Poetry
poetry add gitforge-sdk

Configuration

Initialize
from gitforge import GitForge

gf = GitForge(
    token="gf_YOUR_PAT",
    # Optional: override base URL for self-hosted instances
    base_url="https://api.gitforge.dev",
)

Examples

List repositories
repos = gf.repos.list()
for repo in repos:
    print(f"{repo.name} — {repo.description}")
Create a repository
repo = gf.repos.create(
    name="my-project",
    description="Created via SDK",
    visibility="private",
)
print(repo.id)
Work with pull requests
# List open PRs
prs = gf.repos.prs.list(repo.id, state="open")
for pr in prs:
    print(f"PR #{pr.number}: {pr.title}")

# Create a PR
pr = gf.repos.prs.create(
    repo.id,
    title="Add feature",
    source_branch="feature/new-thing",
    target_branch="main",
)

# Merge a PR
gf.repos.prs.merge(repo.id, pr.number, strategy="squash")

Go SDK

Installation

go get
go get github.com/gitforge/gitforge-go

Configuration

Initialize
package main

import (
    "context"
    gitforge "github.com/gitforge/gitforge-go"
)

func main() {
    client := gitforge.NewClient("gf_YOUR_PAT")
    // Optional: override base URL
    // client.BaseURL = "https://api.gitforge.dev"
    ctx := context.Background()
}

Examples

List repositories
repos, err := client.Repos.List(ctx, nil)
if err != nil {
    log.Fatal(err)
}
for _, repo := range repos {
    fmt.Printf("%s — %s\n", repo.Name, repo.Description)
}
Create a repository
repo, err := client.Repos.Create(ctx, &gitforge.CreateRepoRequest{
    Name:        "my-project",
    Description: "Created via SDK",
    Visibility:  "private",
})
if err != nil {
    log.Fatal(err)
}
fmt.Println(repo.ID)
Create a pull request
pr, err := client.PullRequests.Create(ctx, repo.ID, &gitforge.CreatePRRequest{
    Title:        "Add feature",
    Description:  "Implements new feature",
    SourceBranch: "feature/new-thing",
    TargetBranch: "main",
})
if err != nil {
    log.Fatal(err)
}
fmt.Printf("PR #%d: %s\n", pr.Number, pr.Title)
All SDKs Support
  • Automatic pagination for list endpoints
  • Typed request and response objects
  • Configurable timeouts and retries
  • Custom base URL for self-hosted instances
  • Webhook payload verification helpers
Resources
SDKs | GitForge