Skip to main content
Services are the heart of Feathers. They provide a uniform interface for accessing and manipulating data, whether from a database, API, or any other source.

Service Interface

A Feathers service implements up to six standard methods:
Services are not required to implement all methods. Implement only what your use case needs.

Standard Methods

find(params)

Retrieve multiple records, optionally filtered and paginated:
service.ts:7-9

get(id, params)

Retrieve a single record by its unique identifier:
service.ts:9

create(data, params)

Create one or more new records:
service.ts:10
When creating multiple records, the service must return an array of created records.

update(id, data, params)

Replace a record entirely (PUT semantics):
service.ts:11

patch(id, data, params)

Partially update one or multiple records:
service.ts:12

remove(id, params)

Delete one or multiple records:
service.ts:13

Params Object

The params parameter provides context for service method calls:
declarations.ts:330-335

Custom Methods

Define custom service methods beyond the standard CRUD operations:
service.ts:15,26-28
Custom methods must be explicitly listed in the methods option to be available to external clients.

Protected Methods

Certain method names are reserved and cannot be used as custom methods:
service.ts:26-28

Lifecycle Hooks

setup(app, path)

Called when the application initializes:
declarations.ts:91

teardown(app, path)

Called when the application shuts down:
declarations.ts:93

Service Options

Configure services with options:
declarations.ts:26-44

Real-World Examples

Best Practices

  1. Validate input - Always validate data in hooks before processing
  2. Handle errors gracefully - Throw appropriate Feathers errors
  3. Return consistent shapes - Keep response formats predictable
  4. Use params for context - Pass authentication, user info via params
  5. Implement only needed methods - Don’t implement methods you don’t use
  6. Document custom methods - Make it clear what custom methods do
  7. Use TypeScript - Type your services for better developer experience

Next Steps

Hooks

Learn how to add middleware to service methods

Events

Understand real-time events from services