Endpoint Configuration
Endpoints are the URLs that KrakenD exposes to clients. Each endpoint can aggregate data from one or more backends, apply transformations, and add middleware functionality.Endpoint Structure
Basic endpoint structure:Endpoint Properties
| Property | Type | Required | Description |
|---|---|---|---|
endpoint | string | Yes | URL pattern exposed by the gateway |
method | string | No | HTTP method (defaults to GET) |
backend | array | Yes | List of backend services to call |
cache_ttl | string | No | Override global cache TTL for this endpoint |
concurrent_calls | number | No | Number of concurrent calls to the same backend |
extra_config | object | No | Additional middleware configuration |
Backend Configuration
Backends define the upstream services that KrakenD calls to fetch data:Backend Properties
| Property | Type | Description |
|---|---|---|
host | array | Backend host URLs |
url_pattern | string | URL path with optional parameters |
allow | array | Whitelist of fields to include in response |
mapping | object | Rename fields in the response |
group | string | Wrap response in a named object |
is_collection | boolean | Indicates if response is an array |
target | string | Extract data from a specific field |
encoding | string | Response encoding (json, safejson, xml, etc.) |
extra_config | object | Backend-specific middleware |
Real-World Examples
Example 1: Data Aggregation and Transformation
This endpoint aggregates GitHub user data and repositories:- Aggregation: Calls two different GitHub API endpoints
- Filtering: Uses
allowto whitelist specific fields - Mapping: Renames
blogtowebsite - Grouping: Wraps user data in a
userobject - Collections: Properly handles array responses
Example 2: GraphQL to REST
This endpoint transforms a GraphQL query into a REST API:- GraphQL integration: Converts GraphQL to REST
- Target extraction: Uses
targetto extract nested data - Variable injection: Passes URL parameters to GraphQL query
Example 3: Sequential Calls
This endpoint makes sequential calls, using data from the first response in the second request:- Sequential proxy: Enables sequential calls with
"sequential": true - Response injection: Uses
{resp0_destination_id}from first response
Extra Config Options
Rate Limiting
Endpoint-level rate limiting:JWT Validation
Protect endpoints with JWT token validation:Response Manipulation
Use flatmap filter to transform response data:Backend Caching
Cache backend responses based on HTTP headers:Mocked Responses
Return static data without calling backends:Method Restrictions
By default, endpoints accept GET requests. To restrict methods:Concurrent Requests
Make multiple concurrent calls to the same backend:Next Steps
- Learn about flexible configuration templates
- Configure environment-specific settings
- View the main configuration file structure