Skip to content

Spellbook API Reference

This reference provides a conceptual overview of the Spellbook API for working with Temporal Bayesian Knowledge Graphs.

Spellbook uses URL-based versioning for its API to ensure backward compatibility as the system evolves:

https://spellbook.magick.ai/api/v1/memories

All API endpoints are prefixed with /api/v1/ to indicate they are using version 1 of the API.

For interactive API documentation with the ability to test endpoints directly, visit the Swagger UI.

The Swagger UI provides:

  • Detailed endpoint documentation
  • Request and response schemas
  • The ability to try API calls directly from your browser
  • Authentication support
ElementDescription
EntityA node in the knowledge graph representing a person, place, concept, or object
RelationshipAn edge connecting two entities, describing how they relate to each other
PropertyAn attribute or characteristic of an entity or relationship
Temporal AnnotationTime-based metadata attached to entities, relationships, or properties
Belief ScoreA probabilistic confidence value associated with a fact or relationship
OperationDescription
CreateAdd new entities, relationships, or properties to the graph
ReadQuery and retrieve information from the graph
UpdateModify existing entities, relationships, or properties
DeleteRemove elements from the graph
MergeCombine information from multiple sources with appropriate belief updates

The Spellbook API is organized into several functional areas, all accessible under the /api/v1 base path:

APIs for creating, retrieving, updating, and deleting entities in the knowledge graph.

APIs for establishing, modifying, and removing relationships between entities.

APIs for working with the temporal aspects of the knowledge graph, including:

  • Querying the state of the graph at a specific point in time
  • Tracking the evolution of entities and relationships over time
  • Analyzing temporal patterns and trends

APIs for probabilistic reasoning, including:

  • Updating belief scores based on new evidence
  • Calculating conditional probabilities
  • Performing inference across the graph

APIs for retrieving information from the knowledge graph:

  • Entity and relationship lookup
  • Pattern matching across the graph
  • Semantic similarity search
  • Temporal and causal reasoning queries

Access to the Spellbook API is controlled through:

  • API keys for service-to-service communication
  • JWT tokens for user authentication
  • Role-based access control for multi-tenant deployments

Spellbook provides integration capabilities with:

  • Large Language Models via the Model Context Protocol (MCP)
  • Workflow automation tools
  • Custom applications via REST APIs

Here are some examples of how to use the Spellbook API with versioned endpoints:

Terminal window
curl -X POST https://spellbook.magick.ai/api/v1/entities \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"name": "Albert Einstein",
"type": "person",
"description": "Theoretical physicist who developed the theory of relativity",
"metadata": {
"birth_year": 1879,
"death_year": 1955
}
}'
Terminal window
# Get all entities
curl -X GET https://spellbook.magick.ai/api/v1/entities \
-H "Authorization: Bearer YOUR_API_KEY"
# Get a specific entity by ID
curl -X GET https://spellbook.magick.ai/api/v1/entities/12345 \
-H "Authorization: Bearer YOUR_API_KEY"
Terminal window
curl -X POST https://spellbook.magick.ai/api/v1/relationships \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"sourceEntityId": "12345",
"targetEntityId": "67890",
"type": "developed",
"metadata": {
"year": 1915
}
}'
Terminal window
curl -X POST https://spellbook.magick.ai/api/v1/query/temporal \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"entityId": "12345",
"startTime": "1900-01-01T00:00:00Z",
"endTime": "1920-01-01T00:00:00Z"
}'