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
DI\NetteApiExtensionregisters the services and endpoints from the api: neon section (4.0.0)DI extension
Attribute\Get, Post, Put, Patch, Delete, Endpointendpoint attributes on a handler class (4.0.0)Attribute endpoints
Attribute\Authorization, Attribute\RateLimitauthorization and rate limit of the attribute endpoints of a class (4.0.0)Attribute endpoints
DI\EndpointDefinitionone endpoint for NetteApiExtension::addEndpoint() from another extension (4.0.0)DI extension

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
Error\ProblemDetailsErrorHandler, NegotiatingErrorHandler, ProblemDetails, Response\ProblemDetailsResponseRFC 9457 errors, 4.0.0Problem Details

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\RateLimiterInterface, RateLimitResult, FixedWindowLimiter, SlidingWindowLimiter, TokenBucketLimiter, AlgorithmLimiter, RateLimiterChain, NoRateLimitrate limiting (4.0.0)
RateLimit\Algorithm\RateLimitAlgorithmInterface, Storage\RateLimitStorageInterface, Key\RateLimitKeyInterface, Redis\RedisClientInterface, Storage\KeyValueStorage, Authorization\AuthorizationIdentityInterfaceown algorithms, storages, keys, Redis clients and the identity of a caller (4.0.0)
RateLimit\RateLimitInterface, RateLimitResponsethe 3.x rate limit, deprecated, removed in 5.0Rate 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. 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.

Released under the MIT License.