Skip to content

Reference ​

All classes live under Tomaj\NetteApi.

Core ​

ClassWhat it doesGuide
ApiDeciderregistry of endpoints: addApi(), getApi(), getApis(), enableGlobalPreflight()Architecture
Apione registered endpoint: endpoint, handler, authorization, rate limitArchitecture
ApiHolderused inside ApiDecider: how it stores an endpoint before its handler is created; the handler can still be a class or service nameApiDecider
EndpointIdentifier / EndpointInterfacemethod, version, package, actionHandlers
Presenters\ApiPresenterruns a request step by stepApiPresenter pipeline

Handlers ​

ClassWhat it doesGuide
Handlers\ApiHandlerInterface, BaseHandleryour endpointsHandlers
Handlers\OpenApiHandlerOpenAPI 3.0 documentOpenAPI
Handlers\ApiListingHandlerJSON list of the endpoints in its own versionHandlers
Handlers\AlwaysOkHandler, EchoHandlerhealth check and test endpointsHandlers
Handlers\DefaultHandler404 Unknown api endpointArchitecture
Handlers\CorsPreflightHandler(Interface)answers OPTIONSCORS

Params and validation ​

ClassWhat it doesGuide
Params\GetInputParam, PostInputParam, PutInputParam, CookieInputParam, FileInputParam, RawInputParam, JsonInputParamone input eachParams
Params\InputParam, ParamInterface, ParamsProcessorthe base class and the processingParams
Validation\InputValidator, JsonSchemaValidator, InputType (enum)value checksParams
ValidationResult\ValidationResult(Interface)the result of a checkParams

Responses and outputs ​

ClassWhat it doesGuide
Response\ResponseInterfacewhat every response implementsOutputs
Response\JsonApiResponse, TextApiResponse, XmlApiResponse, RedirectResponsewhat handle() returnsOutputs
Output\JsonOutput, RedirectOutput, AbstractOutput, OutputInterfacedeclared outputsOutputs
Output\Configurator\ConfiguratorInterface, EnvConfigurator, QueryConfigurator, DebuggerConfiguratorwhen to check outputs and show detailsOutputs
Error\ErrorHandlerInterface, DefaultErrorHandlererror responsesError handling

Security ​

ClassWhat it doesGuide
Authorization\NoAuthorization, BearerTokenAuthorization, HeaderApiKeyAuthentication, QueryApiKeyAuthentication, CookieApiKeyAuthentication, BasicAuthenticationbuilt-in authorizationAuthorization
Authorization\ApiAuthorizationInterface, TokenAuthorizationyour ownAuthorization
Misc\TokenRepositoryInterface, StaticTokenRepositorytokens and their IPsAuthorization
Misc\IpDetectorInterface, IpDetector, StaticIpDetectorthe client IPAuthorization
RateLimit\RateLimitInterface, RateLimitResponse, NoRateLimitrate limitingRate limiting
ClassWhat it doesGuide
Logger\ApiLoggerInterfacerequest logLogging
Link\ApiLink, ApiLinkExtension, ApiLinkNodeURLs and the {apiLink} tagLinks
Component\ApiListingControl, ApiConsoleControl, ApiConsoleFormFactoryInterface, DefaultApiConsoleFormFactoryweb consoleWeb console
Misc\ConsoleRequest, ConsoleResponsethe console's cURL requestWeb console
Misc\CorsOriginAllowlistinternal (@internal), used by setCorsAllowedOrigins(); may change in 4.0CORS
Misc\OpenApiTransformhelpers for OpenAPIOpenAPI

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.

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? ​

No, everything is registered as plain services in NEON, see Getting started.

What does a full project look like? ​

See the examples.

Released under the MIT License.