Chris Ismael
Parse Cloud Module

Photo credit: Parse

Parse is a backend-as-a-service (BAAS) platform that lets you focus on building your applications without worrying about server and infrastructure maintenance and complexities.  If you haven’t heard or tried Parse before, I encourage you to try their Quickstart here to get an idea of how the BAAS paradigm works.

This post shows an example of a Mashape API integrated with Parse through Parse Modules.  Parse Modules are libraries that Parse developers import into their app to use certain functionality offered by 3rd-party APIs.  Once your API is turned into a Parse Module, it will be easier for developers to use it in their applications.

There’s a whole tutorial from the Parse documentation that shows how to turn your APIs into Cloud Modules, so we won’t go through those steps.  Instead we will show a finished working code here, that you can use to pattern your Modules after.  (It is however essential to have an understanding of how Cloud Code and Cloud Modules work, so reading them first would be great).

Integrate Mashape APIs with Parse!

This is a very simple representation of how each component interacts with one  another.  (Although we are using HTML and Javascript for our app, you can access the Cloud Code from any language supported by Parse).  For this project, we will integrate the Yoda Speak API to Parse as a Cloud Module.

Integrate Mashape APIs to Parse as Cloud Module

Integrate Mashape APIs to Parse as Cloud Module

Step 1)  Application (index.html) initializes the Parse Javascript SDK and calls our Cloud Code “yodaSpeakFunction”:

<!doctype html>
  <title>My Parse App</title>
  <script type="text/javascript" src=""></script>
  <script type="text/javascript" src=""></script>
  <script type="text/javascript">
    // After installing the Parse SDK above, intialize it with your Parse application ID and key below
    Parse.initialize("<Parse application ID>", "<Parse key>");
    // Call the Cloud Code 'yodaSpeakFunction''yodaSpeakFunction', { sentence: "Hi there my name is Chris." }, {
       success: function(result) {
         // Show result as an alert
       error: function(error) {


Step 2) Define the Cloud Code “yodaSpeakFunction” (main.js in the /cloud folder) and initialize/call the Cloud Module “yodaSpeak”:

// Cloud Code 'yodaSpeakFunction'
// Import Cloud Module from /cloud folder
// Initialize Cloud Code with your Mashape key (
var yodaClient = require('cloud/yoda-1.0.0.js');
yodaClient.initialize('<Enter your Mashape key here>');
Parse.Cloud.define("yodaSpeakFunction", function(request, response) {
// Call 'yodaSpeak' Cloud Module passing in 'sentence' parameter
// Please refer to for parameter details
    	sentence: request.params.sentence
		success: function(httpResponse) {
  		error: function(httpResponse) {
    			response.error("Uh oh, something went wrong");

Step 3) The Cloud Module “yodaSpeak” (yoda-1.0.0.js in the /cloud folder) where the Mashape API is called:

// Cloud Module yoda-1.0.0.js
// Set url of Mashape API to call
var url = '';
var key = '';
module.exports = {
// Method to initialize module
  initialize: function(mashapeKey) {
    key = mashapeKey;
    return this;
// 'yodaSpeak' method to make an HTTP request call to Mashape API
// Uses Javascript Promises ('then') to execute success or error callback through 'options'
  yodaSpeak: function(params, options) {
  return Parse.Cloud.httpRequest({
    url:  url,
    headers: {
       'X-Mashape-Authorization': key
    params: params,
    }).then(function(httpResponse) {
      if (options && options.success) {
    }, function(httpResponse) {
      if (options && options.error) {


Our Parse Cloud Module ‘yoda-1.0.0.js‘ is now finished! You can drop it in your own Parse Cloud Code and start using it.

What’s next?

There’s a ton more Mashape APIs there to expose as Parse libraries.  Let me know if you’ve turned your API to a Parse Cloud Module so we can gather them here and promote them to other developers! –

Share this: