{ DreamFactory: 'Blog' }

DreamFactory Proud to Sponsor HackKings

Posted by Jessica Rose

Mon, Nov 9, 2015

Based around open source technology, the DreamFactory team has a lot of love for spaces where passionate people are building the interesting and unexpected. So being involved with hackathons seemed like an incredible way to get involved with amazing events, communities and to see what kinds of interesting things sleep-deprived technologists could build on the DreamFactory platform in 24 hours. We're going to be sponsoring our first hackathon in December, the esteemed HackKings student hackathon at King's College London on December 12-13th.

HackKings is free to attend and open to university students aged 18 and above. Jessica Rose will be representing DreamFactory during the event and awarding a prize for the best use of the DreamFactory open source platform to generate REST APIs. We're really hoping to see some weird and creative uses of data in the hacks. We'll be featuring the winning DreamFactory hack here on the blog, so check back after the event to see what the KCL students dreamed up.


DreamFactory 2.0 hackathon

DreamFactory 2.0 Bundled With MongoDB

Posted by Ben Busse

Fri, Nov 6, 2015

All of the new Bitnami packages for DreamFactory 2.0 have MongoDB built into the installation. Just run the installer, open up the admin console, and MongoDB is right there as one of the available services. This blog post discusses why we bundled MongoDB in the latest version of DreamFactory and how you can to use this great NoSQL database.

The Big Three

DreamFactory 2.0 has the world’s best REST API for old-fashioned SQL databases. Our enterprise customers often need to mobilize legacy SQL, and we want to make that super easy for them. But SQL can be a bit painful. First, you have to set up the schema. Our admin console has a tab to edit SQL schema, and of course there are many tools for this, but the tables and fields have to be designed carefully. And then there are other issues including date formats, required fields, stored procedures, primary keys, child and parent objects, etc.

And we also have great support for file storage systems. You can store whatever you want in there. We have a REST API for the local storage on your server, and also support a host of cloud storage options from S3 to OpenStack. But while you can save whatever you want in the file store, there isn’t any structure to the documents, and no easy way to search for things.

This is why we are proud to bundle MongoDB with DreamFactory 2.0. Now minimum hassle, you can leverage the immense and very flexible power of MongoDB for your applications. Just run the Bitnami installer and check out the services tab, pictured above. We also include a default SQL database, along with access to the local file storage system. This way, developers have “out of the box” access to SQL, NoSQL, or file storage as needed for their application design. But I think that when you take a look at the power and ease of use of MongoDB, you will see why it occupies the “sweet spot” between file storage and SQL.

Create Your First Table

You really only need to do one thing to start using MongoDB, and that is to create at least one table. (In MongoDB language, this is called a “collection,” but since DreamFactory has to deal with lots of different data sources, we have a more generic name.) There are two main ways to create a table. First, go to the API Docs tab in the admin console, and scroll down to the section:


Next, type the JSON below into the window and click the “Try it out” button.

Alternatively, you can just POST the JSON from any client. That way you could create tables programmatically, or even automate the process. The POST would look something like this. You will want to insert your own table name:


{ "resource": [{
     "name": "mytable",
     "label": "my table",
     "plural": "my tables"

And that’s it! You have created your first table in MongoDB. Now you can GET and PUT or even DELETE entries in the table. If for any reason your table does not show up in the admin console interface you might want to clear the system cache from the config tab. Also, you will have to add the table to a user role to enable client side access through the REST API.

Flexible Structured Data

One of the cool aspects of MongoDB in particular and NoSQL in general is that you don’t have to worry too much about schema. You can store structured JSON documents and even add schema at a later date as needed. For example, you could create a document by POST-ing some JSON, like this:


"resource": [{
     "amount": 300,
     "product": "whatever",
     "email": "billappleton@dreamfactory.com",
     "name": "value2"

This POST will return a result that looks like this:


MongoDB returns a unique identifier called “_id” for your document when it is created. The id can be used to update or delete the document at a later date. As you create documents, you can include new name-value pairs, or drop name-value pairs that were used in the past. By the way, you can create any number of tables at the same time with multiple objects in the “resources” array, above.

Simple Filtered Queries

Go ahead and create a couple of documents with some different name-value fields, and let’s try a filtered query. DreamFactory makes this really easy with a textual query language that is similar to SQL. Go to the API Docs tab and navigate to:


You can search for any text field, or a number with inequalities, or even substrings in a text field. These are all valid examples you might try, below. Type these into the filter string interface, and click the “Try it out” button.

email LIKE %appleton%
amount>290 and amount<310

The result for my data using the first filter looks like this:

     "_id": "561ff05d532c2e9b158b4567",
     "amount": 450,
     "product": "whatever",
     "email": "billappleton@dreamfactory.com",
     "name": "value2"
     "_id": "561ff4e0532c2efc7d8b4567",
     "amount": 300,
     "product": "whatever",
     "email": "mercerappleton@dreamfactory.com",
     "name": "value2"

The call from a client application would be a simple GET like this:


The Big Leagues

Of course, you might already have a MongoDB database running in the cloud or on premises. In that case you can create a new service and hook up the database. MongoDB also has excellent products and services to support and scale your deployment as needed, but the bundled MongoDB database in DreamFactory 2.0 is a great way to start exploring NoSQL for your application needs.

NoSQL MongoDB SQL DreamFactory 2.0 database

DreamFactory 2.0 released into the wild

Posted by Bill Appleton

Thu, Oct 29, 2015

We are thrilled to announce that DreamFactory 2.0 has been released and is available for immediate download. This second generation of DreamFactory provides major enhancements to API security, customizability, modularity, and performance.

This event is a real milestone for the DreamFactory team and the growing DreamFactory community. As one of the founders of the DreamFactory project, I wanted to provide some context for these exceptional new features and capabilities.

A little history

DreamFactory Software wrote the world's first service-based applications over a decade ago. Soon after, we started building REST API backends in the cloud. A few years ago we decided to pour all of this experience into an open source project and we launched the first version of DreamFactory on GitHub. For the first time, developers everywhere could install a free REST API backend on any server, connect to any database, and instantly get the REST APIs they need to build and deploy modern mobile, web, and IoT applications.

The DreamFactory project has been well received, growing quickly to hundreds of thousands of developers and millions of users. But after listening to feedback from numerous developers, administrators, partners, and customers, the DreamFactory development team thought they could build an even better REST API backend. So, we completely rebuilt the product from scratch using the latest PHP frameworks and web standards. The results are spectacular.

Key advancements

  • Engine rewrite for maximum performance at high transaction volumes
  • Adopted JSON Web Token (JWT) for completely stateless operation at scale
  • Architectural improvements for "Platform as a Service" and Docker Containers
  • Comprehensive integration with Active Directory, LDAP, and OAuth
  • Highly-flexible role-based security at the user-app level
  • Custom API creation capabilities with support for API interface editing
  • API customization with multiple server-side scripting languages, including V8 JavaScript, Node.js, and PHP
  • Includes MongoDB for instant integration with the leading NoSQL database
  • Modular, lightweight installation so you can deploy only the packages you need
  • All-new example apps for AngularJS, JavaScript, Titanium, iOS, and Android

Security enhancements

We made important security enhancements to DreamFactory. First, we streamlined our support for Active Directory and LDAP. This allows enterprise customers to use their current user directory to control access to the platform. Users can inherit existing rights or receive custom rights for each application. We also rebuilt support for OAuth. This feature provides a convenient way for end users to log in with credentials from Facebook, Twitter, Google, or GitHub. You can set up both Active Directory and OAuth in a few minutes right from the DreamFactory admin console.

One of the most common requests we received from developers was to expand the scope of our role-based access controls. Users have always been able to host any number of applications on the DreamFactory platform. But in the 1.x generation of the software, users had the same role-based access rights regardless of which application they were running. With DreamFactory 2.0, users can have different access rights for each application. This feature allows an administrator to fine tune the access rights for each user and app.

Lastly, DreamFactory 2.0 has revolutionized the way it handles session management. JSON Web Tokens are an open industry standard from the Internet Engineering Task Force for representing claims securely. The adoption of JWT allows for stateless session management, and this has dramatically increased platform scalability. We also use JWT for API Keys. This increases security at the application level and allows each application to have a default role. You can distribute API keys to partners or use them to make an API public. The move to JWT also allows for more flexible session timeout rules.

API customization

When you connect to a data source, DreamFactory automatically generates a complete palette of powerful and reusable REST APIs with all of the required services. For example, DreamFactory provides over 40 different RESTful services for SQL, handling everything from metadata to stored procedures. If you read my blogs, then you know how helpful this capability is in reducing REST API backend complexity and cost.

But, sometimes the APIs also need to be customized. For example, you might want to do custom validations or create workflow triggers. And some developers want to go even farther and create their own REST APIs from scratch. For all of these reasons, the engineering team worked hard to increase the ability to customize existing APIs or build new ones with DreamFactory 2.0.

First off, the server-side scripting engine now supports multiple languages. DreamFactory supports JavaScript running in the V8js engine as before, but now it also supports Node.js and PHP as well. There are more languages on the way. The security of the server-side scripting system has also been enhanced. The role-based access controls can be used to grant access rights to either the internal scripting system or the external REST API as needed.

Next, DreamFactory 2.0 has a new kind of service available. It has always had the ability to call external REST APIs and bring them under role management. Now you can also create a custom service that runs as a server-side script. From your script, you can use any of the RESTful services made available by the platform. In this manner, you could design a completely custom RESTful interface that merges data from multiple sources.

Finally, we doubled down on our support for Swagger. The new version of DreamFactory has an enhanced user interface that allows you to create the parameters and request or response format for your custom services. Then your custom service will appear in the API Docs just like the regular services generated by DreamFactory. The interface you design will also be used to validate the passed parameters and request or response information.

Performance breakthroughs

We have conducted extensive horizontal and vertical performance benchmarks on the new DreamFactory platform and the results are impressive. Vertical scaling can be achieved with additional processors. Horizontal scaling works behind a load balancer. DreamFactory 2.0 can be scaled in a predictable manner to any desired performance characteristics. This was made possible in part by our adoption of JWT, discussed earlier. But there are other reasons for the performance improvements.

First, a major reason for the rewrite of DreamFactory was that we wanted to move to the Laravel PHP framework. This is the most popular framework for the most popular scripting language. The routing engine in Laravel is world class. The eventing system and other system libraries are extremely well done. There are also mature drivers available for every type of SQL or NoSQL database in the PHP language.

While the main engine is written in Laravel, we use the V8js engine for server-side scripting. This architecture allows us to run V8js in parallel for each request and response. The engine is sandboxed for security and reliability. This architecture avoids the performance bottlenecks normally found in single-threaded Node.js, which also uses the V8js engine. And DreamFactory now supports PHP in the scripting engine as well.

Laravel includes a great package management capability. This allowed us to move to a much more modular architecture. You can install just the parts of DreamFactory that you need. For example, even user management is a module. Each of the database services can be installed separately. And now, users can build their own modules and install them as first-class DreamFactory services.

We also worked with our packaging partner, Bitnami, to really trick out the installation options. DreamFactory 2.0 now includes MongoDB, the leading NoSQL database, as a pre-installed service. MySQL is still in there, too, and there are a bunch of new file storage options. DreamFactory 2.0 also includes SQLite, so users can instantly create SQLite databases when needed. This gives developers three great options right out of the box: SQL, NoSQL, and file storage. We also made it really easy to run the web server with either Apache or NGINX. So DreamFactory is now fully-stocked and ready to run with a variety of options.

Get it now, run it anywhere

DreamFactory 2.0 is available for download now. To simplify installation, there are Bitnami packaged versions of DreamFactory for all major IaaS cloud platforms, including AWS, Azure, GCP, and VMware. There is a microservices container on Docker Hub. There are easy desktop installers for Mac, Windows, and Linux. The PaaS versions of DreamFactory for BlueMix, OpenShift, Heroku, and Pivotal will be out in November. The source code is available on GitHub under the Apache License. And if you like instant gratification, we also offer a free developer environment to try a hosted instance of DreamFactory.

Wrapping it up

I am very proud of the effort that the DreamFactory engineering team and community has put into the DreamFactory project, not to mention the results. The fact that DreamFactory is a completely free open source software package is a real stunner. I encourage you to check it out for your next project. And keep an eye on this blog. We’re going to dive deep into many important topics, including scalability benchmarks, using MongoDB, creating SQLite databases, merging multiple data sources, creating custom services, and the new sample applications for AngularJS, JavaScript, Titanium, iOS, and Android.

We look forward to hearing about the incredible mobile, web, and IoT applications users will build on DreamFactory 2.0. Be sure to let us know how it goes.

MongoDB DreamFactory

How to connect to a MySQL database with JavaScript

Posted by Carsten Jacobsen

Tue, Oct 27, 2015

The DreamFactory REST API enables database connections using a wide variety of front end scenarios. This simple sample app demonstrates how DreamFactory 2.0 easily can be used as a backend for a JavaScript application. It's a simple address book, where contacts can be created, shown, updated, deleted and grouped, basically CRUD operations.

The Address Book is a very simple one page app based on plain JavaScript and jQuery. All the functions used for DreamFactory 2.0 REST API requests are extended in the file functions.js, and the code examples show how to use them.

Getting Started

The code is available at the GitHub repo, and to get the sample app up and running, just sign up for a free hosted developer account or download the free DreamFactory open source project from Bitnami.

Once you've logged into the DreamFactory Admin Console, follow the steps below to get the address book app up and running.

Step 1: Import the provided application package file:

Import DreamFactory package file

After importing the package, the app will be assigned an API Key, which you can see in the Apps tab. This API Key is needed to set up the app.

API key assignment

Step 2: Configure CORS

Navigate to the Config tab and select CORS. Click the '+' button to add a new CORS entry and select '*' from the list box. This will pre-populate the fields in the form. Enter 3600 for Max Age, make sure that the 'Enabled' checkbox is checked, and save.

Note: '*' denotes open access to your API endpoints and should only be used in for development.

CORS configuration

Now edit the first lines of code in the script.js file.

var DSP_API_KEY = '';

If the JavaScript Address Book Sample App code is not running on the DreamFactory 2.0 instance, specify the instance host (e.g. http://www.my-instance.com) in INSTANCE_HOST, otherwise leave INSTANCE_HOST blank. Insert the app API Key in DSP_API_KEY.

See the readme for more detailed instructions.

Code Examples

The JavaScript Address Book shows how to log in, log out and perform common CRUD operations.

DreamFactory 2.0 REST API requests are formatted like this:


All API requests executed from the Address Book are done with AJAX calls, with the following parameters:

dataType: String
contentType: String
url: String
data: String,Object
method: String
headers: Object

Breaking down each parameter:

dataType - format of the returned data. This depends on the application, but will typically be JSON.
contentType - the format of data sent to the API. This is commonly JSON and charset UTF-8.
url - the URL to the REST API endpoint (see format in Code Examples). You can include the query parameters here. However, it is easier and cleaner to pass in the query parameters by using the data parameter than it is to format them into the url.
data - the (optional) query parameter(s).
method - the REST verb (e.g. GET, POST).
headers - the header object must include the app-specific API key and a session token.

Log in

The Address Book implements DreamFactory 2.0's built-in user management for easy user creation and authentication. New users can register and existing users can log in to the app.
If the app is imported to the DreamFactory 2.0 instance, leave INSTANCE_HOST blank. Email and password are typically input fields in the app UI (like in the Address Book app).

var INSTANCE_HOST = 'http[s]://<server-name>';
var email = 'my@email.com';
var password = 'mypassword';

POST email and password to the endpoint user/session to retrieve a session token:

     dataType: 'json',
     contentType: 'application/json; charset=utf-8',
     url: INSTANCE_HOST + '/api/v2/user/session',
     data: JSON.stringify({
          'email': email,
          'password': password
     method: 'POST',
     success: function (response) {
          // Handle success
     error: function (response) {
          // Handle error

If the email and password matches users in the DreamFactory 2.0 instance, a session token will be returned. This session token is used for API requests requiring authentication.

Getting Records

After logging in and retrieving a session token, we can go ahead and get some records from the instance database. The approach is very similar to logging in and retrieving the session token. This time we use the extended function getRecords() in functions.js. The usage is like this:

getRecords(table, params, token, callback) - params can be fields, filters etc.

Use callback functions to get the requested data. The session token and the API key are inserted in the AJAX call as an object:

headers: {
     "X-DreamFactory-API-Key": API_KEY,
     "X-DreamFactory-Session-Token": token

In this example, all contact groups in the database are retrieved. Since the query retrieves all records without filtering, no parameters are passed to the function (null).

$.api.getRecords('contact_group', null, session_token, callback);
// create a callback function and handle the returned data there
var callback = function(response) {
     // The response contains an array of group objects

Now let's get all contacts, but we only interested in the id, first name, and last name. With the parameter fields, the response will be limited to the specified fields.

var params = 'fields=contact_id,first_name,last_name';
$.api.getRecords('contacts', params, session_token, callback);

Use a callback function like in the previous example to get the API request response.

Now let's get all contact ids belonging to a specific group instead (group id = 10). Note the equal sign in the filter value is url encoded (%3D).

var params = 'filter=contact_group_id%3D10';
$.api.getRecords('contact_group_relationship', params, session_token, callback);

Again, use a callback function like in the previous example to get the API request response. Parameters (e.g. fields, limits) can be combined in the same API request.

Creating Records

As the last example, a new record is created, and it's very similar to getting a record. Instead of executing a GET request, a POST request is executed to an API endpoint. In this example a new group named 'My Group' is created.

var group = { name: 'My Group' };
var params = JSON.stringify(group);
$.api.setRecord('contact_group', params, session_token, callback);

The parameters (request payload) must be stringified. If the API request was successful, and the group was created in the instance database, the id of the new group is returned (use callback function to get the response).

Dreamfactory 2.0 in JavaScript apps

Using DreamFactory 2.0 as a backend in JavaScript applications is easy. We hope this tutorial is useful and will get you started using DreamFactory 2.0 in your own projects. 

sdk sample app javascript mysql

DreamFactory Enterprise Beta Now Available

Posted by Ben Busse

Tue, Oct 20, 2015

We’re pleased to announce that DreamFactory Enterprise beta is ready to download and evaluate in your own environment.

DreamFactory Enterprise is a new commercial software package that helps you provision, govern, and report on multiple DreamFactory instances. It also helps you run DreamFactory more efficiently on shared computing infrastructure. Simply put, it’s the easiest way to manage multiple DreamFactory instances across your development lifecycle. 

Here’s an overview of DreamFactory Enterprise and how it can help.

What is DreamFactory Enterprise?

DreamFactory Enterprise is a commercial software package that runs on any Linux server. It includes the free DreamFactory open source runtime for fast DreamFactory instance deployment and provides an administrative web console and commands that allow you to:

  • Logically group server clusters where DreamFactory runs in development, test, and production
  • Manage multiple instances of DreamFactory on the same server cluster
  • Import / export DreamFactory instances between dev, test, and production servers or VMs
  • Log and report on every API call with the “ELK” stack (Elasticsearch, Logstash, Kibana)
  • Administer API call limits at the cluster, instance, and user level
  • Manage administrative ownership of each DreamFactory instance

To see it in action, check out this 11 minute demo video.

Who should use DreamFactory Enterprise?

DreamFactory Enterprise is for anyone who wants to manage DreamFactory instances more efficiently. This includes enterprise DevOps and Ops teams, software development agencies, systems integrators, independent software vendors (ISVs), managed service providers (MSPs), and infrastructure-as-a-service (IaaS) companies.

Why DreamFactory Enterprise?

DreamFactory, the open source project, provides a sophisticated REST API backend for your mobile, Web, and IoT applications. But how do you provision and manage multiple instances of DreamFactory across dev, test, and production? Or across multiple projects, business groups, or customers? That’s where DreamFactory Enterprise comes in.

DreamFactory Enterprise makes it easy to provision, govern, and report on multiple DreamFactory instances used across your development lifecycle–all from a single management platform. It provides centralized governance to enable super admins to institutionalize best practices and standards at the critical API layer and track conformance in operation. It’s the best way to ensure that your DreamFactory instances are fully managed, secure, compliant, and more predictable in cost.

Try DreamFactory Enterprise Beta Today

Trying DreamFactory Enterprise beta is easy. To give it a try, simply sign up and follow the installation instructions.

We’re excited for users to try out DreamFactory Enterprise beta. And we stand ready to provide extra responsive support to early users. Please let us know if you have feedback in the blog comments or feel free to weigh in on the DreamFactory Community Forum.

DreamFactory DreamFactory Enterprise