What is the Itinerary API (Concur)

Have an app for travelers? Learn how to integrate with the Concur Platform using our Itinerary API. This brief video shows you how the API works and provides sample scenarios and key resources to start building.


How to Use Mashape’s Auto-Generated Java client library for your Android apps

One of the ways that Mashape facilitates easy consumption of APIs is by offering auto-generated client libraries for several programming languages, for each of the APIs.  You can see these as a row of buttons lined up in the middle-right section of each API page in Mashape.

This saves both the API provider and consumer / developer a huge amount of coding time and manpower, which lets them attend to more important things like running their core business, or brainstorming on code logic for new product features.

This post will guide you on how to use Mashape’s auto-generated Java client library to consume Mashape APIs in your Android apps.  A sample code is also provided at the end of this post so you can review and test.

There are generally two things to remember when consuming Mashape APIs in your Java Android application:

  1. The Mashape client library might require you to import class libraries that are not in your Android project, depending on the Android platform and API level you’re targetting.  These will usually manifest itself as a runtime exception.  The IDE debugger andGithub are your best friends in these cases.
  2. Depending on the Android platform you’re targetting, you may or may not be required to wrap the client call in an asynchronous class.  The latter is usually the the case for newer Android platforms.  The sample code provided here uses an asynchronous call.

Ok let’s get started!  

In this example, we will use Webknox’ Question-Answering API to create an Android app that lets the user get answers to user-typed questions.  (NOTE: You have to be subscribed to a plan to consume the Question-Answering API).  The tutorial below however will assume that you have already created your default Android project in the Eclipse IDE, and will only focus on the Mashape integration part.

1. Download the Java/Android auto-generated client library for the Question-Answering API.

When you extract the contents, you will get the following files:


Generally, you will only need to import the mashape-java-client-*.jar and theQuestionAnswering.java into your project.  These two files respectively contain the Mashape and QuestionAnswering classes and functions to make the API call and get a response.

2. Import the Mashape client library files into your project.  

The image above is my project view in Eclipse, showing where I imported the two files from number 1 to.  QuestionAnswering.java goes to the “src” folder, and the Mashape java client jar file goes to the “libs” folder.  This is of course a matter of preference, as long as the files are accessible from your build path.

You need to “include” the QuestionAnswering.java, and change the package name at the top to whatever your project is using.

Adding a jar file to the “libs” folder (in my case in Eclipse), automatically adds it to the “Android dependencies” (see image above).  In others you might have to manually add to the build path by right-clicking the main project and navigating to Build Path->Configure Build Path.   This opens up the dialog window (in the image below) where you can start adding jar files and what not, into the build path.

3. Download and import the other jar files below:

  • Apache HttpClient – download, extract, and find the httpmime jar inside.  Import it to your project in the “libs” folder.
  • Gson – extract and import to your project in the “libs” folder.

These are required by the Mashape client library.  If you already have these imported, then you don’t have to do this step.

This is how it looks like after importing.


At this point, we’re all set and we can start calling the library functions to make a call to the Mashape API endpoints.

But let’s explore first what the UI looks like, so we can understand the sequence of events before we actually call the API.


From the UI above you can see that we’re letting the user type in a question in the edittext field. The Send button will then pass the question and call our Mashape API Question-Answering, and return a response which will be shown in the Results textview.

4. Call the Mashape client library

The code that gets called for the Send button looks like below:

The “sendMessage” gets called when the Send button is clicked.  This method then does a Mashape API call wrapped in an asynchronous class “CallMashapeAsync”.  This keeps the UI happy while the library retrieves the API response.

Note that you also have to plug in your Mashape public and private keys.

Here’s the sample app in action.


You can get the sample code here.  (I’ll be updating this post when I’ve uploaded to Github).

To wrap up – Mashape lets you access the APIs faster with the auto-generated client libraries.  This example showed you how we can use the auto-generated Java client library to call Mashape APIs in Android.

As always, we welcome your feedback!  Please email us at support@mashape.com or check us out in Facebook http://www.facebook.com/mashape

Calling Mashape APIs in Node.js through REST

Hi guys, here’s a short example on how you can call APIs in Mashape through Node.js / REST.  It’s pretty straightforward.  You just need to remember that you need to make a secure call using https://, and have a generated Mashape Authorization header and plug it in the header parameter.

(You can download this source code from Github)

And then run the node.js script like so..

You would get a nice JSON reply that you can start parsing.

If you’re new to Node.js, you can check out their site at http://nodejs.org/ .  You can get either the source code or binaries for Node.js there.

We’d like to invite node.js developers out there to share with us any applications that you are planning/or have created using the APIs in Mashape.  There are tons of APIs to try!  Email me at chris@mashape.com if you have questions.

Happy coding!

Need APIs for your Windows 8 apps?

*UPDATE – You can check the video tutorial of this post here*

If you’re looking for API ingredients for your Windows 8 applications, go check out Mashape.  They are an API Marketplace for your apps.  Instead of Googling/Binging your way to find new APIs, Mashape consolidates them for you, ready to be consumed.  No lengthy documentation whatsoever.  (Well, we still have to pay attention to documentation sometimes).  At this point they have 1100+ APIs listed there.  That’s good news for you, especially if you’re in a rush to win a hackathon or something 🙂

For C#, they currently have documentation here – https://www.mashape.com/docs/consume/csharp.   However if you’re looking for an async/await sample apt for your Windows 8 app, you’re in luck.  I have posted a sample code in Github that uses HttpClient (REST) to access Mashape-hosted APIs.

Before you download and run it, you should know that –

  1. The sample uses Bitly and WordCloudMaker APIs from Mashape.
  2. For both services, you would need to get a Mashape Authentication Header.
  3. For Bitly, you need a developer login and legacy API key.
  4. For WordCloudMaker, no API key is needed.
  5. Once you have retrieved info for number 2 and 3, you can plug them in to fields at the very top of the MainPage.xaml.cs file

Once you’re done with the above, test by hitting F5.  Study the code and start copy-pasting! 🙂

If you have questions or want to share a cool Windows 8/Mashape app that you’ve built, email chris@mashape.com

Happy coding!