Adding a Remote Web Service to Your DSP | Dreamfactory

Table of contents


The DreamFactory Services Platform (DSP) provides a flexible and powerful backend for your mobile apps. If you don’t have a DreamFactory account, sign up here. One of the key features is the ability to integrate any number of remote web services, and access them directly through the DreamFactory REST API. In this blog post we'll walk through the process of setting up and invoking a remote web service.

By letting your DSP manage the service, you can hide many of the complex details of the remote web service from the client. Service credentials, URL params, and headers can all be configured once and stored on the DSP. This provides the client a simple, secure, and consistent way to access any remote web service via the DreamFactory REST API.

Testing the Remote Service

For this example we'll be using a web service at for retrieving make and model information on cars. You can substitute some other web service if you like. First we need to verify access to the API. To use the API you can go to to create an account and request an API key. We are displaying a fake API key to protect our real one, your key would be different.

From the edmunds API docs, we know already that the URL for our service is

and it requires two URL parameters named fmt and api_key.

fmt is just the return data type, and should be set to json. api_key is assigned to you by when you signed up for API access.

The full URL with params is then

At this point you should be able to use curl or a similar tool to retrieve data from this URL. Remember this URL as we'll refer to it later. Now that we know the service is working we need to integrate it with our DSP by adding it as a remote web service.

Creating the Service on your DSP

To create a new web service, go to the Services tab in the admin console. Click the Create New button in the upper right and complete the form as shown below.



Type: Remote Web Service

Service Name:
Service Name can be whatever you like and will be the name displayed in the list of services in the admin console.

API Name: edmunds
Api Name can be whatever you like and will be the name used by the REST API. If we set it to 'edmunds' then the service URL will be You would replace dsp-foo with the name of your own DSP.

Base URL:
When a client makes a request to the service, the DSP will append everything after /edmunds in the service URL to the base URL before invoking the web service. The DSP is acting as a proxy for the remote web service. An important benefit of this setup is that web service credentials (in this case api_key) are never exposed to the client.

Parameter #1: name=fmt, value=json

Parameter #2: name=api_key, value=7rjqgtvjryjks5zjn482fpg2

After completing the form click the Save button and the new service should show up in the list.


Creating an App to Call the New Service

Now we can create an app that uses our new web service. Go to the Applications tab in the admin console and click the New button in the upper right. Complete the form as shown, making sure the API name for the app is 'edmundsapp' because the API call in the sample code below includes the app name.


Click the Save button then select the new app in the list. Click the file manager icon to the right of the app name in the list. You will see that an index.html file has been created for you. Click the edit icon next to index.html and replace the contents of that file with the code below and click the Save button.

<meta charset="utf-8">
<script type="text/javascript" src="//"></script>
<script type="text/javascript">
$(document).ready(function() {

url:location.protocol + '//' + + '/rest/edmunds/vehicle/makerepository/findall',
success:function (response) {
error:function (response) {
alert("There was an error loading the make and model data.");
<p> via DreamFactory</p>
<div id="RESULTS_CONTAINER">&nbsp;</div>

The DSP Service Proxy

After the page loads there is a single ajax call to the service at

location.protocol + '//' + + '/rest/edmunds/vehicle/makerepository/findall' points to the DSP that is hosting the app. You could point to some other hard-coded host if you wanted. The service URL is /rest/edmunds. When the DSP receives this GET request, it appends everything after the /edmunds to the service's base URL as in   +  vehicle/makerepository/findall

The DSP then appends the service's configured URL params fmt and api_key which gives the complete URL;api_key=7rjqgtvjryjks5zjn482fpg

Hopefully this URL looks familiar. It's the one I told you to remember a while ago. The DSP sends the request to and forwards the response back to the client.

Running the App

Click the Edmunds App in the list and click the preview (eye) icon to the right of the app name. If all goes well you will see the returned data in the preview area. You can use your browser's developer tools to look at the details of the request and response.


Using the admin console you can add as many services as you want and access them through the DreamFactory REST API. You can also control which apps and users have access to each service. Please leave any questions or comments and we'll get back to you ASAP!