PHPackages                             faktore/fe-json-api-utilities - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. faktore/fe-json-api-utilities

ActiveTypo3-cms-extension[Utility &amp; Helpers](/categories/utility)

faktore/fe-json-api-utilities
=============================

Faktor E JSON Utilities

v1.4.3(10mo ago)05.5k↓33.3%GPL-2.0+PHPPHP &gt;= 8.1.0, &lt;= 8.4.99

Since Sep 8Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/faktore-git/fe-json-api-utilities)[ Packagist](https://packagist.org/packages/faktore/fe-json-api-utilities)[ Docs](https://www.faktor-e.de/)[ RSS](/packages/faktore-fe-json-api-utilities/feed)WikiDiscussions production Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (6)Used By (0)

Faktor E JSON API Utilites package
==================================

[](#faktor-e-json-api-utilites-package)

Purpose
-------

[](#purpose)

This TYPO3 extension helps extension authors with setting up a simple JSON-based API. It provides some helper methods and classes that can:

- parse the JSON request data
- build, enrich and send a JSON response
- transform TYPO3-specific models and object storages into structured arrays

Motivation
----------

[](#motivation)

Several of our recent projects have demands for widgets and components implemented in a frontend framework such as Vue. To effectively utilize these frontend components, communication with a TYPO3 backend is usually done via JSON requests &amp; responses.

Since these are usually very isolated widgets that don't require a fully fledged (headless) API, extensions like TYPO3 headless or t3api are very impressive, but they would be overkill in our use context. Instead we decided to go with this lightweight, self-maintainable solution.

Usage
-----

[](#usage)

### JSON Requests

[](#json-requests)

If you want to handle POST data from a request, create a new instance and make sure to use the `parseJsonBody()` and `getDecodedData()` methods. Usage is very basic - Example in an Extbase Controller context:

```
use Faktore\FeJsonApiUtilities\Utility\JsonRequestUtility;

class EventsJsonApiController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
    protected JsonRequestUtility $jsonRequestUtility;

    // constructor with dependency injection
    public function __construct(JsonRequestUtility $jsonRequestUtility)
    {
        $this->jsonRequestUtility = $jsonRequestUtility;
    }

    public function searchAction(): ResponseInterface
    {
        // initialize the request utility
        $this->jsonRequestUtility->initialize();

        // get JSON POST data and store it in an array
        $postData = $this->jsonRequestUtility->parseJsonBody()->getDecodedData();

        // ... implement your handling of data
    }
}

$postData = $this->jsonRequestUtility->parseJsonBody()->getDecodedData();
```

### JSON Responses

[](#json-responses)

Responses can be built with the JsonResponseUtility. You can add response data (in array format), keep track of errors and success status, all in this object.

```
use Faktore\FeJsonApiUtilities\Utility\JsonResponseUtility;

class EventsJsonApiController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
{
    protected JsonResponseUtility $jsonResponseUtility;

    // constructor with dependency injection
    public function __construct(JsonResponseUtility $jsonResponseUtility)
    {
        $this->jsonResponseUtility = $jsonResponseUtility;
    }

    public function searchAction(): ResponseInterface
    {
        // ... implement your handling of data

        // for example get events for a calendar using a repository
        // $events = $this->eventRepository->findByDemand($filterDemand);

        // convert your result to array first.
        // Implementing the convertToArray method will be your responsibility.
        // The ConvertUtilities provide a lot of useful functions to help with that.
        $events = $this->convertToArray($events);

        if ($events) {
            // assign data to the response
            $this->jsonResponseUtility->assignData('events', $output);
            // keep track of success status for the response
            $this->jsonResponseUtility->setSuccess(true);
        } else {
            // add an error
            $this->jsonResponseUtility->addError('no events found');
            // keep track of success status for the response
            $this->jsonResponseUtility->setSuccess(false);
        }

        // ... do more checks and validations to add errors if necessary.

        // Lastly, make sure to return a PSR-compliant response. The JsonResponse works just fine in Controller context.
        return $this->jsonResponse(
            $this->jsonResponseUtility->getOutput()
        )->withStatus(200);
    }
}
```

### Object &amp; Property conversion utilities

[](#object--property-conversion-utilities)

Here is where you have a ConvertUtility class that can do a lot of magic for you.

#### Flattening FAL objects or FAL Storages

[](#flattening-fal-objects-or-fal-storages)

Use `ConvertUtility::flattenFileStorage($imageFileStorage, $properties, $useAbsoluteUrl)`.

Note that in addition to the provided properties, every file in the storage will always yield the key 'publicUrl':

**New in 1.4.0**: Added a third optional parameter to flattenFileStorage. If true, the 'publicUrl' will be made absolute.

```
use Faktore\FeJsonApiUtilities\Utility\ConvertUtility;

// ...

$result = [
    'title' => $event->getTitle() ?? '',
    // get FAL storages flattened
    'images' => ConvertUtility::flattenFileStorage(
            $event->getImages(),
            ['title', 'description', 'alternative'],
            true
        ) ?? '',
];

/* will return:
 * [
 *   'title' => 'foo'
 *   'images' => [
 *     0 => [
 *       'title' => bar,
 *       'publicUrl' => 'https://my.domain.com/puppies.jpg'
 *   ]
 * ]
 */
```

#### Flattening object storages

[](#flattening-object-storages)

this will utilize the propertymapper to access gettable properties of an object

```
use Faktore\FeJsonApiUtilities\Utility\ConvertUtility;

// ...

$result = ConvertUtility::flattenObjectStorage(
            $this->getCategories(),
            ['title', 'uid']
        );

/* $result will contain:
 * [
 *   0 => [
 *     'title' => 'foo',
 *     'uid' => 1234,
 *   ],
 *   1 => [
 *     'title' => 'bar',
 *     'uid' => 5678,
 *   ]
 * ]
 */
```

#### Others

[](#others)

There are a few other utility methods for converting your extbase models to arrays. Feel free to explore!

Disclaimer
----------

[](#disclaimer)

This utility library is very limited in scope, and it does not provide anything close to a full API for you. Making use of it in a real-world TYPO3 application will still require some work on your processing of requests and responses.

**Important:** Use at your own risk. There may be bugs. Remember to handle matters of security in your own code.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance55

Moderate activity, may be stable

Popularity22

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 58.3% 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

Every ~171 days

Total

5

Last Release

300d ago

PHP version history (2 changes)1.3.0PHP &gt;= 8.1.0, &lt;= 8.2.99

v1.4.2PHP &gt;= 8.1.0, &lt;= 8.4.99

### Community

Maintainers

![](https://www.gravatar.com/avatar/79a2502779c424057772dea1dcc6e3ee5f0b75f794a60ba2b977d23aa300b6ec?d=identicon)[faktor-e](/maintainers/faktor-e)

---

Top Contributors

[![larsgoo](https://avatars.githubusercontent.com/u/36926021?v=4)](https://github.com/larsgoo "larsgoo (7 commits)")[![fe-mohmand](https://avatars.githubusercontent.com/u/131554515?v=4)](https://github.com/fe-mohmand "fe-mohmand (3 commits)")[![garvinhicking](https://avatars.githubusercontent.com/u/273326?v=4)](https://github.com/garvinhicking "garvinhicking (2 commits)")

---

Tags

TYPO3 CMSFaktor E

### Embed Badge

![Health badge](/badges/faktore-fe-json-api-utilities/health.svg)

```
[![Health](https://phpackages.com/badges/faktore-fe-json-api-utilities/health.svg)](https://phpackages.com/packages/faktore-fe-json-api-utilities)
```

###  Alternatives

[derhansen/sf_event_mgt

Configurable event management and registration extension based on ExtBase and Fluid

64313.9k6](/packages/derhansen-sf-event-mgt)[brotkrueml/schema

Embedding schema.org vocabulary - API and view helpers for schema.org markup

33584.6k13](/packages/brotkrueml-schema)[causal/extractor

This extension detects and extracts metadata (EXIF / IPTC / XMP / ...) from potentially thousand different file types (such as MS Word/Powerpoint/Excel documents, PDF and images) and bring them automatically and natively to TYPO3 when uploading assets. Works with built-in PHP functions but takes advantage of Apache Tika and other external tools for enhanced metadata extraction.

16244.5k](/packages/causal-extractor)[typo3-themes/themes

TYPO3 THEMES

3642.6k2](/packages/typo3-themes-themes)[jweiland/events2

Events 2 - Create single and recurring events

2062.4k2](/packages/jweiland-events2)[mfd/ai-filemetadata

Automatically generates FAL metadata for files by means of public LLMs

1142.1k](/packages/mfd-ai-filemetadata)

PHPackages © 2026

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