Skip to content

fhello23/synapse-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Synapse API

A Go-based API for managing prompt/knowledge/context data with template filling capabilities.

Features

  • RESTful API for managing JSON data structure
  • Endpoints for Prompts, Contexts, Knowledge, and Template Libraries
  • Template variable filling functionality
  • JSON data persistence

About the Data Source

The data managed by this API is generated and exported from Synapse, a native macOS app for organizing and managing reusable prompts, context information, and knowledge items for LLM workflows.

What is Synapse?

Synapse is a powerful macOS application designed to help users structure and manage their AI workflow content. It features:

  • Three Main Sections: Prompts (with placeholders), Contexts (reference materials), and Knowledge (facts and summaries)
  • Organized Structure: Custom groups, tags, favorites, and smart collections for easy organization and retrieval
  • Rich Features: AI-powered prompt generation (OpenRouter integration), advanced search and filtering, import/export, visual editor, and metadata tracking
  • Workflow Enhancements: Global hotkeys, batch prompt generation, keyboard navigation, and a native three-panel macOS interface
  • Data Storage: All data is stored in a human-readable JSON file at ~/Documents/synapse_data.json, which can be imported/exported for use with this API

For more details, see the Synapse documentation or the full feature list below.


Setup

  1. Clone the repository
  2. Run go mod tidy to install dependencies
  3. Run go run main.go to start the server

The server will start on port 8081.

Running the API

To start the API server:

go run main.go

Or to build and run:

go build -o synapse-api
./synapse-api

API Endpoints

General Data Operations

  • GET /api/data - Get all data
  • PUT /api/data - Update all data

Prompts

  • GET /api/prompts - Get all prompts
  • PUT /api/prompts - Update prompts

Contexts

  • GET /api/contexts - Get all contexts
  • PUT /api/contexts - Update contexts

Knowledge

  • GET /api/knowledge - Get all knowledge items
  • PUT /api/knowledge - Update knowledge items

Templates

  • GET /api/templates - Get all template libraries
  • PUT /api/templates - Update template libraries

Template Filling

  • POST /api/fill-template - Fill a template with variables
  • POST /api/fill-template-by-id - Fill a template by its ID with variables

Example request body for /api/fill-template:

{
  "template": "Hello {name}, welcome to {place}!",
  "variables": {
    "name": "John",
    "place": "our platform"
  }
}

Example request body for /api/fill-template-by-id:

{
  "template_id": "94BD3B8E-93C4-4ED8-B2A1-9765016C9521",
  "variables": {
    "meeting_topic": "project planning",
    "recipient_name": "John Doe",
    "sender_name": "Jane Smith"
  }
}

Testing

You can run the provided test script to verify the API is working:

./test-api.sh

Note: You'll need curl and jq installed for the test script to work.

Data Structure

The API manages a JSON structure with the following main components:

  • savedSearches - Array of saved searches
  • templateLibraries - Array of template libraries with snippets
  • groups - Object containing groups for Prompts, Contexts, and Knowledge
  • customSnippets - Array of custom snippets
  • smartCollections - Array of smart collections
  • lastModified - Timestamp of last modification

Dependencies

About

A Go-based API for managing prompt/knowledge/context data with template filling capabilities.

Resources

License

Stars

Watchers

Forks