<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->

# API Reference — Public Code Repositories

## GitHub REST API

### Organization Repos
```bash
curl -s -H "Authorization: token $GITHUB_TOKEN" \
  "https://api.github.com/orgs/targetorg/repos?per_page=100"
```

### Organization Members
```bash
curl -s -H "Authorization: token $GITHUB_TOKEN" \
  "https://api.github.com/orgs/targetorg/public_members"
```

### Code Search
```bash
curl -s -H "Authorization: token $GITHUB_TOKEN" \
  "https://api.github.com/search/code?q=org:targetorg+password"
```

### User Events
```bash
curl -s "https://api.github.com/users/targetuser/events?per_page=30"
```

## gh CLI

### Code Search
```bash
gh search code "org:targetorg api_key" --limit 50
gh search code "org:targetorg filename:.env" --limit 50
```

### Repo Operations
```bash
gh repo list targetorg --limit 100 --json name,url
gh repo view targetorg/repo --json description,languages
```

## Trufflehog

### GitHub Org Scan
```bash
trufflehog github --org=targetorg --only-verified --json
```

### Single Repo Scan
```bash
trufflehog git https://github.com/targetorg/repo.git --only-verified
```

### Filesystem Scan
```bash
trufflehog filesystem --directory=/path/to/repo --only-verified
```

## Gitleaks

### Detect in Repo
```bash
gitleaks detect --source=./repo -v --report-path=results.json
```

### SARIF Output
```bash
gitleaks detect --source=./repo --report-format=sarif -r results.sarif
```

### Custom Config
```bash
gitleaks detect --source=./repo --config=custom_rules.toml
```

## GitLab API

### Projects
```bash
curl -s -H "PRIVATE-TOKEN: $GITLAB_TOKEN" \
  "https://gitlab.com/api/v4/groups/targetgroup/projects"
```

### Search Code
```bash
curl -s -H "PRIVATE-TOKEN: $GITLAB_TOKEN" \
  "https://gitlab.com/api/v4/projects/ID/search?scope=blobs&search=password"
```

## GitHub Dorks Reference

| Dork | Purpose |
|------|---------|
| `org:target filename:.env` | Environment files |
| `org:target filename:id_rsa` | SSH keys |
| `org:target "AKIA"` | AWS access keys |
| `org:target "sk-"` | Stripe/OpenAI keys |
| `org:target "ghp_"` | GitHub tokens |
| `org:target "xoxb-"` | Slack tokens |
| `org:target filename:wp-config.php` | WordPress config |
| `org:target filename:credentials.json` | Credential files |

## Environment Variables

| Variable | Description |
|----------|-------------|
| `GITHUB_TOKEN` | GitHub personal access token |
| `GITLAB_TOKEN` | GitLab private token |
