Quickstart
Start a Spica project on your machine, create your first bucket, read data over REST and serve your first function, in about ten minutes.
This guide runs Spica locally with the Spica CLI. The CLI starts the API, the admin panel, a database and an ingress as Docker containers, so you don't install anything else.
Before you begin
You need:
Install the CLI
Terminalnpm install -g @spica/cli spica --versionStart a project
Choose a name for your project and start it. The first run pulls the images, which takes a minute.
Terminalspica project start my-appWhen the project is ready, the CLI prints where it is serving:
TextSpica my-app is serving on http://localhost:4500. Open your browser on http://localhost:4500/dashboard to login. Identitifer: spica Password: spicaThe panel is served at
http://localhost:4500and the API athttp://localhost:4500/api. If port 4500 is busy, the CLI picks a free port and tells you which one.Log in to the panel
Create a bucket
Buckets hold your data. In the panel, open Buckets, click New Bucket and create a
Postsbucket with atitle(string) and abody(textarea) property. Then add a few entries with New Entry.You can do the same over the API. First get a token:
Terminalcurl -X POST http://localhost:4500/api/passport/identify \ -H "Content-Type: application/json" \ -d '{"identifier": "spica", "password": "spica"}'JSON{"scheme": "IDENTITY", "token": "eyJhbGciOi...", "issuer": "passport/identity"}Then create the bucket with that token:
Terminalcurl -X POST http://localhost:4500/api/bucket \ -H "Authorization: IDENTITY <token>" \ -H "Content-Type: application/json" \ -d '{ "title": "Posts", "description": "Blog posts", "primary": "title", "properties": { "title": {"type": "string", "title": "Title"}, "body": {"type": "textarea", "title": "Body"} } }'Read and write data
Use the bucket id from the response to insert and list entries:
Terminalcurl -X POST http://localhost:4500/api/bucket/<bucketId>/data \ -H "Authorization: IDENTITY <token>" \ -H "Content-Type: application/json" \ -d '{"title": "Hello Spica", "body": "My first post"}' curl "http://localhost:4500/api/bucket/<bucketId>/data?limit=10" \ -H "Authorization: IDENTITY <token>"JSON[{"_id": "6b0b1972a5611972c29c25fd", "title": "Hello Spica", "body": "My first post"}]On PostgreSQL the bucket and its entries are identified by
idinstead of_id. See MongoDB and PostgreSQL.Write a function
Open Functions, click Add New Function, name it
helloand add an HTTP trigger with methodGetand path/hello. Replace the code with:index.mjsexport default function (req, res) { const name = req.query.name ?? "world"; return {message: `Hello, ${name}!`}; }Save, then call it:
Terminalcurl "http://localhost:4500/api/fn-execute/hello?name=Ada"JSON{"message": "Hello, Ada!"}
Clean up
Stop and remove the project when you are done. Data is kept in Docker volumes unless you ask the CLI to remove them:
spica project remove my-app --retain-volumes=falseNext steps
Learn the vocabulary: buckets, functions, identities, users, policies and API keys.
Every property type, validation option and setting a bucket supports.
Fetch your buckets and functions into files, review changes with spica plan and apply them.
A complete scenario: content model, public read access, editors and webhooks.
