Fusio

Simply build and
manage REST APIs

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.

Deployment

Fusio uses a simple YAML format to describe the capabilities of the API. The following definition can be deployed through a simple command: /fusio/bin deploy.

routes:
  "/todo":
    version: 1
    methods:
      GET:
        public: true
        response: Todo-Collection
        action: "${dir.src}/Todo/collection.php"
      POST:
        public: false
        request: Todo
        response: Todo-Message
        action: "${dir.src}/Todo/insert.php"
schema:
  Todo: !include resources/schema/todo/entity.json
  Todo-Collection: !include resources/schema/todo/collection.json
  Todo-Message: !include resources/schema/todo/message.json
connection:
  Default-Connection:
    class: Fusio\Adapter\Sql\Connection\SqlAdvanced
    config:
      url: "sqlite:///${dir.cache}/todo-app.db"
migration:
  Default-Connection:
    - resources/sql/v1_schema.php
<?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,
]);
{
  "type": "object",
  "title": "todo",
  "properties": {
    "id": {
      "type": "integer"
    },
    "status": {
      "type": "integer"
    },
    "title": {
      "type": "string",
      "minLength": 3,
      "maxLength": 32
    },
    "insertDate": {
      "type": "string",
      "format": "date-time"
    }
  },
  "required": ["title"]
}
<?php
/**
 * @var \Doctrine\DBAL\Schema\Schema $schema
 */

$todoTable = $schema->createTable('app_todo');
$todoTable->addColumn('id', 'integer', ['autoincrement' => true]);
$todoTable->addColumn('status', 'integer', ['default' => 1]);
$todoTable->addColumn('title', 'string', ['length' => 64]);
$todoTable->addColumn('insertDate', 'datetime');
$todoTable->setPrimaryKey(['id']);

Features

Once the API is deployed Fusio provides the following features out of the box:

build

API management

Fusio provides a powerful backend app to control and monitor your API.

assessment

Developer portal

Fusio provides a developer portal app where developer can register to use your API.

book

Documentation

Fusio provides a documentation app which shows all available API endpoints.

layers

JSON Schema

Fusio validates all incoming requests accordingly to the provided JSON schema.

account_box

OAuth2 authorization

App developer can obtain an access token to access non-public API endpoints.

swap_horiz

Rate limiting

Fusio provides a way to rate limit requests based on the user or app.

cloud_queue

Schema generation

Fusio provides an endpoint to automatically generate RAML and OAI specifications.

device_hub

JWT

For SPAs users can request a JWT to access protected parts of the API.

label_outline

Scope handling

Each user and app can be limited to scopes to request only specific parts of the API.