About serverpod-endpoints
serverpod-endpoints is a skill for developers building Serverpod endpoints and server APIs. It covers defining endpoint methods, generating client RPC interfaces, and preserving API backward compatibility.
Key features
- 01Define endpoint methods and streaming responses
- 02Generate client RPC interfaces
- 03Use Session for database and cache access
- 04Control endpoint and method code generation
- 05Manage inheritance and version compatibility
Use cases
- 01Add server methods for client calls
- 02Implement real-time streaming interfaces
- 03Access databases or caches during requests
- 04Preserve compatibility for older clients during API changes
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ serverpod/ serverpod --skill serverpod-endpointsAfter installing, type/serverpod-endpointsin Claude Code to confirm it loaded.
Details
From the project READMEServerpod Endpoints
Extend Endpoint with instance methods; first parameter is Session, return Future<T> (or Stream<T> for real-time data streaming). Place anywhere under server lib/. The Serverpod runner regenerates the client on save; without one, run serverpod generate.
Defining an endpoint
import 'package:serverpod/serverpod.dart';
class ExampleEndpoint extends Endpoint {
Future<String> hello(Session session, String name) async {
return 'Hello $name';
}
}
Client name is derived from the class name minus Endpoint suffix (ExampleEndpoint → example).
Calling from the client
var result = await client.example.hello('World');
Client initialized once:
final serverUrl = await getServerUrl();
client = Client(serverUrl)
// When using Flutter:
..connectivityMonitor = FlutterConnectivityMonitor()
// When using authentication:
..authSessionManager = FlutterAuthSessionManager();
Supported parameter and return types
- Primitives:
bool,int,double,String Duration,DateTime(UTC),ByteData,UuidValue,Uri,BigInt- Generated serializable models (from
.spy.yaml) List,Map,Set,Record— strictly typed with the above
Default request size limit: 512 kB. Change with maxRequestSize in config. Use the file upload API for large files.
Session
Provides: database access (session.db, Model.db), cache (session.caches), logging, request context. Do not capture for use after the request completes.
Excluding from code generation
- Entire endpoint:
@doNotGenerateon the class. - Single method:
@doNotGenerateon the method.
Endpoint inheritance
- Concrete extends concrete: Client gets both; subclass exposes own + inherited methods.
- Abstract endpoint: Not registered; only concrete subclass is exposed.
- Parent with
@doNotGenerate: Parent hidden; subclass gets a client implementing inherited methods.
Overriding is allowed: same signature, different behavior, client code unchanged.
Backward compatibility
Older app versions may still call your server. Do not rename parameters (REST API passes by name). Do not delete methods, add required parameters, or change signatures; add new methods or optional named parameters instead.
When you must break an endpoint's API, create a versioned endpoint:
@Deprecated('Use TeamV2Endpoint instead')
class TeamEndpoint extends Endpoint {
Future<TeamInfo> join(Session session) async { /* ... */ }
}
class TeamV2Endpoint extends TeamEndpoint {
@override
@doNotGenerate
Future<TeamInfo> join(Session session) async => throw UnimplementedError();
Future<NewTeamInfo> joinWithCode(Session session, String invitationCode) async {
// New implementation
}
}
Old clients use client.team.join(); new clients use client.teamV2.joinWithCode(...). Remove the old endpoint after all clients upgrade. Alternative: extract logic into a helper class callable from both endpoints.