About
Fusio is an open source API management platform which helps to build and manage REST APIs. Fusio provides all tools to quickly build an API from different data sources yet it is possible to create complete customized responses. It can help you with the following use cases:
- API-Gateway
Fusio can be used as gateway to your internal API and microservices. - Low-Code-Platform
Fusio allows you to build API endpoints without coding knowledge. - API-Framework
Fusio can be used as API framework to build complete customized API endpoints.
API management and features
Fusio is an API management platform where you can configure routes which execute specific actions. An action triggers your business logic, it is like a controller in a classical framework, you can also think of it like a serverless lambda function, which can be executed on a route call or via RPC. Fusio covers many aspects of the API management life cycle so that you can concentrate on writing the actual business logic of your API. The following feature list gives you a first overview:
- OpenAPI generation
Fusio generates automatically an OpenAPI specification for the defined routes - SDK generation
Fusio can automatically generate a client SDK for your API based on the defined schema - Subscription support
Fusio contains a subscription layer which helps to build pub/sub for your API - Rate limiting
Fusio provides a way to rate limit requests based on the user or app - Authorization
Fusio uses OAuth2 for API authorization - RPC support
Fusio provides RPC support, every action which you create can be also called via JsonRPC - Monetization
Fusio provides a simple payment system to charge for specific routes - Validation
Fusio uses the TypeSchema to automatically validate incoming request data - Analytics
Fusio monitors all API activities and shows them on a dashboard - User management
Fusio provides a developer app where new users can login or register a new account through GitHub, Google, Facebook or through normal email registration
Development
In Fusio an action contains the business logic of your API. It i.e. inserts data to a database or returns specific data for an endpoint. Fusio contains already example Todo actions, please take a look at the src/
folder. To give you a first impression the following action shows how to insert a todo entry:
<?php
namespace App\Action\Todo;
use App\Model\Todo;
use Fusio\Engine\ActionAbstract;
use Fusio\Engine\ContextInterface;
use Fusio\Engine\ParametersInterface;
use Fusio\Engine\RequestInterface;
class Insert extends ActionAbstract
{
public function handle(RequestInterface $request, ParametersInterface $configuration, ContextInterface $context)
{
/** @var \Doctrine\DBAL\Connection $connection */
$connection = $this->connector->getConnection('System');
$body = $request->getPayload();
$now = new \DateTime();
assert($body instanceof Todo);
$connection->insert('app_todo', [
'status' => 1,
'title' => $body->getTitle(),
'insert_date' => $now->format('Y-m-d H:i:s'),
]);
return $this->response->build(201, [], [
'success' => true,
'message' => 'Insert successful',
]);
}
}
At the code we get the System
connection which returns a \Doctrine\DBAL\Connection
instance. We have already many adapters to connect to different services. Then we simply fire some queries and return the response.
We have also a CMS demo app which is a headless CMS build with Fusio which shows how to design and structure a more complex app.
Folder structure
resources/config.yaml
Contains common config values of your APIresources/connections.yaml
Contains all available connections which can be used at an action. TheSystem
connection to the Fusio database is always availableresources/routes.yaml
Contains all routes of your API. Each route points to a dedicatedyaml
file which contains all information about the endpointsrc/Action
Contains all actionssrc/Migrations
Contains migrations which can be executed on a specific connection. To execute those migrations on theSystem
connection you can run the following command:php bin/fusio migration:migrate --connection=System
src/Model
Contains all models which are used at your actions. You can also automatically generate those models, please take a look at thegen/
folder
Deployment
To tell Fusio about all the routes, actions and connections which you define at the yaml
files you need to run the deploy command:
php bin/fusio deploy
This reads all yaml files and uses the internal API to create those resources at the database. For more information please read the development doc.
Backend
For simple uses cases you also dont need to use the deployment. You can simply build your API based on the available actions and only through the backend. This means you use Fusio more like a CMS. The following actions are available by default:
Client SDKs
Fusio provides multiple SDKs to talk to the internal API of Fusio. The SDK can be used to integrate Fusio into your app and to automate processes. I.e. it would be possible to dynamically create a route, user or app. These SDKs are automatically generated and you can easily also generate such an SDK for the API which you build with Fusio.
SDK-PHP
SDK-Javascript
Code-Generation
Fusio can be used in a lot of use cases. If you build an API based on entities which should be stored in a relational database you can use our code generator to simply build all routes, schemas and actions based on a simple YAML definition. The code can be used as great starting point to rapidly build your API. The tool is available at: https://generate.apioo.de/
Serverless (in development)
Serverless is a great paradigma to build scaleable APIs. The biggest disadvantage is that your app is locked in at the serverless provider (vendor-lock-in). If you want to switch the provider it is difficult to move your app to a different vendor.
Fusio tries to solve this problem by providing a self hosted platform written in PHP which you can simply host on your own bare-metal server, but it is also possible to move the entire application to a serverless provider i.e. AWS. If you develop your API with Fusio you can start hosting your app on a cheap self-hosted server and move to serverless only if you actually need the scaling capabilities.
For this we need to require a fitting adapter to support a serverless cloud provider. I.e. for AWS:
composer require fusio/adapter-aws
php bin/fusio system:register "Fusio\Adapter\Aws\Adapter"
To push the app to a cloud provider we use the serverless framework. Through the following command Fusio generates a serverless.yaml
file and the fitting action files at the public/
folder.
php bin/fusio push aws
To finally push this to the cloud provider we use the recommended serverless framework via:
npm install -g serverless
serverless config credentials --provider aws --key <key> --secret <secret>
serverless deploy
Ecosystem overview
This should give you a first overview about all important repositories which belong to the Fusio project:
- Fusio
Contains a configured Fusio instance with a simple Todo app. It is also the main place about Fusio where we collect and discuss all ideas and issues - Fusio-Impl
Contains the backend API implementation of Fusio. This is the place if you like to change the internal API of Fusio - Fusio-CLI
Contains the CLI client for Fusio, it is automatically included in every Fusio installation but you can also run the CLI client standalone. It allows you to directly interact with the API and to deploy specific YAML configuration files - Fusio-Model
Contains all Fusio models automatically generated via TypeSchema. This repository helps if you want to work with the Fusio API since you can use the same model classes which we also use at the backend - Fusio-Engine
Contains mostly interfaces which are also needed by adapters. This repository is very stable and there are few changes - Fusio-Adapter
Page which shows all available adapters. An adapter can extend Fusio by providing i.e. custom Actions or Connections to different services. I.e. we have an adapter MongoDB which helps to work with a MongoDB - Fusio-Docker
Contains a Docker-Image to run Fusio, it helps to quickly create a Fusio instance in the cloud. You can find it also directly on DockerHub - App-Backend
Contains the Fusio backend app which you can use to configure your API. This is the place if you like to change or improve the backend app - App-Consumer
Contains a developer portal app where external developers can register to use your API
Apps
Since it is difficult to work with an API only app Fusio provides apps which help to work with the API. Mostly apps are simple JS apps, which work with the internal API of Fusio. You can see a list of all available apps at our marketplace. You can install such an app either through a CLI command i.e. php bin/fusio marketplace:install fusio
or through the backend app.
All apps are installed to the apps/
folder. You need to tell Fusio the public url to the apps folder at the .env
file by defining the FUSIO_APPS_URL
variable. Depending on your setup this can be either a custom sub-domain like https://apps.acme.com
or simply the sub folder https://acme.com/apps
.
Backend
The backend app is the main app to configure and manage your API. The installer automatically installs this app. The app is located at /apps/fusio/
.
Installation
It is possible to install Fusio either through composer or manually file download.
Composer
composer create-project fusio/fusio
Download
https://github.com/apioo/fusio/releases
Configuration
You can either manually install Fusio with the steps below or you can also use the browser based installer at public/install.php
. Note because of security reasons it is highly recommended removing the installer script after the installation.
- Adjust the configuration file
Open the file.env
in the Fusio directory and change theFUSIO_URL
to the domain pointing to the public folder. Also insert the database credentials to theFUSIO_DB_*
keys. Optional adjustFUSIO_APPS_URL
to the public url of the apps folder (in case you want to use apps). - Execute the installation command
The installation script inserts the Fusio database schema into the provided database. It can be executed with the following commandphp bin/fusio install
. - Create administrator user
After the installation is complete you have to create a new administrator account. Therefor you can use the following commandphp bin/fusio adduser
. Choose as account type "Administrator". - Install backend app
To manage your API through an admin panel you need to install the backend app. The app can be installed with the following commandphp bin/fusio marketplace:install fusio
You can verify the installation by visiting the FUSIO_URL
with a browser. You should see an API response that the installation was successful.
In case you want to install Fusio on a specific database you need to adjust the driver
parameter at the configuration.php
file:
pdo_mysql
: MySQLpdo_sqlite
: SQLitepdo_pgsql
: PostgreSQLsqlsrv
: Microsoft SQL Serveroci8
: Oraclesqlanywhere
: SAP Sybase SQL Anywhere
Docker
Alternatively it is also possible to setup Fusio through docker. This has the advantage that you automatically get a complete running Fusio system without configuration. This is especially great for testing and evaluation. To setup the container you have to checkout the repository and run the following command:
docker-compose up -d
This builds the Fusio system with a predefined backend account. The credentials are taken from the env variables FUSIO_BACKEND_USER
, FUSIO_BACKEND_EMAIL
and FUSIO_BACKEND_PW
in the docker-compose.yml
. If you are planing to run the container on the internet you must change these credentials.
Documentation
Here we list all available documentation resources. If these resources dont answer your questions or you want to provide feedback feel free to create an issue on GitHub.
Use cases
Today there are many use cases where you need a great documented REST API. In the following we list the most popular choices where Fusio comes in to play.
Business functionality
Exposing an API of your business functionality is a great way to extend your product. You enable customers to integrate it 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.
Micro services
With Fusio you can simply build small micro services which solve a specific task in a complex system.
Javascript applications
Javascript frameworks like i.e. Angular or Vue becoming the standard. With Fusio you can easily build a backend for such applications. So you dont have to build the backend part by yourself.
Mobile apps
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 then can also be used by other applications.
Contribution
Contributions to the project are always appreciated. There are many options available to improve the project (which is not limited to coding). The following list shows some ways how you can participate:
Developing
If you are a PHP or Javascript developer you can help to improve the system. If you want to create a new feature it is in general recommended to create a new issue where we can talk about the feature before you start to hack on it. So there are three main components of Fusio:
The backend API is the core of the system developed in PHP, which provides the basic functionality of Fusio. This is the place to develop new core features and improvements.
An adapter is a plugin to the Fusio system which can be used to connect to other remote services. I.e. you could create a new adapter which speaks to a specific API or other remote service. This is easy to develop since you can build it in a separate repository. Please use the keyword fusio-adapter
in your composer.json
file so that adapter gets listed automatically on our website.
This is the AngularJS app which is used as GUI to control the backend. It is the main app to improve the Fusio backend. But you are also free to develop new apps for special use cases which talk to the internal API of Fusio.
Testing
In general we have a high PHPUnit test case coverage and also automatic end-to-end AngularJS tests using protractor and selenium. Beside this it is always great if users checkout the current master version of the project and try to test every aspect of the system. In case you have found an issue please report it through the issue tracker.
Documentation
We want to create a system which is easy to use also by novice users. To enable everybody to start using Fusio we need a simple to understand documentation. Since we have not always the view of a novice developer please let us know about chapters which are difficult to understand or topics which are missing. You can also send us directly a pull request with an improved version. The main documentation of Fusio is available at readthedocs. The documentation source is available in the docs/
folder.
Support
Promotion
If you are a blogger or magazine we would be happy if you like to cover Fusio. Please take a look at the Media section of our About Page to download the official icon set. In case you have any questions please write us a message directly so we can help you to create great content.
Consulting
If you are a company or freelancer and want to get detailed information how you can use Fusio you can contact us for consulting. In the workshop we try to find the best way how you can use/integrate Fusio also we try to explain the functionality and answer your questions.
Donations
If this project helps you to generate revenue or in general if you like to support the project you can donate any amount through paypal. We like to thank every user who has donated to the project.