This document describes all REST API endpoints provided by Gitoscope.
http://localhost:3000/api
(Port configurable via PORT environment variable)
- Status Endpoints
- Content Endpoints
- Git Objects Endpoints
- Reference Endpoints
- Error Handling
- Examples
Returns comprehensive file status information across working copy, staging area (cache), and HEAD commit.
Endpoint: GET /api/status
Response:
{
"files": [
{
"fileName": "example.js",
"isInWorkingCopy": true,
"isInCache": true,
"isInTree": true,
"diffString": "modified",
"diffCachedString": ""
}
]
}Field Descriptions:
fileName(string): Name of the fileisInWorkingCopy(boolean): File exists in working directoryisInCache(boolean): File exists in staging areaisInTree(boolean): File exists in HEAD commitdiffString(string): Status between working copy and cache"added": New file in working copy"modified": File changed in working copy"deleted": File removed from working copy"": No changes
diffCachedString(string): Status between cache and HEAD"added": New file staged for commit"modified": Modified file staged"deleted": File deletion staged"": No changes
Example Request:
curl http://localhost:3000/api/statusUse Cases:
- Display working copy state
- Show staged changes
- Compare current state with HEAD
These endpoints retrieve file content from different areas of the repository.
Returns file content from the HEAD commit.
Endpoint: GET /api/HEAD/entries/:name
Parameters:
name(path parameter): File name (must match[\w.]+)
Response:
{
"content": "file contents here...",
"name": "example.js"
}Example Request:
curl http://localhost:3000/api/HEAD/entries/example.jsReturns file content from the working directory.
Endpoint: GET /api/workingCopy/entries/:name
Parameters:
name(path parameter): File name (must match[\w.]+)
Response:
{
"content": "current file contents...",
"name": "example.js"
}Example Request:
curl http://localhost:3000/api/workingCopy/entries/example.jsReturns file content from the staging area (index/cache).
Endpoint: GET /api/cache/entries/:name
Parameters:
name(path parameter): File name (must match[\w.]+)
Response:
{
"content": "staged file contents...",
"name": "example.js"
}Example Request:
curl http://localhost:3000/api/cache/entries/example.jsThese endpoints provide access to Git's internal object database.
Returns details of a specific commit.
Endpoint: GET /api/commits/:commitId
Parameters:
commitId(path parameter): SHA-1 hash of the commit (must match\w+)
Response:
{
"id": "a1b2c3d4e5f6...",
"type": "commit",
"tree": "tree123...",
"treeUrl": "/api/trees/tree123...",
"parents": [
{
"id": "parent123...",
"url": "/api/commits/parent123..."
}
],
"author": "John Doe <john@example.com>",
"committer": "John Doe <john@example.com>",
"message": "Commit message here",
"timestamp": "2025-11-08T12:00:00Z"
}Field Descriptions:
id: SHA-1 hash of the committype: Always "commit"tree: SHA-1 hash of the root tree objecttreeUrl: REST URL to fetch the tree objectparents: Array of parent commit referencesauthor: Author name and emailcommitter: Committer name and emailmessage: Commit messagetimestamp: Commit timestamp (ISO 8601)
Example Request:
curl http://localhost:3000/api/commits/a1b2c3d4e5f6Use Cases:
- Display commit history
- Show commit details
- Navigate commit graph
Returns a tree object and its entries (files and subdirectories).
Endpoint: GET /api/trees/:treeId
Parameters:
treeId(path parameter): SHA-1 hash of the tree (must match\w+)
Response:
{
"id": "tree123...",
"type": "tree",
"entries": [
{
"mode": "100644",
"type": "blob",
"id": "blob456...",
"name": "file.js",
"url": "/api/blobs/blob456..."
},
{
"mode": "040000",
"type": "tree",
"id": "subtree789...",
"name": "subdir",
"url": "/api/trees/subtree789..."
}
]
}Field Descriptions:
id: SHA-1 hash of the treetype: Always "tree"entries: Array of tree entriesmode: Git file mode (100644 = regular file, 040000 = directory, 100755 = executable)type: Entry type ("blob" or "tree")id: SHA-1 hash of the entryname: File or directory nameurl: REST URL to fetch the entry
Example Request:
curl http://localhost:3000/api/trees/tree123Use Cases:
- Browse repository structure
- Display directory contents
- Navigate file hierarchy
Returns a blob object (file content).
Endpoint: GET /api/blobs/:blobId
Parameters:
blobId(path parameter): SHA-1 hash of the blob (must match\w+)
Response:
{
"id": "blob456...",
"type": "blob",
"content": "file contents here...",
"size": 1234
}Field Descriptions:
id: SHA-1 hash of the blobtype: Always "blob"content: File content (text or base64 for binary)size: Size in bytes
Example Request:
curl http://localhost:3000/api/blobs/blob456Use Cases:
- Display file contents
- Download files from Git object database
- Compare object contents
Returns all Git references (branches, tags, HEAD).
Endpoint: GET /api/references
Response:
{
"references": [
{
"name": "HEAD",
"type": "symbolic",
"target": "refs/heads/main",
"commit": "a1b2c3d4e5f6..."
},
{
"name": "refs/heads/main",
"type": "direct",
"commit": "a1b2c3d4e5f6...",
"url": "/api/commits/a1b2c3d4e5f6..."
},
{
"name": "refs/heads/feature-branch",
"type": "direct",
"commit": "b2c3d4e5f6a1...",
"url": "/api/commits/b2c3d4e5f6a1..."
},
{
"name": "refs/tags/v1.0.0",
"type": "direct",
"commit": "c3d4e5f6a1b2...",
"url": "/api/commits/c3d4e5f6a1b2..."
}
]
}Field Descriptions:
name: Reference name (e.g., "HEAD", "refs/heads/main")type: Reference type"symbolic": Points to another reference (like HEAD)"direct": Points directly to a commit
target: For symbolic refs, the reference it points tocommit: SHA-1 hash of the commiturl: REST URL to fetch the commit
Example Request:
curl http://localhost:3000/api/referencesUse Cases:
- List branches
- Show tags
- Display current HEAD
- Build branch selector UI
All endpoints follow standard HTTP status codes and return JSON error responses.
{
"error": {
"message": "Error description",
"code": "ERROR_CODE",
"details": {}
}
}200 OK: Successful request404 Not Found: Resource not found (commit, tree, blob, or file)400 Bad Request: Invalid parameters500 Internal Server Error: Server-side error (e.g., git command failed)
File not found in HEAD:
HTTP/1.1 404 Not Found
Content-Type: application/json
{
"error": {
"message": "File not found in HEAD commit",
"code": "FILE_NOT_FOUND"
}
}Invalid commit ID:
HTTP/1.1 400 Bad Request
Content-Type: application/json
{
"error": {
"message": "Invalid commit ID format",
"code": "INVALID_COMMIT_ID"
}
}-
Get all references to find commits:
curl http://localhost:3000/api/references
-
Get commit details:
curl http://localhost:3000/api/commits/a1b2c3d4e5f6
-
Get the commit's root tree:
curl http://localhost:3000/api/trees/tree123
-
Get a specific file blob:
curl http://localhost:3000/api/blobs/blob456
-
Get repository status:
curl http://localhost:3000/api/status
-
Compare working copy with HEAD:
# Get from working copy curl http://localhost:3000/api/workingCopy/entries/example.js # Get from HEAD curl http://localhost:3000/api/HEAD/entries/example.js
-
Check staged version:
curl http://localhost:3000/api/cache/entries/example.js
# Pretty-print status
curl -s http://localhost:3000/api/status | jq '.'
# Get only file names from status
curl -s http://localhost:3000/api/status | jq '.files[].fileName'
# List all branches
curl -s http://localhost:3000/api/references | jq '.references[] | select(.name | startswith("refs/heads/"))'Currently, there is no rate limiting implemented. This is an educational tool meant for local development.
Future Consideration: Add rate limiting before exposing to untrusted networks.
Currently, there is no authentication required.
Security Note: This tool is designed for local, trusted environments. Do not expose to public networks without adding authentication and authorization.
CORS is not configured. The API is intended to be accessed by the frontend served from the same origin.
All endpoints return Content-Type: application/json.
There is no support for other content types (XML, YAML, etc.).
The API is currently unversioned. All endpoints are at the root /api path.
Future Consideration: Add versioning (e.g., /api/v1/) before making breaking changes.
# Test status endpoint
curl -i http://localhost:3000/api/status
# Test with verbose output
curl -v http://localhost:3000/api/references# Install HTTPie: pip install httpie
http GET localhost:3000/api/statusImport this base URL: http://localhost:3000/api
Create requests for each endpoint documented above.
See test files in __tests__/ directory for Jest/Supertest integration tests.
Run tests:
npm testFor issues or questions:
- Check ARCHITECTURE.md for implementation details
- Review CLAUDE.md for AI assistant context
- Open an issue on GitHub
Last Updated: 2025-11-08 API Version: Unversioned (initial release)