Appery.io Server Code makes it super easy to create a custom API on the server. With Server Code you can add any app logic using JavaScript including invoke another API. Invoking another API literally takes a few minutes. Let me show you how do to it using Uber API.

When working with Uber API, one of the first request will be to find out what products are available in your area using latitude/longitude information.
This simple script will return all Uber products available in your location:
// script input var lat = request.get("lat"); var lng = request.get("lng"); var url = "https://api.uber.com/v1/products"; var token = "4dPYezRBsWmqpV_XO.............."; // send Ajax request var res = XHR2.send("GET", url + "?latitude="+lat+"&longitude="+lng, { "headers": { "Authorization": "Token " + token } }); // response response.success(res, "application/json");
The script:
- lat and lng are inputs to the script
- token can be found in your Uber developer account
- XHR2 sends an Ajax request
- The last line will return the response from Uber API
To test the script is fast, just enter sample latitude/longitude information:

What’s super nice is that when you created the script, you also created an API to invoke it:

In this post I have showed you how to expose any custom logic via a REST API. This example showed you how to invoke Uber API. You can invoke any other API as fast.
If you liked this and want to build apps fast, sign up for Appery.io plan.
Leave a Reply