Overview
The KiCad API uses Protocol Buffers (protobuf) for message serialization and follows a request-response pattern. All API calls are wrapped in an envelope structure that provides status codes and error handling.Connection
The API server runs on a local socket and uses protobuf messages for communication. Each request must be wrapped in anApiRequest envelope and will receive an ApiResponse envelope.
Message Envelope
ApiRequest
All requests to KiCad must be wrapped in this envelope:header- Request metadata (see ApiRequestHeader)message- The actual command message (type-encoded using protobuf Any)
ApiRequestHeader
kicad_token- Opaque string to verify connection to same KiCad instanceclient_name- Unique identifier for your client (e.g., “com.example.my_plugin-12345”)
ApiResponse
All responses from KiCad are wrapped in this envelope:header- Response metadatastatus- Status code and error informationmessage- The response data (if successful)
ApiResponseStatus
Status Codes
Common Commands
Base Commands
GetVersion
Retrieves the KiCad version.Ping
Checks if the connection is active.Empty message with AS_OK status.
GetTextExtents
Calculates the bounding box for text.kiapi.common.types.Box2 with text bounds.
GetPluginSettingsPath
Gets a writable path for plugin data storage.Board Commands
All board commands are in thekiapi.board.commands package.
Board Stackup
GetBoardStackup
GetBoardEnabledLayers
SetBoardEnabledLayers
Warning: This operation deletes content on disabled layers and cannot be undone.Board Origins
GetBoardOrigin
Vector2 with the origin coordinates.
SetBoardOrigin
Net Management
GetNets
Retrieves all nets or filtered by netclass.GetItemsByNet
Retrieves copper items belonging to specific nets.GetItemsResponse.
GetNetClassForNets
Retrieves the effective netclass for nets (merged from multiple classes).Zone Operations
RefillZones
Blocking operation - KiCad returnsAS_BUSY until complete.
Pad Utilities
GetPadShapeAsPolygon
Computes polygon representation of pad shapes.CheckPadstackPresenceOnLayers
Tests if pads/vias have content on specific layers.DRC Markers
InjectDrcError
Creates a DRC marker programmatically (available since v10.0).PCB Editor Display
GetVisibleLayers / SetVisibleLayers
GetActiveLayer / SetActiveLayer
Board Appearance Settings
Interactive Commands
These commands begin interactive operations in the editor and return immediately, but KiCad becomes busy until the user completes the operation.InteractiveMoveItems
Note: Takes ownership of the active commit. The move tool will push the commit when confirmed or roll back if cancelled.Error Handling
Always check thestatus field in ApiResponse:
Best Practices
- Set client_name - Always provide a unique client identifier in the request header
- Handle AS_BUSY - Some operations are blocking; poll until KiCad is ready
- Check status codes - Always verify the response status before accessing message data
- Use kicad_token - For long-running clients, use tokens to ensure connection stability
- Batch operations - When possible, batch multiple item queries in a single request
Proto File Locations
The protocol buffer definitions are located in the KiCad source tree:api/proto/common/- Common types and base commandsapi/proto/board/- PCB board-specific commandsapi/proto/schematic/- Schematic-specific commands
See Also
- Python API - Python scripting interface
- CLI Reference - Command-line interface