Reference
All classes live under Tomaj\NetteApi.
Core
| Class | What it does | Guide |
|---|---|---|
ApiDecider | registry of endpoints: addApi(), getApi(), getApis(), enableGlobalPreflight() | Architecture |
Api | one registered endpoint: endpoint, handler, authorization, rate limit | Architecture |
ApiHolder | used inside ApiDecider: how it stores an endpoint before its handler is created; the handler can still be a class or service name | ApiDecider |
EndpointIdentifier / EndpointInterface | method, version, package, action | Handlers |
Presenters\ApiPresenter | runs a request step by step | ApiPresenter pipeline |
DI\NetteApiExtension | registers the services and endpoints from the api: neon section (4.0.0) | DI extension |
Attribute\Get, Post, Put, Patch, Delete, Endpoint | endpoint attributes on a handler class (4.0.0) | Attribute endpoints |
Attribute\Authorization, Attribute\RateLimit | authorization and rate limit of the attribute endpoints of a class (4.0.0) | Attribute endpoints |
DI\EndpointDefinition | one endpoint for NetteApiExtension::addEndpoint() from another extension (4.0.0) | DI extension |
Handlers
| Class | What it does | Guide |
|---|---|---|
Handlers\ApiHandlerInterface, BaseHandler | your endpoints | Handlers |
Handlers\OpenApiHandler | OpenAPI 3.0 document | OpenAPI |
Handlers\ApiListingHandler | JSON list of the endpoints in its own version | Handlers |
Handlers\AlwaysOkHandler, EchoHandler | health check and test endpoints | Handlers |
Handlers\DefaultHandler | 404 Unknown api endpoint | Architecture |
Handlers\CorsPreflightHandler(Interface) | answers OPTIONS | CORS |
Params and validation
| Class | What it does | Guide |
|---|---|---|
Params\GetInputParam, PostInputParam, PutInputParam, CookieInputParam, FileInputParam, RawInputParam, JsonInputParam | one input each | Params |
Params\InputParam, ParamInterface, ParamsProcessor | the base class and the processing | Params |
Validation\InputValidator, JsonSchemaValidator, InputType (enum) | value checks | Params |
ValidationResult\ValidationResult(Interface) | the result of a check | Params |
Responses and outputs
| Class | What it does | Guide |
|---|---|---|
Response\ResponseInterface | what every response implements | Outputs |
Response\JsonApiResponse, TextApiResponse, XmlApiResponse, RedirectResponse | what handle() returns | Outputs |
Output\JsonOutput, RedirectOutput, AbstractOutput, OutputInterface | declared outputs | Outputs |
Output\Configurator\ConfiguratorInterface, EnvConfigurator, QueryConfigurator, DebuggerConfigurator | when to check outputs and show details | Outputs |
Error\ErrorHandlerInterface, DefaultErrorHandler | error responses | Error handling |
Error\ProblemDetailsErrorHandler, NegotiatingErrorHandler, ProblemDetails, Response\ProblemDetailsResponse | RFC 9457 errors, 4.0.0 | Problem Details |
Security
| Class | What it does | Guide |
|---|---|---|
Authorization\NoAuthorization, BearerTokenAuthorization, HeaderApiKeyAuthentication, QueryApiKeyAuthentication, CookieApiKeyAuthentication, BasicAuthentication | built-in authorization | Authorization |
Authorization\ApiAuthorizationInterface, TokenAuthorization | your own | Authorization |
Misc\TokenRepositoryInterface, StaticTokenRepository | tokens and their IPs | Authorization |
Misc\IpDetectorInterface, IpDetector, StaticIpDetector | the client IP | Authorization |
RateLimit\RateLimiterInterface, RateLimitResult, FixedWindowLimiter, SlidingWindowLimiter, TokenBucketLimiter, AlgorithmLimiter, RateLimiterChain, NoRateLimit | rate limiting (4.0.0) | |
RateLimit\Algorithm\RateLimitAlgorithmInterface, Storage\RateLimitStorageInterface, Key\RateLimitKeyInterface, Redis\RedisClientInterface, Storage\KeyValueStorage, Authorization\AuthorizationIdentityInterface | own algorithms, storages, keys, Redis clients and the identity of a caller (4.0.0) | |
RateLimit\RateLimitInterface, RateLimitResponse | the 3.x rate limit, deprecated, removed in 5.0 | Rate limiting |
Logging, links and console
| Class | What it does | Guide |
|---|---|---|
Logger\ApiLoggerInterface | request log | Logging |
Link\ApiLink, ApiLinkExtension, ApiLinkNode | URLs and the {apiLink} tag | Links |
Component\ApiListingControl, ApiConsoleControl, ApiConsoleFormFactoryInterface, DefaultApiConsoleFormFactory | web console | Web console |
Misc\ConsoleRequest, ConsoleResponse | the console's cURL request | Web console |
Misc\CorsOriginAllowlist | internal (@internal), used by setCorsAllowedOrigins(); may change in 4.0 | CORS |
Misc\OpenApiTransform | helpers for OpenAPI | OpenAPI |
FAQ
Which classes are final?
Presenters\ApiPresenter, Error\DefaultErrorHandler, the Latte classes Link\ApiLinkExtension and Link\ApiLinkNode, and the internal Misc\CorsOriginAllowlist are final; wrap them instead of extending. See Error handling.
Since 4.0 these are final too: Api, ApiHolder, EndpointIdentifier, Authorization\NoAuthorization, RateLimit\NoRateLimit, RateLimit\RateLimitResponse, Misc\IpDetector, Misc\StaticIpDetector, Misc\StaticTokenRepository, Misc\ConsoleRequest, Misc\ConsoleResponse, Misc\OpenApiTransform, Params\ParamsProcessor, Validation\InputValidator, Validation\JsonSchemaValidator, ValidationResult\ValidationResult, the output configurators DebuggerConfigurator, EnvConfigurator and QueryConfigurator, and OpenApi\SchemaRegistry and OpenApi\EndpointFilter. Implement the matching interface (IpDetectorInterface, TokenRepositoryInterface, ApiAuthorizationInterface, RateLimitInterface, ConfiguratorInterface, …) instead of extending them. Handlers, params, outputs, responses, authorizations, the OpenAPI builders, ApiDecider, ApiLink, the console components and DefaultApiConsoleFormFactory stay open for extension. The exception is Handlers\DefaultHandler, which is final; customize the 404 in the error handler's handleNotFound().
Where are the method signatures?
In the source on GitHub; the guide pages show the ones you use.
Which classes are deprecated?
None. setExample() on params and outputs was removed in 4.0; use addExample(). The old StaticBearerTokenRepository and BearerTokenRepositoryInterface were removed in 4.0. Use StaticTokenRepository and TokenRepositoryInterface, which work the same way.
Is there a DI extension?
Yes, since 4.0.0: DI\NetteApiExtension configures the whole API from one api: neon section, see DI extension. Registering plain services in NEON, as in Getting started, keeps working.
What does a full project look like?
See the examples.