Fusio is an open source API management platform which helps to build and manage RESTful APIs. We think that there is a huge potential in the API economy. Whether you need an API to expose your business functionality, develop One-Page web applications, Mobile-Apps or Microservices. Because of this we think that Fusio is a great tool to build such APIs. If you like the project and want to see it grow please checkout the repository.
If you are researching API solutions you probably hear often the term API-Gateway/Proxy and API-Management. Fusio is an API-Management system in the sense that it helps to develop actual API endpoints (which i.e. request and transform data from a database). It is not limited to proxy requests to another API. The following diagram should give you a better overview.
Fusio uses the backend services to produce the API response or to handle the request data. A backend service can be i.e. a database, message queue or another API. It is also very easy to implement a custom connection to support any kind of service.
To give you a first overview, every request which arrives at Fusio goes through the following lifecycle:
Fusio tries to assign the incoming request to a fitting route. The route contains all schema information about the incoming request and outgoing responses. Those schemas are also used at the documentation which is automatically available. If a request schema was provided the incoming request body gets validated after this schema. In case everything is ok the action which is assigned to the route gets executed.
An action represents the code which handles an incoming request and
produces a response. Each action can use connections to accomplish this
task. A connection uses a library which helps to work with a remote service.
I.e. the SQL connection uses the Doctrine DBAL library to work with a
database (it returns a
Doctrine\DBAL\Connection instance). A
connection always returns a fully configured object so you never have to
deal with any credentials in an action. Besides that there are already many
different actions available which you can use i.e. to create an API based on
a database table.
With Fusio we want to remove as many layers as possible so that you can work in your action directly with a specific library. Because of this Fusio has no model or entity system like many other frameworks, instead we recommend to write plain SQL in case you work with a relational database. We think that building API endpoints based on models/entities limits the way how you would design a response. You only need to describe the request and response in the JSON schema format. This schema is then the contract of your API endpoint, how you produce this response technically is secondary. Fusio provides the mentioned connections, which help you to create complete customized responses based on complicated SQL queries, message queue inserts or multiple remote HTTP calls.
Fusio provides two ways to develop an API. The first way is to build API endpoints only through the backend interface by using all available actions. Through this you can solve already many tasks especially through the usage of the v8 action.
The other way is to use the deploy mechanism. Through this you can use
normal PHP files to implement your business logic and thus you can use the
complete PHP ecosystem. Therefor you need to define a
deploy file which specifies the available routes and actions of the system.
This file can be deployed with the following command:
php bin/fusio deploy
The action of each route contains the source which handles the business logic. This can be i.e. a simple php file, php class or a url. More information in the src/ folder. In the following an example action to build an API response from a database:
<?php /** * @var \Fusio\Engine\ConnectorInterface $connector * @var \Fusio\Engine\RequestInterface $request * @var \Fusio\Engine\Response\FactoryInterface $response * @var \Fusio\Engine\ProcessorInterface $processor * @var \Psr\Log\LoggerInterface $logger * @var \Psr\SimpleCache\CacheInterface $cache */ /** @var \Doctrine\DBAL\Connection $connection */ $connection = $connector->getConnection('Default-Connection'); $count = $connection->fetchColumn('SELECT COUNT(*) FROM app_todo'); $entries = $connection->fetchAll('SELECT * FROM app_todo WHERE status = 1 ORDER BY insertDate DESC LIMIT 16'); return $response->build(200, , [ 'totalResults' => $count, 'entry' => $entries, ]);
In the code we get the Default-Connection which we have defined
previously in our .fusio.yml deploy file. In this case the connection
Doctrine\DBAL\ Connection instance but we have
already many adapters to connect to different services. Then we simply fire
some queries and return the response.
Exposing an API of your business functionality is a great way to extend your product. You enable customers to integrate your business value into other applications which gives the possibility to open up for new markets. With Fusio you can build such APIs and integrate them seamlessly into your product. We also see many companies which use the API itself as the core product.
With Fusio you can simply build small micro services which solve a specific task in a complex system.
Almost all mobile apps need some form to interact with a remote service. This is mostly done through REST APIs. With Fusio you can easily build such APIs which can also be used by other applications.
Fusio is licensed under the AGPLv3. It is possible to use Fusio for commercial products but if you extend the code of Fusio (i.e. develop custom actions) you are required to license this code also under the AGPL which requires that the source code must be public available. Please contact us if you have any questions regarding the license or need other license options.
If you are a blogger or magazine we would be happy if you like to cover Fusio. You can download the official icon set to represent Fusio. In case you have any questions please write us a message directly so we can help you to create great content.