PHPackages                             heimrichhannot/contao-api-bundle - 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. heimrichhannot/contao-api-bundle

ActiveContao-bundle[API Development](/categories/api)

heimrichhannot/contao-api-bundle
================================

A generic API with restricted access to provide access to 3rd party applications.

2.2.6(2y ago)542212[4 issues](https://github.com/heimrichhannot/contao-api-bundle/issues)1LGPL-3.0-or-laterPHPPHP ^7.4 || ^8.0CI failing

Since Sep 20Pushed 2y ago5 watchersCompare

[ Source](https://github.com/heimrichhannot/contao-api-bundle)[ Packagist](https://packagist.org/packages/heimrichhannot/contao-api-bundle)[ RSS](/packages/heimrichhannot-contao-api-bundle/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (7)Dependencies (13)Versions (16)Used By (1)

Contao api bundle
=================

[](#contao-api-bundle)

[![](https://camo.githubusercontent.com/00e1e79b2fa03bf66bd7a3cee0ca22028a963a6d8eb15fca8d2102f5f493f521/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6865696d7269636868616e6e6f742f636f6e74616f2d6170692d62756e646c652e737667)](https://packagist.org/packages/heimrichhannot/contao-api-bundle)[![](https://camo.githubusercontent.com/231ae20fb50d0a4d6a8e305a0cd255a8bbfe94e2dbf2a39603fbb0d667cffc83/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6865696d7269636868616e6e6f742f636f6e74616f2d6170692d62756e646c652e737667)](https://packagist.org/packages/heimrichhannot/contao-api-bundle/stats)[![](https://camo.githubusercontent.com/c5ddb1f5add84f09c5c724745853ef91ff5675d6173162d7be0dc8a5603c9fa3/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6865696d7269636868616e6e6f742f636f6e74616f2d6170692d62756e646c652f6d61737465722e737667)](https://travis-ci.org/heimrichhannot/contao-api-bundle/)[![](https://camo.githubusercontent.com/4998ddd67fa4c426c16f95c0d8212a4f9149a4d24c8ec31eb2648361f195a6e0/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6865696d7269636868616e6e6f742f636f6e74616f2d6170692d62756e646c652f6d61737465722e737667)](https://coveralls.io/github/heimrichhannot/contao-api-bundle)

A generic API with restricted access to provide access to 3rd party applications.

Login `/api/login/member` or `api/login/user`
---------------------------------------------

[](#login-apiloginmember-or-apiloginuser)

Login is done via symfony `guard` authenticator in combination with contao members `tl_member` or users `tl_user`. After successful login a volatile token (default: `24 hours`) will be returned that is used for any api and must be provided within request headers `Authorization: Bearer {{token}}`;

```
# test login (with contao front end member)
curl --user username:password -H "Content-Type: application/json" -X POST http://domain.tld/api/login/member

# example response on success
{
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmXtZSI6ImRpZ2l0YWxlc0BoZWltcmljaA1oYW5ub3QuZGUiLCJpYXQiOjE1MzY4NTYwMDMsImV4cCI6MTUzNjk0MjQwM30.trp-1NgYgXGfHYdE3dlQ8awE8aXUWL-RfBQyfWm2Hz0"
}

# test login (with contao back end member)
curl --user username:password -H "Content-Type: application/json" -X POST http://domain.tld/api/login/user

# example response on success
{
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmXtZSI6ImRpZ2l0YWxlc0BoZWltcmljaA1oYW5ub3QuZGUiLCJpYXQiOjE1MzY4NTYwMDMsImV4cCI6MTUzNjk0MjQwM30.trp-1NgYgXGfHYdE3dlQ8awE8aXUWL-RfBQyfWm2Hz0"
}

```

Create an app with an custom api key
------------------------------------

[](#create-an-app-with-an-custom-api-key)

Visit your contao backend at `http://domain.tld/contao?do=api_apps` and create your first app. Access can be restricted for member or user groups. Admin users `tl_user` will have access to every api by default. For each request beside the login routes you must provide the generated API `key` as `GET` Parameter.

Resource /api/resource/{resource\_alias}
----------------------------------------

[](#resource-apiresourceresource_alias)

To add your custom resource, simply add an service within your bundles or app `services.yml`:

```
services:
	my.api.resource.my_resource:
		class: MyApi\Resource\MyResource
		arguments:
              - "my_resource"
		tags:
		- { name: huh.api.resource, alias: my_resource}

```

And register your resource configuration within your bundles or app `config.yml`:

```
huh:
  api:
    resources:
      - {name: my_resource, type: entity_resource, modelClass: "MyResourceModel", verboseName: my_resource}

```

To get your `config.yml` loaded properly, your `Plugin` class must implement the interface `Contao\ManagerPlugin\Config\ExtensionPluginInterface`:

```
namespace MyApi\ContaoManager;

use Contao\ManagerPlugin\Config\ContainerBuilder;
use Contao\ManagerPlugin\Config\ExtensionPluginInterface;
use HeimrichHannot\UtilsBundle\Container\ContainerUtil;

class Plugin implements ExtensionPluginInterface
{

    /**
     * {@inheritdoc}
     */
    public function getExtensionConfig($extensionName, array $extensionConfigs, ContainerBuilder $container)
    {
        return ContainerUtil::mergeConfigFile(
            'huh_api',
            $extensionName,
            $extensionConfigs,
            __DIR__.'/../Resources/config/config.yml'
        );
    }

```

**Do not forget to clear the symfony cache afterwards!**

Now you are able to access your resource through `/api/resource/my_resource`.

```
# test access to my_resource (provide your token from user or member login and your api key)
curl --header "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmXtZSI6ImRpZ2l0YWxlc0BoZWltcmljaA1oYW5ub3QuZGUiLCJpYXQiOjE1MzY4NTYwMDMsImV4cCI6MTUzNjk0MjQwM30.trp-1NgYgXGfHYdE3dlQ8awE8aXUWL-RfBQyfWm2Hz0" -H "Content-Type: application/json" -X GET http://domain.tld/api/resource/my_resource?key=

```

Now you are able to access crud functionality by using the related `HTTP method`:

PathHTTP-MethodResource-Method (Mapping)/api/resource/my\_resourcePOSTcreate() new resource/api/resource/my\_resource/23PUTupdate() existing resource with id 23/api/resource/my\_resourceGETlist() all resources/api/resource/my\_resource/23GETshow() existing resource with id 23/api/resource/my\_resource/23DELETEdelete() existing resource with id 23```
# test create() new resource
curl --header "Authorization: Bearer " -H "Content-Type: application/json" -X POST -d "{"title":"My test title", "published":true}" http://domain.tld/api/resource/my_resource?key=

```

```
# test update() existing resource
curl --header "Authorization: Bearer " -H "Content-Type: application/json" -X PUT -d "{"title":"My new test title", "published":false}" http://domain.tld/api/resource/my_resource/23?key=

```

```
# test list() all resources
curl --header "Authorization: Bearer " -H "Content-Type: application/json" -X GET http://domain.tld/api/resource/my_resource?key=

```

```
# test show() existing resource
curl --header "Authorization: Bearer " -H "Content-Type: application/json" -X GET http://domain.tld/api/resource/my_resource/23?key=

```

```
# test delete() existing resource
curl --header "Authorization: Bearer " -H "Content-Type: application/json" -X DELETE http://domain.tld/api/resource/my_resource/23?key=

```

### Available Resources

[](#available-resources)

#### Service: huh.api.resource.member

[](#service-huhapiresourcemember)

Skeleton resource that provides simple crud functionality with contao member (tl\_member) entity

PathHTTP-MethodResource-Method (Mapping)Additional GET Parameters/api/resource/memberPOSTcreate() new member-/api/resource/member/23PUTupdate() existing member with id 23-/api/resource/memberGETlist() all memberlimit, offset/api/resource/member/23GETshow() existing member with id 23-/api/resource/member/23DELETEdelete() existing member with id 23-

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance4

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 89.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 ~135 days

Recently: every ~109 days

Total

14

Last Release

1034d ago

Major Versions

1.0.2 → 2.0.02018-12-12

PHP version history (3 changes)1.0.0PHP ^7.1

2.2.0PHP ^7.1 || ^8.0

2.2.5PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/28ad3224d8727b622ebd229840eea6b9dbcb83eb0bd609e6ce65b614830ff538?d=identicon)[digitales@heimrich-hannot.de](/maintainers/digitales@heimrich-hannot.de)

---

Top Contributors

[![koertho](https://avatars.githubusercontent.com/u/12064642?v=4)](https://github.com/koertho "koertho (25 commits)")[![fritzmg](https://avatars.githubusercontent.com/u/4970961?v=4)](https://github.com/fritzmg "fritzmg (1 commits)")[![seibtph](https://avatars.githubusercontent.com/u/17127525?v=4)](https://github.com/seibtph "seibtph (1 commits)")[![srhinow](https://avatars.githubusercontent.com/u/741418?v=4)](https://github.com/srhinow "srhinow (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/heimrichhannot-contao-api-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/heimrichhannot-contao-api-bundle/health.svg)](https://phpackages.com/packages/heimrichhannot-contao-api-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[docusign/esign-client

The Docusign PHP library makes integrating Docusign into your apps and websites a super fast and painless process. The library is open sourced on GitHub, look for the docusign-esign-php-client repository. Join the eSign revolution!

2087.4M13](/packages/docusign-esign-client)[codefog/contao-news_categories

News Categories bundle for Contao Open Source CMS

3183.3k6](/packages/codefog-contao-news-categories)[terminal42/contao-node

Node bundle for Contao Open Source CMS

3172.5k4](/packages/terminal42-contao-node)[contao-community-alliance/dc-general

Universal data container for Contao

1578.3k86](/packages/contao-community-alliance-dc-general)[numero2/contao-storelocator

Contao Plugin for managing stores (or in common address data) and providing a frontend-search based on geo data

121.5k](/packages/numero2-contao-storelocator)

PHPackages © 2026

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