CloudRail SI for node.js
Integrate Multiple Services With Just One API
CloudRail is an API integration solution which abstracts multiple APIs from different providers into a single and universal interface.
---
---
Learn more about CloudRail at https://cloudrail.com
Full documentation can be found here
With CloudRail, you can easily integrate external APIs into your application.
CloudRail provides abstracted interfaces that take several services and then exposes a developer-friendly API that uses common functions between all providers.
This means that, for example, upload() works in exactly the same way for Dropbox as it does for Google Drive, OneDrive, and other Cloud Storage Services, and getEmail() works similarly the same way across all social networks.
Current Interfaces
Interface | Included Services |
---|
Cloud Storage | Dropbox, Google Drive, OneDrive, OneDrive Business, Box, Egnyte |
Business Cloud Storage | Amazon S3, Microsoft Azure, Rackspace, Backblaze |
Social Profile | Facebook, GitHub, Google+, LinkedIn, Slack, Twitter, Windows Live, Yahoo, Instagram |
Social Interaction | Facebook, Twitter |
Payment | PayPal, Stripe |
Email | Maljet, Sendgrid |
SMS | Twilio, Nexmo |
Point of Interest | Google Places, Foursquare, Yelp |
Cloud Storage Interface:
- Dropbox
- Box
- Google Drive
- Microsoft OneDrive
- Microsoft OneDrive for Business
- Egnyte
Features:
- Download files from Cloud Storage.
- Upload files to Cloud Storage.
- Get Meta Data of files, folders and perform all standard operations (copy, move, etc) with them.
- Retrieve user and quota information
- Generate share links for files and folders
- Get thumbnails for images
Full Documentation
Code Example:
const cloudrail = require("cloudrail-si");
cloudrail.Settings.setKey("[CloudRail License Key]");
let cs = new cloudrail.services.Dropbox(redirectReceiver, "[clientIdentifier]", "[clientSecret]", "[redirectUri]", "[state]");
cs.createFolder("/TestFolder", (err) => {
if (err) throw err;
let fileStream = fs.createReadStream("UserData.csv");
let size = fs.statSync("UserData.csv").size;
cs.upload("/TestFolder/Data.csv", fileStream, size, false, (err) => {
if (err) throw err;
console.log("Upload successfully finished");
});
});
Business/Bucket Cloud Storage Interface:
- Amazon Web Services S3
- Microsoft Azure
- Rackspace
- Backblaze
Features
- Create, delete and list buckets
- Upload files
- Download files
- List files in a bucket and delete files
- Get file metadata (last modified, size, etc.)
Full Documentation
Code Example
const cloudrail = require("cloudrail-si");
cloudrail.Settings.setKey("[CloudRail License Key]");
let bcs = new cloudrail.services.Backblaze(null, "[accountId]", "[appKey]");
bcs.createBucket("myNewBucket", (err, bucket) => {
if (err) throw err;
let fileStream = fs.createReadStream("UserData.csv");
let size = fs.statSync("UserData.csv").size;
bcs.upload(bucket, "Data.csv", fileStream, size, (err) => {
if (err) throw err;
console.log("Upload successfully finished");
});
});
Social Profile Interface:
- Facebook
- Github
- Google Plus
- LinkedIn
- Slack
- Twitter
- Windows Live
- Yahoo
- Instagram
Features
- Get profile information, including full names, emails, genders, date of birth, and locales.
- Retrieve profile pictures.
- Login using the Social Network.
Full Documentation
Code Example:
const cloudrail = require("cloudrail-si");
cloudrail.Settings.setKey("[CloudRail License Key]");
let profile = new cloudrail.services.Facebook(redirectReceiver, "[clientIdentifier]", "[clientSecret]", "[redirectUri]", "[state]");
profile.getFullName((err, fullName) => {
if (err) throw err;
console.log("User's full name is " + fullName);
});
profile.getEmail((err, email) => {
if (err) throw err;
console.log("User's email address is " + email);
});
Social Interaction Interface:
Features
- Get the IDs of a user's friends/followers. Works well with the Profile interface's "login with" to check if two of your users are friends on a platform
- Post to a user's wall
Full Documentation
Code Example:
const cloudrail = require("cloudrail-si");
cloudrail.Settings.setKey("[CloudRail License Key]");
let social = new cloudrail.services.Twitter(redirectReceiver, "[clientIdentifier]", "[clientSecret]", "[redirectUri]");
social.getConnections((err, connIds) => {
if (err) throw err;
console.log("User has " + connIds.length + " connections");
});
social.postUpdate("Hello from CloudRail", (err) => {
if (err) throw err;
console.log("Update posted");
});
Payment Interface:
Features
- Perform charges
- Refund previously made charges
- Manage subscriptions
Full Documentation
Code Example
const cloudrail = require("cloudrail-si");
cloudrail.Settings.setKey("[CloudRail License Key]");
let payment = new cloudrail.services.PayPal(null, true, "[clientIdentifier]", "[clientSecret]");
let source = new cloudrail.types.CreditCard(null, 6, 2021, "xxxxxxxxxxxxxxxx", "visa", "<FirstName>", "<LastName>", null);
payment.createCharge(500, "USD", source, (err, charge) => {
if (err) throw err;
console.log("Successfully charged " + charge.amount + " " + charge.currency);
});
Email Interface:
Features
Full Documentation
Code Example
const cloudrail = require("cloudrail-si");
cloudrail.Settings.setKey("[CloudRail License Key]");
let email = new cloudrail.services.Sendgrid(null, "[APIKey]");
email.sendEmail("info@cloudrail.com", "CloudRail", ["foo@bar.com", "bar@foo.com"], "Welcome", "Hello from CloudRail", null, null, null, (err) => {
if (err) throw err;
console.log("Email successfully sent");
});
SMS Interface:
Features
Full Documentation
Code Example
const cloudrail = require("cloudrail-si");
cloudrail.Settings.setKey("[CloudRail License Key]");
let sms = new cloudrail.services.Twilio(null, "[clientIdentifier]", "[clientSecret]");
sms.sendSMS("CloudRail", "+4912345678", "Hello from CloudRail", (err) => {
if (err) throw err;
console.log("SMS successfully sent");
});
Points of Interest Interface:
- Google Places
- Foursquare
- Yelp
Features
- Get a list of POIs nearby
- Filter by categories or search term
Full Documentation
Code Example
const cloudrail = require("cloudrail-si");
cloudrail.Settings.setKey("[CloudRail License Key]");
let poi = new cloudrail.services.GooglePlaces(null, "[apiKey]");
poi.getNearbyPOIs(49.4557091, 8.5279138, 1000, "restaurant", null, (err, pois) => {
if (err) throw err;
console.log("Amount of locations called 'restaurant' in a 1 km radius around the given coordinates: " + pois.length);
});
More interfaces are coming soon.
Advantages of Using CloudRail
-
Consistent Interfaces: As functions work the same across all services, you can perform tasks between services simply.
-
Easy Authentication: CloudRail includes easy ways to authenticate, to remove one of the biggest hassles of coding for external APIs.
-
Switch services instantly: One line of code is needed to set up the service you are using. Changing which service is as simple as changing the name to the one you wish to use.
-
Simple Documentation: There is no searching around Stack Overflow for the answer. The CloudRail Wiki is regularly updated, clean, and simple to use.
-
No Maintenance Times: The CloudRail Libraries are updated when a provider changes their API.
-
Direct Data: Everything happens directly in the Library. No data ever passes a CloudRail server.
NPM
npm install cloudrail-si
Typescript
(this only concerns Typescript users)
The package includes an index.d.ts file. To use the typings provided, include services and types like so:
import {PointsOfInterest} from "cloudrail-si/interfaces/PointsOfInterest";
import {Foursquare} from "cloudrail-si/services/Foursquare";
import {POI} from "cloudrail-si/types/POI";
let poi:PointsOfInterest = new Foursquare(null, "[clientID]", "[clientSecret]");
poi.getNearbyPOIs(49.4557091, 8.5279138, 1000, "restaurant", null, (err:Error, pois:POI[]) => {
if (err) console.log(err);
console.log("Amount of locations called 'restaurant' in a 1 km radius around the given coordinates: " + pois.length);
});
Examples
Check out https://github.com/CloudRail/cloudrail-si-node-sdk/tree/master/examples for examples of how to e.g. implement a redirectReceiver and more complex use cases.
License Key
CloudRail provides a developer portal which offers usage insights for the SDKs and allows you to generate license keys.
It's free to sign up and generate a key.
Head over to https://developers.cloudrail.com
Pricing
CloudRail is free to use as long as your app is free as well. Learn more about our pricing on https://cloudrail.com/cloudrail-pricing/
Other Platforms
CloudRail is also available for other platforms like Android, iOS and Java. You can find all libraries on https://cloudrail.com
Questions?
Get in touch at any time by emailing us: support@cloudrail.com
or
Tag a question with cloudrail on StackOverflow