For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Logo
ContactLearn More
GuidesReferenceSamplesLicenseChangelog
GuidesReferenceSamplesLicenseChangelog
  • Concepts
    • Overview
    • Principles
  • Getting started
    • Set up
    • Authenticate
    • Quickstart
  • Best practices
    • Choose a protocol
    • Connect offline
    • Retry connections
  • Developer tools
    • Sandboxes
  • Entities
    • Overview
    • Watch
    • Publish
  • Tasks
    • Overview
    • Operate
    • Listen
    • Update
  • Objects
    • Overview
    • Upload
    • Download
    • Manage
ContactLearn More
On this page
  • Authentication
  • Reliability and retries
  • Managing objects
  • Publishing entities
  • Streaming entities
  • Decision guide
  • What’s next
Best practices

Choose a protocol

Select between gRPC and REST for your Lattice SDK integration
Previous

Connect to offline environments

Configure the Lattice SDK for environments without access to the internet.
Next

The Lattice SDK supports both REST and gRPC protocols. REST offers familiar HTTP/JSON workflows with automatic authentication and broad tooling support.

RESTgRPC
InstallationPackages via PyPi, Maven, npm, source via GitHubPackages generated in Buf Schema Registry
Language SupportPython, Typescript, Java, and GoAuto-generated bindings for 16 languages
AuthenticationIncludes built-in support for OAuth 2.0Requires manual token lifecycle management
StreamingSupported with basic filteringSupported with advanced filtering
API availabilityEntities, Tasks, and ObjectsEntities and Tasks
RetriesBuilt-in retries for 5xx, 408, 409, and 429 responsesNo built-in retries, implement them in your integration
On-the-wire sizeLarger packets with JSON encodingSmaller packets with binary encoding
Browser supportBetter browser supportWeaker browser support

gRPC provides binary Protocol Buffers encoding that reduces bandwidth in constrained networks. For high-frequency scenarios, the payload difference compounds quickly. Publishing 50 drone positions at 10 Hz requires ~2 Mbps with REST and JSON, compared to ~1.3 Mbps with gRPC and Protobuf:

500 bytes × 10 updates/sec × 50 drones = 250 KB/sec = ~2 Mbps
gRPC authentication

If you are using gRPC with client credentials, set up the token refresh module before running the examples on this page.

Authentication

If you are using client credentials, your authentication set up differs between REST and gRPC. REST SDKs automatically manage OAuth token lifecycle, while gRPC requires manual token management with custom credential providers.

For complete authentication details including OAuth client credentials, environment tokens, and code examples for both protocols, see the Authenticate guide.

Reliability and retries

Networks that carry Lattice traffic, such as tactical links, satellite relays, and congested cloud egress, drop connections, throttle traffic, and return transient errors. How much of that your integration has to handle manually depends on the protocol you choose.

REST: Built-in retries for transient errors

The Lattice REST SDKs retry automatically on HTTP 5xx, 408, 409, and 429 responses, using exponential backoff starting at 1 second with a maximum of 60 seconds and ±20% jitter. The SDK also honors Retry-After, retry-after-ms, and X-RateLimit-Reset headers returned by the server. The default is 2 retries per call, and you can override this per call with request_options={"max_retries": N}.

For REST integrations, the baseline reliability story is already in the SDK. You only need a custom retry utility if you want to retry additional error classes (for example, 404 under eventual consistency) or centralize backoff policy across every call site.

gRPC: No built-in retries

The Lattice gRPC SDKs do not retry anything automatically. Every call that returns a non-OK status surfaces the error to your code unchanged. For gRPC integrations, you must implement retry logic yourself: classify gRPC status codes as retryable or terminal, apply an exponential backoff, and honor context cancellation.

For a modular, utility-driven pattern that works for both protocols, see Retry connections.

Managing objects

The Objects API is a REST-only content delivery network (CDN) service for uploading and managing files and binary data in Lattice. This API is not available in gRPC. If your integration requires file operations alongside gRPC entity or task operations, you need to use both protocols.

For more information on managing files and binary data, see Objects overview.

Publishing entities

The choice between REST and gRPC for publishing entities depends on your update frequency and data volume.

gRPC: High-throughput streaming

Use the PublishEntities API when your integration produces high volumes of entity updates. This API creates a client-side stream that efficiently publishes batches of entities in a single connection. This approach is ideal for integrations that generate large quantities of track detections, such as passive sensors or radar systems tracking multiple targets simultaneously.

1// This Go example is compatible with artifacts generated using
2// the following grpc/go plugin: https://buf.build/anduril/lattice-sdk/sdks/main:grpc/go
3package main
4
5import (
6 "context"
7 "fmt"
8 "log"
9 "os"
10 "time"
11
12 "buf.build/gen/go/anduril/lattice-sdk/grpc/go/anduril/entitymanager/v1/entitymanagerv1grpc"
13 entitymanagerv1 "buf.build/gen/go/anduril/lattice-sdk/protocolbuffers/go/anduril/entitymanager/v1"
14 ontologyv1 "buf.build/gen/go/anduril/lattice-sdk/protocolbuffers/go/anduril/ontology/v1"
15 "github.com/google/uuid"
16 "google.golang.org/grpc"
17 "google.golang.org/grpc/credentials"
18 "google.golang.org/protobuf/types/known/timestamppb"
19 "google.golang.org/protobuf/types/known/wrapperspb"
20)
21
22func main() {
23 ctx := context.Background()
24
25 // Get environment variables
26 clientID := os.Getenv("LATTICE_CLIENT_ID")
27 clientSecret := os.Getenv("LATTICE_CLIENT_SECRET")
28 latticeEndpoint := os.Getenv("LATTICE_ENDPOINT")
29 sandboxesToken := os.Getenv("SANDBOXES_TOKEN")
30
31 if latticeEndpoint == "" || clientSecret == "" || clientID == "" || sandboxesToken == "" {
32 log.Fatalf("Missing required environment variables")
33 }
34
35 // Set up authentication
36 authCredentials := &ClientCredentialsAuth{
37 ClientID: clientID,
38 ClientSecret: clientSecret,
39 SandboxesToken: sandboxesToken,
40 Endpoint: fmt.Sprintf("https://%s/api/v1/oauth/token", latticeEndpoint),
41 }
42
43 // Create gRPC connection
44 opts := []grpc.DialOption{
45 grpc.WithTransportCredentials(credentials.NewClientTLSFromCert(nil, "")),
46 grpc.WithPerRPCCredentials(authCredentials),
47 }
48 conn, err := grpc.NewClient(latticeEndpoint, opts...)
49 if err != nil {
50 log.Fatalf("Failed to connect: %v", err)
51 }
52 defer conn.Close()
53
54 client := entitymanagerv1grpc.NewEntityManagerAPIClient(conn)
55
56 // Create client-side streaming connection
57 stream, err := client.PublishEntities(ctx)
58 if err != nil {
59 log.Fatalf("Failed to create stream: %v", err)
60 }
61
62 log.Println("Publishing entities via client-side streaming...")
63
64 // Send multiple entities through the stream
65 for i := range 100 {
66 entity := &entitymanagerv1.Entity{
67 EntityId: fmt.Sprintf("entity-%s", uuid.New().String()[:8]),
68 Description: "Streaming track example",
69 Aliases: &entitymanagerv1.Aliases{
70 Name: fmt.Sprintf("Track-%d", i),
71 },
72 IsLive: true,
73 CreatedTime: timestamppb.Now(),
74 ExpiryTime: timestamppb.New(time.Now().Add(10 * time.Second)),
75 Ontology: &entitymanagerv1.Ontology{
76 Template: entitymanagerv1.Template_TEMPLATE_TRACK,
77 PlatformType: "UNKNOWN",
78 },
79 MilView: &entitymanagerv1.MilView{
80 Disposition: ontologyv1.Disposition_DISPOSITION_UNKNOWN,
81 Environment: ontologyv1.Environment_ENVIRONMENT_UNKNOWN,
82 },
83 Location: &entitymanagerv1.Location{
84 Position: &entitymanagerv1.Position{
85 LatitudeDegrees: 33.6405 + float64(i)*0.001,
86 LongitudeDegrees: -117.6738 + float64(i)*0.001,
87 AltitudeHaeMeters: wrapperspb.Double(100.0),
88 },
89 },
90 Provenance: &entitymanagerv1.Provenance{
91 IntegrationName: "streaming_example",
92 DataType: "track_data",
93 SourceUpdateTime: timestamppb.Now(),
94 },
95 }
96
97 // Send entity through stream
98 if err := stream.Send(&entitymanagerv1.PublishEntitiesRequest{Entity: entity}); err != nil {
99 log.Fatalf("Failed to send entity: %v", err)
100 }
101
102 if (i+1)%10 == 0 {
103 log.Printf("Sent %d entities", i+1)
104 }
105
106 // Throttle the call
107 time.Sleep(300 * time.Millisecond)
108 }
109
110 // Close the stream and receive response
111 _, err = stream.CloseAndRecv()
112 if err != nil {
113 log.Fatalf("Failed to close stream: %v", err)
114 }
115
116 log.Println("Successfully published entities")
117}

REST: Individual entity updates

Use the PublishEntity API when your integration publishes entities individually or at lower frequencies. This unary API publishes one entity per request, making it well-suited for stateful entities like assets that update their position and status periodically rather than continuously.

Go
1package main
2
3import (
4 "context"
5 "fmt"
6 "math"
7 "net/http"
8 "os"
9 "time"
10
11 Lattice "github.com/anduril/lattice-sdk-go/v4"
12 "github.com/anduril/lattice-sdk-go/v4/client"
13 "github.com/anduril/lattice-sdk-go/v4/option"
14 "github.com/google/uuid"
15)
16
17func main() {
18 // Get environment variables
19 latticeEndpoint := os.Getenv("LATTICE_ENDPOINT")
20 clientSecret := os.Getenv("LATTICE_CLIENT_SECRET")
21 clientId := os.Getenv("LATTICE_CLIENT_ID")
22
23 // Remove sandboxesToken from the following statements if you are not developing on Sandboxes
24 sandboxesToken := os.Getenv("SANDBOXES_TOKEN")
25
26 // Check required environment variables
27 if latticeEndpoint == "" || clientId == "" || clientSecret == "" || sandboxesToken == "" {
28 fmt.Println("Missing required environment variables")
29 os.Exit(1)
30 }
31
32 // Initialize headers for sandbox authorization
33 headers := http.Header{}
34 headers.Add("Anduril-Sandbox-Authorization", fmt.Sprintf("Bearer %s", sandboxesToken))
35
36 // Create the client
37 LatticeClient := client.NewClient(
38 option.WithClientCredentials(clientId, clientSecret),
39 option.WithBaseURL(fmt.Sprintf("https://%s", latticeEndpoint)),
40 option.WithHTTPHeader(headers),
41 )
42
43 // Generate a unique ID for the entity
44 entityId := uuid.New().String()
45
46 // Set a radius, in degrees, to simulate the entity moving in a circle
47 radiusDegrees := 0.1
48 count := 0.0
49 creationTime := time.Now().UTC()
50
51 // Continuously publish the entity
52 for {
53 latestTimestamp := time.Now().UTC()
54 ctx := context.Background()
55
56 // Update position
57 count += 0.1
58 t := math.Pi * count / 180.0
59
60 // Create entity to publish
61 entity := Lattice.Entity{
62 EntityID: &entityId,
63 Description: Lattice.String("Friendly drone asset"),
64 Aliases: &Lattice.Aliases{
65 Name: Lattice.String("Drone 1"),
66 },
67 IsLive: Lattice.Bool(true),
68 CreatedTime: Lattice.Time(creationTime),
69 ExpiryTime: Lattice.Time(latestTimestamp.Add(1 * time.Hour)),
70 Ontology: &Lattice.Ontology{
71 Template: Lattice.OntologyTemplateTemplateAsset.Ptr(),
72 PlatformType: Lattice.String("UAV"),
73 },
74 MilView: &Lattice.MilView{
75 Disposition: Lattice.MilViewDispositionDispositionFriendly.Ptr(),
76 Environment: Lattice.MilViewEnvironmentEnvironmentAir.Ptr(),
77 },
78 Location: &Lattice.Location{
79 Position: &Lattice.Position{
80 LatitudeDegrees: Lattice.Float64(50.91402185768586 + (radiusDegrees * math.Cos(t))),
81 LongitudeDegrees: Lattice.Float64(0.79203612077257 + (radiusDegrees * math.Sin(t))),
82 AltitudeAsfMeters: Lattice.Float64(1000),
83 },
84 },
85 Provenance: &Lattice.Provenance{
86 IntegrationName: Lattice.String("your_integration_name"),
87 DataType: Lattice.String("your_data_type"),
88 SourceUpdateTime: Lattice.Time(latestTimestamp),
89 },
90 Health: &Lattice.Health{
91 ConnectionStatus: Lattice.HealthConnectionStatusConnectionStatusOnline.Ptr(),
92 HealthStatus: Lattice.HealthHealthStatusHealthStatusHealthy.Ptr(),
93 // Live list of active alerts for the asset. Remove entries
94 // when the underlying condition clears; Lattice does not
95 // filter stale entries automatically.
96 ActiveAlerts: []*Lattice.Alert{},
97 UpdateTime: Lattice.Time(latestTimestamp),
98 },
99 // Declare the sensors carried by the asset. Each entry requires a
100 // stable sensor_id, a sensor_type, and at least one field of view
101 // so Lattice can render the sensor cone.
102 Sensors: &Lattice.Sensors{
103 Sensors: []*Lattice.Sensor{
104 {
105 SensorID: Lattice.String("camera-1"),
106 SensorType: Lattice.SensorSensorTypeSensorTypeCamera.Ptr(),
107 OperationalState: Lattice.SensorOperationalStateOperationalStateOperational.Ptr(),
108 FieldsOfView: []*Lattice.FieldOfView{
109 {
110 CenterRayPose: &Lattice.EntityManagerPose{
111 Orientation: &Lattice.Quaternion{
112 X: Lattice.Float64(0.0),
113 Y: Lattice.Float64(0.0),
114 Z: Lattice.Float64(0.0),
115 W: Lattice.Float64(1.0),
116 },
117 },
118 HorizontalFov: Lattice.Float64(1.047),
119 VerticalFov: Lattice.Float64(0.785),
120 Range: Lattice.Float64(2000.0),
121 Mode: Lattice.FieldOfViewModeSensorModeSearch.Ptr(),
122 },
123 },
124 },
125 },
126 },
127 TaskCatalog: &Lattice.TaskCatalog{
128 TaskDefinitions: []*Lattice.TaskDefinition{
129 {TaskSpecificationURL: Lattice.String("type.googleapis.com/anduril.tasks.v2.VisualId")},
130 {TaskSpecificationURL: Lattice.String("type.googleapis.com/anduril.tasks.v2.Investigate")},
131 },
132 },
133 }
134
135 // Publish the entity
136 _, err := LatticeClient.Entities.PublishEntity(ctx, &entity)
137
138 // Handle errors
139 if err != nil {
140 fmt.Printf("Error publishing entity: %v\n", err)
141 } else {
142 fmt.Println("Publishing asset")
143 }
144
145 // Wait before next request
146 time.Sleep(1 * time.Second)
147 }
148}

For detailed guidance on entity publishing patterns and best practices, see Publish entities.

Streaming entities

Both protocols support server-side streaming for consuming entity updates, with different filtering capabilities.

gRPC: Advanced filtering

Use StreamEntityComponents when you need complex filtering logic to receive only relevant entities. This API offers more robust filtering capabilities, letting you specify filter criteria for more fine-tuned streaming.

1// This Go example is compatible with artifacts generated using
2// the following grpc/go plugin: https://buf.build/anduril/lattice-sdk/sdks/main:grpc/go
3package main
4
5import (
6 "context"
7 "fmt"
8 "io"
9 "log"
10 "os"
11
12 "buf.build/gen/go/anduril/lattice-sdk/grpc/go/anduril/entitymanager/v1/entitymanagerv1grpc"
13 entitymanagerv1 "buf.build/gen/go/anduril/lattice-sdk/protocolbuffers/go/anduril/entitymanager/v1"
14 "google.golang.org/grpc"
15 "google.golang.org/grpc/credentials"
16)
17
18func main() {
19 ctx := context.Background()
20
21 clientID := os.Getenv("LATTICE_CLIENT_ID")
22 clientSecret := os.Getenv("LATTICE_CLIENT_SECRET")
23 latticeEndpoint := os.Getenv("LATTICE_ENDPOINT")
24 sandboxesToken := os.Getenv("SANDBOXES_TOKEN")
25
26 if latticeEndpoint == "" || clientSecret == "" || clientID == "" || sandboxesToken == "" {
27 log.Fatalf("Missing required environment variables")
28 }
29 auth := &ClientCredentialsAuth{
30 ClientID: clientID,
31 ClientSecret: clientSecret,
32 SandboxesToken: sandboxesToken,
33 Endpoint: fmt.Sprintf("https://%s/api/v1/oauth/token", latticeEndpoint),
34 }
35
36 opts := []grpc.DialOption{
37 grpc.WithTransportCredentials(credentials.NewClientTLSFromCert(nil, "")),
38 grpc.WithPerRPCCredentials(auth),
39 }
40 conn, err := grpc.NewClient(latticeEndpoint, opts...)
41
42 if err != nil {
43 log.Fatalf("Did not connect: %v", err)
44 }
45 defer conn.Close()
46
47 client := entitymanagerv1grpc.NewEntityManagerAPIClient(conn)
48
49 stream, err := client.StreamEntityComponents(ctx, &entitymanagerv1.StreamEntityComponentsRequest{
50 ComponentsToInclude: []string{"aliases", "location"},
51 })
52 if err != nil {
53 log.Fatalf("Error creating stream: %v", err)
54 }
55
56 log.Println("Starting to receive stream data...")
57 for {
58 response, err := stream.Recv()
59 if err == io.EOF {
60 // End of stream
61 log.Println("End of stream reached.")
62 break
63 }
64 if err != nil {
65 log.Fatalf("Error receiving stream data: %v", err)
66 }
67
68 entity := response.GetEntityEvent().GetEntity()
69 if position := entity.GetLocation().GetPosition(); position != nil {
70 log.Printf("Entity %s at location: %f, %f",
71 entity.EntityId,
72 position.LatitudeDegrees,
73 position.LongitudeDegrees,
74 )
75 }
76 }
77}

REST: Component-based filtering

Use StreamEntities for server-side streaming over HTTP with component-based filtering. This API filters entities based on the presence of specific components, which is sufficient for most integration scenarios where you need entities with particular data.

Go
1package main
2
3import (
4 "context"
5 "errors"
6 "fmt"
7 "io"
8 "log"
9 "net/http"
10 "os"
11
12 Lattice "github.com/anduril/lattice-sdk-go/v4"
13 "github.com/anduril/lattice-sdk-go/v4/client"
14 "github.com/anduril/lattice-sdk-go/v4/option"
15)
16
17func main() {
18 ctx, cancel := context.WithCancel(context.Background())
19 defer cancel()
20
21 latticeEndpoint := os.Getenv("LATTICE_ENDPOINT")
22 clientSecret := os.Getenv("LATTICE_CLIENT_SECRET")
23 clientId := os.Getenv("LATTICE_CLIENT_ID")
24 sandboxesToken := os.Getenv("SANDBOXES_TOKEN")
25
26 if latticeEndpoint == "" || clientId == "" || clientSecret == "" || sandboxesToken == "" {
27 log.Fatal("Required environment variables not set.")
28 }
29
30 headers := http.Header{}
31 headers.Add("Anduril-Sandbox-Authorization", fmt.Sprintf("Bearer %s", sandboxesToken))
32
33 latticeClient := client.NewClient(
34 option.WithClientCredentials(clientId, clientSecret),
35 option.WithBaseURL(fmt.Sprintf("https://%s", latticeEndpoint)),
36 option.WithHTTPHeader(headers),
37 )
38
39 // Create the entity stream.
40 stream, err := latticeClient.Entities.StreamEntities(ctx, &Lattice.EntityStreamRequest{
41 PreExistingOnly: Lattice.Bool(false),
42 // Define a list of components to control which entities are fetched.
43 // If set, Lattice streams only entities with the components you provide.
44 ComponentsToInclude: []string{"aliases", "location_uncertainty"},
45 })
46 if err != nil {
47 log.Fatalf("Failed to create entity stream: %v", err)
48 }
49 defer stream.Close()
50
51 for {
52 select {
53 case <-ctx.Done():
54 log.Printf("Context canceled: %v", ctx.Err())
55 return
56 default:
57 // Continue processing
58 }
59 message, err := stream.Recv()
60
61 // Handle stream completion
62 if errors.Is(err, io.EOF) {
63 log.Println("Stream completed successfully.")
64 return
65 }
66
67 if err != nil {
68 log.Printf("Error receiving message: %v", err)
69 continue
70 }
71
72 // Process the event based whether it is a heartbeat or entity event.
73 switch message.Event {
74 case "heartbeat":
75 timestamp := *message.Heartbeat.Timestamp
76 log.Printf("Heartbeat: %s", timestamp)
77 case "entity":
78 log.Printf("Entity: %s", *message.Entity.Entity.Aliases.Name)
79 default:
80 log.Printf("Unknown event type: %s", message.Event)
81 }
82 }
83}

For more information on streaming patterns and filtering strategies, see Watch entities.

Decision guide

Use this three-step framework to guide your protocol choice:

1

When to use gRPC

Choose gRPC when your integration prioritizes performance and bandwidth efficiency:

  • Bandwidth-constrained networks: Tactical networks, satellite links, or environments where data transmission costs matter use gRPC.
  • High-throughput scenarios: Integrations that publishing hundreds of entity updates rapidly use gRPC.
  • Specialized languages: Integrations written in Rust, C++, or other languages beyond the REST SDK use gRPC bindings.
  • Custom reliability logic: Integrations that need more control over retry classification, backoff, and error handling implement it directly in their integration, since the gRPC SDKs ship no retry layer of their own.
Scenario

An autonomous drone fleet publishes sensor data and location updates at 10 Hz per vehicle. With 50 drones, you’re sending 500 entity updates per second. gRPC’s binary encoding reduces each payload by 30-50% compared to JSON, significantly decreasing bandwidth requirements.

2

When to use REST

Choose REST when your integration prioritizes development velocity and ecosystem compatibility:

  • Web applications: Dashboards, command and control interfaces, or browser-based tools use REST
  • Low-frequency operations: Periodic polling, manual workflows, or asynchronous task creation use REST
  • Objects API access: Services that manage files and binary data in Lattice use REST to integrate with the Objects API.
  • Built-in reliability: Integrations that want sensible retry defaults for transient server errors without writing a retry layer benefit from the REST SDK’s automatic retries on 5xx, 408, 409, and 429 responses.
Scenario

A command and control web dashboard queries Lattice every 5 seconds to display current entity positions. The interface creates tasks when operators interact with the UI. REST’s simplicity accelerates development, and browser compatibility is essential.

3

When to use both

Many production systems combine both protocols to leverage their respective strengths:

  • Fleet management platforms: Hardware components use gRPC for telemetry, while web interfaces use REST for visualization.
  • Multi-component systems: Edge devices publish updates using gRPC, and cloud services consume the data using REST.
  • Objects integration: Core entity, and tasking operations use gRPC, and file management is implemented in REST.
Scenario

A robotics platform has autonomous ground vehicles publishing position and sensor data via gRPC at 5 Hz. A React web application consumes this data via REST polling at 1 Hz for operator display. Mission plans are uploaded as files through the REST Objects API, then referenced in tasks sent to the robots.

What’s next

  • Review Authentication patterns for both protocols.
  • Explore the REST API reference or gRPC API reference.
  • Check Connect to offline environments for self-signed certificate configuration.
  • Learn how to Retry connections with a modular utility that applies to both REST and gRPC.