PHPackages                             causal/simple\_api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. causal/simple\_api

ActiveTypo3-cms-extension[API Development](/categories/api)

causal/simple\_api
==================

Service to route HTTP/REST requests to your own TYPO3 controllers.

1.0.0(9y ago)46002GPL-2.0+PHPPHP &gt;= 5.5.0, &lt;= 7.1.99

Since Apr 20Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/xperseguers/t3ext-simple_api)[ Packagist](https://packagist.org/packages/causal/simple_api)[ Docs](https://github.com/xperseguers/t3ext_simple_api)[ RSS](/packages/causal-simple-api/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (5)Used By (0)

Simple API for TYPO3
====================

[](#simple-api-for-typo3)

Service to route HTTP/REST requests to your own controllers.

**BEWARE:** This extension is expected to be used by TYPO3 developers and acts as a central hub to route requests to your own business logic.

Features
--------

[](#features)

- Support for authenticated method calls
- Support for localized calls (taking the language into account)
- Support for cached calls and transparent access to the TYPO3 caching framework within your API handler
- Support for gzip payload if header `HTTP_ACCEPT_ENCODING` is present and contains `gzip`
- Support for dynamically generating a documentation of your API
- Automatic flushing of cache entries when editing records in Backend (use `%` in the list of corresponding tags)

In addition, this supports dependency injection for your API handlers, you just need to use `@inject` or methods prefixed by `inject`, as well-known when programming with Extbase.

Difference with EXT:routing
---------------------------

[](#difference-with-extrouting)

Unlike [EXT:routing](https://github.com/xperseguers/t3ext-routing), this extension does not force you to map Extbase controller/actions to route segments but instead basically lets you register a "segment" (typically the first one) and then will simply route the whole request to a `handle()` method within your controller.

Registration of handlers
------------------------

[](#registration-of-handlers)

First of all you should add a dependency within your `ext_emconf.php` configuration file, either as a real constraint, or as a suggestion, depending on what you prefer:

```
$EM_CONF[$_EXTKEY] = [
    // snip
    'constraints' => [
        'depends' => [
            'php' => '5.5.0-7.1.99',
            'typo3' => '7.6.0-8.99.99',
        ],
        'conflicts' => [],
        'suggests' => [
            'simple_api' => '',
        ],
    ],
];

```

Then, within `ext_localconf.php`:

```
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['simple_api']['apiHandlers'][] = [
    'route' => '/some-route',
    'class' => \VENDOR\YourExt\Api\YourClass::class,
];

```

you may register a pattern instead of a fixed route:

```
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['simple_api']['apiPatternHandlers'][] = [
    'route' => '/members/\d+/history',
    'class' => \VENDOR\YourExt\Api\YourClass::class,
];

```

Your handler must extend `\Causal\SimpleApi\Controller\AbstractHandler`.

### Handler Keys

[](#handler-keys)

The registration array supports various keys:

- **route** \[*mandatory*\]: The route to register.
- **class** \[*mandatory*\]: The class handling requests to the corresponding route.
- **contentType** \[*optional*\]: Content type of the payload accepted by a POST request, will decode it automatically before invoking your handler.
- **methods** \[*optional*\]: The comma-separated list of HTTP methods accepted by the handler (e.g., "POST"). Defaults to no restrictions.
- **restricted** \[*optional*\]: Whether the API call expects an authenticated call (using `HTTP_X_AUTHORIZATION` header). If restricting access to part of your API, you **must** register a route with name `/authenticate` which will get the `HTTP_X_AUTHORIZATION` header, do something with it and return an array with following keys:

    - `success => true` (or `false`). Will be passed as `_authenticated` boolean flag to the API handler
    - Custom keys will be prefixed by `_` and passed as-is to the API handler (e.g., `user` will become `_user`)
    - Custom boolean flag `demo` may be used to specify that the authentication succeeded but with "demonstration" capabilities. This needs to be then handled in your API controller by checking, as expected, boolean flag parameter `_demo`.

    **Hint:** If `HTTP_X_AUTHORIZATION` header is present, the authentication will take place and your handler will be invoked regardless of the outcome of the call, if you did not explicitely marked your handler as "restricted".
- **deprecated** \[*optional*\]: Boolean flag to mark the corresponding route as deprecated in the documentation.

### Payload

[](#payload)

Following rules apply with the payload you return from your API handler:

- Payload is expected to be an array and will be returned as content-type `application/json`. If you want to return another content-type (such as an image), you should do it in your own API handler and `exit()` afterwards.
- If an exception is thrown, it is catched and encapsulated into a HTTP 500 error. The only exception is if exception `\Causal\SimpleApi\Exception\ForbiddenException` is thrown, it will throw a HTTP 403 error instead.
- If no handlers are found, a HTTP 404 error is returned.

Known Issues and Workaround
---------------------------

[](#known-issues-and-workaround)

- Extbase repositories may be used within your API handlers but you need to manually invoke method `includeTCA()` from the base class in order for the Extbase mapping to be available to returned objects. This call should typically be part of the `initialize()` method you can override in your handler and which is called before invoking `handle()`.

    **BEWARE:** If you don't properly include the TCA of your domain model, you may corrupt the Extbase datamap cache by storing incomplete mapping definition into the cache backend for `extbase_datamapfactory_datamap` (e.g., table `cf_extbase_datamapfactory_datamap` with out-of-the-box TYPO3 settings). In such case, you will need to flush that cache manually.

Installation
------------

[](#installation)

1. Clone this repository into `typo3conf/ext/simple_api`:

    ```
    cd /path/to/typo3conf/ext/
    git clone https://github.com/xperseguers/t3ext-simple_api.git simple_api

    ```

    Alternatively, you may load it via composer:

    ```
    composer require causal/simple_api

    ```
2. Go to Extension Manager and activate extension `simple_api`
3. Add a rewrite rule to your `.htaccess`. E.g.,

    ```
    RewriteRule ^api/(.*)$ /index.php?eID=simple_api&route=$1 [QSA,L]

    ```

    or, if you are using Nginx:

    ```
    rewrite ^/api/(.*)$ /index.php?eID=simple_api&route=$1 last;

    ```

    This will have the effect of using this extension for handling requests starting with `api/`.

**Hint:** If you need to support localization (`&L=`), then you should change the suggesting routing above to include the root page uid of your website (`&id=`). This is needed because localization mode and default language may differ in complex environments and thus cannot be inferred.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance61

Regular maintenance activity

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 96.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3362d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/646805?v=4)[Xavier Perseguers](/maintainers/xperseguers)[@xperseguers](https://github.com/xperseguers)

---

Top Contributors

[![xperseguers](https://avatars.githubusercontent.com/u/646805?v=4)](https://github.com/xperseguers "xperseguers (134 commits)")[![rubsilv](https://avatars.githubusercontent.com/u/39330651?v=4)](https://github.com/rubsilv "rubsilv (5 commits)")

---

Tags

apiTYPO3 CMS

### Embed Badge

![Health badge](/badges/causal-simple-api/health.svg)

```
[![Health](https://phpackages.com/badges/causal-simple-api/health.svg)](https://phpackages.com/packages/causal-simple-api)
```

###  Alternatives

[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

103519.9k53](/packages/friendsoftypo3-content-blocks)[hn/typo3-mcp-server

TYPO3 extension that provides a Model Context Protocol (MCP) server for interacting with TYPO3 pages and records

8523.4k1](/packages/hn-typo3-mcp-server)[pagemachine/searchable

TYPO3 extension to index and search content with Elasticsearch

1039.9k](/packages/pagemachine-searchable)[friendsoftypo3/interest

REST and CLI API for adding, updating, and deleting records in TYPO3. Tracks relations so records can be inserted in any order. Uses remote ID mapping so you don't have to keep track of what UID a record has gotten after import. Data is inserted using backend APIs as if a real human did it, so you can can inspect the record history and undo actions.

122.4k1](/packages/friendsoftypo3-interest)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
