Skip to content

Features

gRPC API

Requires a license with the grpc feature. See pricing.

The gRPC API serves your content types and entries to gRPC clients on a port of its own, with the same data, tenants, roles and data residency rules as the REST APIs. A second port answers health checks and offers every method as a plain JSON route, which is handy with curl. It adds no features over REST: it carries the same calls over HTTP/2.

As a super admin, open Delivery > gRPC. A badge says whether the gRPC API is Serving. Listeners gives the gRPC address, with a button to copy it, the Health and REST address and whether Reflection is on. On the default addresses it notes that the listeners are on loopback only. Services lists each service with what its health check reports, and REST, without a gRPC client lists the JSON routes. Refresh reads the status again.

The Services table of the gRPC page, with ContentService, FlowService and SchemaService each reported as Serving.

ListenerVariableDefaultServes
gRPCGRPC_ADDR127.0.0.1:3003SchemaService, ContentService, FlowService, gRPC health, and reflection outside production
Health and JSONGRPC_HEALTH_ADDR127.0.0.1:3004/healthz, and every method as a JSON route under /api/

Both are separate from the Admin API (3001) and the Content API (3002). Both default to loopback, so nothing outside the container reaches them until you change the address. The gRPC listener is plaintext HTTP/2: put TLS in front of it as you do for the Content API. The Kubernetes deployment shows the container ports and Service entries.

For the console steps, you are signed in to LyEve Console as a super admin. For the API steps, you need a signed-in user's token in TOKEN. The quickstart shows how to get one.

1. Open both listeners. This is set in the environment of the instance, not in the console or the API. Publish the ports (the engine image exposes 3003 and 3004), then restart:

Shell
GRPC_ADDR=0.0.0.0:3003
GRPC_HEALTH_ADDR=0.0.0.0:3004

2. Check health.

Console v0.28.0

Open Delivery > gRPC. The badge reads Serving, Listeners gives the two addresses, and Services lists each service with what its health check says.

Engine API v0.62.0

The health route needs no token:

Shell
curl http://localhost:3004/healthz
JSON
{"status": "SERVING", "services": {"": "SERVING", "lyeve.core.v1.ContentService": "SERVING", "lyeve.core.v1.SchemaService": "SERVING"}}

3. List entries of a content type through the JSON route.

Console v0.28.0

Open Delivery > API labs and choose gRPC. Under Transcoded route, pick GET /api/content/{schema}, type post in schema and choose Run. The console runs the route inside the engine with your own token.

Engine API v0.62.0

Shell
curl http://localhost:3004/api/content/post \
-H "Authorization: Bearer $TOKEN"
JSON
{"items": [{"id": "c8a14e2b-7d3f-4b90-a1c6-5e8f0d2b9a74", "title": "Hello"}]}

4. Call the gRPC listener itself. Only a gRPC client does this. grpcurl reads the services through reflection, which needs a token, so pass one even for the health service:

Shell
grpcurl -plaintext -H "authorization: Bearer $TOKEN" \
localhost:3003 grpc.health.v1.Health/Check

The answer is {"status": "SERVING"}. On engine v0.58.0, grpcurl list and grpcurl describe read every LyEve service, but grpcurl cannot call them, because the services take JSON messages and grpcurl sends binary ones. Call them from a client that sends JSON messages, as Call the services describes. In Go:

Go
type jsonCodec struct{}
func (jsonCodec) Marshal(v any) ([]byte, error) { return json.Marshal(v) }
func (jsonCodec) Unmarshal(b []byte, v any) error { return json.Unmarshal(b, v) }
func (jsonCodec) Name() string { return "json" }
func listSchemas(token string) (json.RawMessage, error) {
encoding.RegisterCodec(jsonCodec{})
conn, err := grpc.NewClient("localhost:3003",
grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return nil, err
}
defer conn.Close()
ctx := metadata.AppendToOutgoingContext(context.Background(),
"authorization", "Bearer "+token)
var out json.RawMessage
err = conn.Invoke(ctx, "/lyeve.core.v1.SchemaService/ListSchemas",
json.RawMessage(`{}`), &out, grpc.CallContentSubtype("json"))
return out, err
}

The answer lists your content types as schemas, each with name and definition. Without a token, the call fails with Unauthenticated.

ServiceMethodsRole
lyeve.core.v1.SchemaServiceListSchemas, GetSchemaviewer, editor or admin
lyeve.core.v1.ContentServiceList, Getviewer, editor or admin
lyeve.core.v1.ContentServiceCreate, Update, Deleteeditor or admin
lyeve.core.v1.FlowServiceRun, Listany signed-in user, and the flow's own auth setting
grpc.health.v1.HealthCheck, Watchnone
grpc.reflection.v1.ServerReflectiona token, and only outside production. On engine v0.58.0 it lists and describes each service.

A super admin may call every method. The services are defined in lyeve/core/v1/schema.proto, lyeve/core/v1/content.proto and lyeve/core/v1/flow.proto, package lyeve.core.v1.

Messages travel as JSON, so you can call the services without generated message types: use the json content subtype, which sends Content-Type: application/grpc+json. In Go, pass grpc.CallContentSubtype("json"). In the .proto files, definition, items, item, data, filters, input and input_schema are google.protobuf.Struct fields, and the body of a flow run is a google.protobuf.Value. On the wire each key is the field's own name, and its value is a JSON object, or any JSON value for body, never an encoded string.

MethodRequestAnswer
ContentService.Listschema, limit (default 50, 1 to 500), offset, filters (equality on known fields), locale, fields, populate, depthitems
ContentService.Getschema, id, locale, fields, populate, depthitem
ContentService.Createschema, dataitem
ContentService.Updateschema, id, dataitem
ContentService.Deleteschema, idempty
SchemaService.ListSchemasnoneschemas, each name and definition
SchemaService.GetSchemanamename and definition
FlowService.Runslug, inputrun_id, status, headers, body
FlowService.Listnoneflows, each slug, name, description, auth and input_schema

On content types that use soft delete, List and Get leave deleted entries out, and Delete soft-deletes.

A content type's transports block decides what gRPC serves:

CaseAnswer
The content type is off for gRPCNOT_FOUND, the answer a missing content type gets, and ListSchemas leaves it out
It is served, but not in this direction (r refuses writes, w refuses reads)FAILED_PRECONDITION

See Transports.

List and Get take the read options the Content API takes:

  • fields keeps only the named fields of each entry. id, created_at, updated_at and resolved_locale stay whatever you name, and a belongs-to relation keeps its key column and its entry together. A name the content type does not have, or one you may not read, answers INVALID_ARGUMENT.
  • populate serves a relation as the entries it points at: a belongs-to or has-one relation as an entry or null, a has-many or many-to-many relation as a list, newest first. author.company reaches a relation of the related entry, * populates every relation at its level, and author{name} keeps only the named fields of each related entry. A name that is not a relation is skipped.
  • depth populates every relation, to that many levels, from 0 to 10.
  • filters, on List, keeps the entries whose fields equal the values you give. A value written as text is read by its field's type: true or false, a number, a UUID with its dashes, a date written 2006-01-02, or a time in RFC 3339. A value its field cannot hold, and a filter on a JSON field, answer INVALID_ARGUMENT. A field name the content type does not have is ignored, so check the spelling.

A related entry is what a read of its own content type gives you: from your tenant, not deleted, with that type's field rules, and a draft only when you may read drafts there. A has-one relation serves the newest entry you may read. A relation into a content type you may not read, or one gRPC does not read, is left out of the entry. So is a has-one or has-many relation whose related entries hide the field that links them to this one from you.

A read has three bounds, and past one it answers INVALID_ARGUMENT: 5000 related entries, counting an entry once under each entry it is served under, 32 MiB of them, and 1000 database queries. A request to List that keeps two fields of each post and serves its author's name and its tags:

JSON
{
"schema": "post",
"fields": ["title", "author"],
"populate": ["author{name}", "tags"]
}

Send it from a JSON client as in Try it, to /lyeve.core.v1.ContentService/List.

Send a signed-in user's session token in the authorization metadata on gRPC, or the Authorization header on the JSON routes. API keys are not accepted here, and neither is a sign-in that still waits for its second factor. Only the health service and /healthz answer without a token. The token's tenant_id claim decides the tenant, never a header the client sends. See Tenants.

Every call is rate limited, authenticated, scoped to its tenant and checked for data residency before it runs.

The health and JSON listener offers the same calls for clients without gRPC:

JSON routes on GRPC_HEALTH_ADDR
MethodPathSame as
GET/healthzHealth summary. ?service=<name> checks one service. No token needed.
GET/api/schemasSchemaService.ListSchemas
GET/api/schemas/{name}SchemaService.GetSchema
GET/api/content/{schema}ContentService.List. Takes limit, offset, locale, filters[<field>], fields, populate and depth.
GET/api/content/{schema}/{id}ContentService.Get. Takes locale, fields, populate and depth.
POST/api/content/{schema}ContentService.Create. Answers 201.
PUT/api/content/{schema}/{id}ContentService.Update
DELETE/api/content/{schema}/{id}ContentService.Delete. Answers {"deleted": "<id>"}.
GET/api/flowsFlowService.List
POST/api/flows/{slug}FlowService.Run. The body is the input.

GET / redirects to /healthz.

On these routes the whole body is the entry, while the Content API on 3002 takes {"data": {...}}. Sending that envelope here creates an entry with one field named data:

Shell
curl -X POST http://localhost:3004/api/content/post \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"title": "From gRPC JSON", "slug": "from-grpc-json"}'

The answer is 201 with {"item": {...}}. A body is at most 1 MB, and one that is not JSON answers 400 with {"error": "invalid JSON body"}.

The read options go in the query string, fields and populate as comma lists, and a comma inside a projection's braces stays in its path:

Shell
curl "http://localhost:3004/api/content/post?fields=title,author&populate=author%7Bid,name%7D&filters%5Bfeatured%5D=true" \
-H "Authorization: Bearer $TOKEN"

A filters key without its closing bracket, an empty name in fields, two values for one filter, a brace in populate left open or closed without opening, or a limit, offset or depth that is not a whole number answers 400 with {"error": "invalid query parameter: <name>"}.

When flows run beside gRPC, FlowService.Run starts a published flow of the caller's tenant whose HTTP trigger lists grpc in protocols, with input as the trigger body:

JSON
{"slug": "order-totals", "input": {"order": 7}}

Send it from a JSON client as in Try it, to /lyeve.core.v1.FlowService/Run. The same run is POST /api/flows/order-totals on the JSON listener, with the input as the body. In the console, open Delivery > API labs, choose gRPC, pick POST /api/flows/{slug} under Transcoded route, fill in the slug and the body, and choose Run. The console asks first, and Run it starts the flow.

The answer carries the run id (empty when the flow's cache answered), the status the flow set or 200, its headers and the body. The flow's auth setting decides who may run it: public and auth flows answer, and admin flows answer NOT_FOUND. Its rate limit and cache count gRPC callers apart from REST and GraphQL callers.

CodeMeaning
NOT_FOUNDNo published flow has that slug for this protocol and caller.
PERMISSION_DENIEDThe license does not carry flow-pro, which starting a flow over gRPC needs.
RESOURCE_EXHAUSTEDThe flow's rate limit refused the call.
ABORTEDThe call would nest flows too deep.
UNAVAILABLEThe flow could not run.
UNIMPLEMENTEDFlows are not available on this instance. The JSON routes answer 501.

Both need a super admin and live on the Admin API. The console's Delivery > gRPC page reads the status route, and API labs runs routes through the invoke route.

MethodPathPurpose
GET/api/admin/grpc/statusThe listeners, their services, what health reports and the JSON routes.
POST/api/admin/grpc/invokeRun one JSON route inside the engine with your own token and return its answer.
Shell
curl -X POST http://localhost:3001/api/admin/grpc/invoke \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"route": "GET /api/content/{schema}", "params": {"schema": "post"}}'

route is one of the JSON routes, written as in the table. params fills its {name} parts and body is sent on a write. The answer carries the status, duration_ms, headers and body.

VariableWhat it doesDefault
GRPC_ADDRAddress of the gRPC listener127.0.0.1:3003
GRPC_HEALTH_ADDRAddress of the health and JSON listener127.0.0.1:3004
GRPC_RATE_LIMITCalls a second per gRPC method, shared by every caller. Only a positive number is taken, so the limit cannot be turned off.100
GRPC_RATE_BURSTBurst per gRPC method200
JWT_SECRET, JWT_SECRETSThe secrets tokens are checked against. Without one, every call except health is refused.none
APP_ENVOutside production, server reflection is served. Nothing else changes.production
INSTANCE_REGIONWith data residency, writes from a tenant assigned to another region are refused.empty, so off

A gRPC request is at most 4 MiB, and a larger one is refused with RESOURCE_EXHAUSTED before it is read. A response is at most 32 MiB. Calls in flight get up to 10 seconds to finish on shutdown. If you set LYEVE_PLUGINS to choose which features start, include grpc. See Licensing and tiers.

On the JSON routes, gRPC codes map to HTTP statuses.

gRPC codeHTTPCause
UNAUTHENTICATED401No token, a token that does not verify, or no JWT secret configured.
PERMISSION_DENIED403The caller's role does not allow it, or FlowService without flow-pro.
INVALID_ARGUMENT400A malformed request.
NOT_FOUND404No such content type or entry.
ALREADY_EXISTS409A conflicting entry.
RESOURCE_EXHAUSTED429rate limit exceeded. Slow down or raise GRPC_RATE_LIMIT.
FAILED_PRECONDITION421A write from a tenant that belongs in another region. The JSON answer is {"error": "write routed to wrong region", "target_region": "<slug>"}.
FAILED_PRECONDITION400A content type served over gRPC in the other direction only. The JSON answer's error says the content type is read-only or write-only over gRPC.
DEADLINE_EXCEEDED504The call ran out of time.
UNAVAILABLE503The tenant's region could not be read, or the database did not answer.