Install
SDK

Relic API clients

Generate typed Go or TypeScript clients of the Relic API from its protobuf definitions.

The Relic API is defined in protobuf under api/proto/relic/v1 and served with ConnectRPC. Any Connect or gRPC-Web client generated from those files can call it. gRPC clients need HTTP/2, which the server offers only when it serves HTTPS itself.

Go

The protos import google/api/annotations.proto from third_party/proto in the Relic repository. Copy api/proto and third_party/proto into your project and list both in buf.yaml:

version: v2
modules:
  - path: api/proto
  - path: third_party/proto

Generate code for api/proto with protoc-gen-go and protoc-gen-connect-go, pinned to the versions Relic generates its own code with. The generated code imports connectrpc.com/connect/v2 and the annotations from google.golang.org/genproto/googleapis/api:

# buf.gen.yaml
version: v2
managed:
  enabled: true
  disable:
    - path: google
  override:
    - file_option: go_package_prefix
      value: example.com/yourapp/gen
inputs:
  - directory: api/proto
plugins:
  - remote: buf.build/protocolbuffers/go:v1.36.12
    out: gen
    opt: paths=source_relative
  - remote: buf.build/connectrpc/go:v2.0.1
    out: gen
    opt: paths=source_relative

Call the API with an access token. The base URL ends in /api, and connecthttp is connectrpc.com/connect/v2/connecthttp:

transport := connecthttp.NewTransport(http.DefaultClient, "https://relic.example.com/api")
client := relicv1connect.NewRepositoryServiceClient(connect.NewClient(transport))
ctx, call := connect.NewClientContext(ctx)
call.RequestHeader().Set("Authorization", "Bearer "+token)
resp, err := client.ListRepositories(ctx, &relicv1.ListRepositoriesRequest{})

TypeScript

Generate the client with protoc-gen-es and call it with @connectrpc/connect:

import { createClient } from '@connectrpc/connect'
import { createConnectTransport } from '@connectrpc/connect-node'
import { RepositoryService } from './gen/relic/v1/repository_pb'

const transport = createConnectTransport({
  baseUrl: 'https://relic.example.com/api',
  httpVersion: '1.1',
  interceptors: [next => req => { req.header.set('Authorization', `Bearer ${token}`); return next(req) }]
})
const repos = createClient(RepositoryService, transport)
const { repositories } = await repos.listRepositories({})

Errors, access and files

Errors are Connect codes, and each method declares who may call it (Authentication and access). Messages never carry file contents: use plain HTTP at /api/v1/files/<repo>/<path> (File contents). Without a generated client, call the REST routes in the API reference.