smash-api v2.1.9
Getting started
Introduction
Multi-use Flexible API for:
- User:
- Login
- Registration
- User Management
- Profile Updates
Two Factor Authentication
Verifcation:
- Identity Verification
- Address Verifcation
- Cell Phone Verification
Image:
- Manipulation
- Compression
Moderation
Data:
- Manipulation
- Compression
- Conversion
- Sorting
Services:
- Node Application Hosting
- DNS Management
- CDN (Content Delivery Network)
Security:
- Encryption
- Code Obfuscation
- Platform Identification
- WAF and DDOS Protection (Web Application Firewall)
- Advanced Logging
- User:
Overview
- API Domain: api.rest.sh, api.restful.sh
This API supports both GET and POST API requests with a JSON or XML output.
~ You can post to this API via a direct body response in JSON/XML, or using URL variables/requests.
Authentication
Be sure to include your User API KEY, and UID when sending a POST or GET request to our API.
~ If domain restriction is enabled in your dashboard, please include your domain in the request and redirect headers for your API calls.
Status Codes
Success Codes:
- 200: Information Recieved
- 201: Success, Resource Created, or Updated
- 202: Proccessing
Information Codes:
- 400: Bad Request
- 401: Incorrect Credentials
- 403: Forbidden
- 406: Not Acceptable Input
- 409: Data Conflict
- 413: Payload Too Large
- 415: Un-Supported Content Type
- 451: Un-Available For Legal Reasons
Error Codes:
- 500: Internal API Error
- 501: Not Implemented
- 503: API Unavailable
- 504: Request Timeout
- 511: Authentication Required
Rate Pricing
Verification requests:
- per/1000 Requests: $50.00
User requests:
- per/1000 Requests: $0.0072
Image requests:
- per/1000 Requests: $11.87
Data requests:
- per/1MB: $0.00024
Service requests:
DNS Pricing Per Month:
- Per Hosted Zone: $1.00
- Per Traffic Flow Record: $100.00
- Per 1 Million Queries: $0.80
- Per 1 Million Latency Based Queries: $1.20
- Per 1 Million GEO Queries: $1.40
- Per Health Check: $1.00
Hosting Per Month:
- Per APP: $5.00
CDN Pricing per/1GB:
- North America: $0.17
- Europe: $0.17
- Australia: $0.28
- Asia: $0.28
- India: $0.34
- South America: $0.5
Security requests:
WAF and DDOS Pricing Per Month:
- per/1000 Web Requests: $0.0012
- Per Web Access Control List: $10.00
- Per Custom Domain Configuration: $2.00
Encryption:
- per/1000 data sets: $0.0144
- per/1MB per file: $0.00048
Code Obfuscation Per Month:
- per/APP (300 files per app): $102.00
Code Obfuscation Per Month:
- per/APP (300 files per app): $102.00
Advanced Logging:
- per/1000 Log Entries: $0.0072
How to Build
The generated SDK relies on Node Package Manager (NPM) being available to resolve dependencies. If you don't already have NPM installed, please go ahead and follow instructions to install NPM from here. The SDK also requires Node to be installed. If Node isn't already installed, please install it from here
NPM is installed by default when Node is installed
To check if node and npm have been successfully installed, write the following commands in command prompt:
node --version
npm -version
Now use npm to resolve all dependencies by running the following command in the root directory (of the SDK folder):
npm install
This will install all dependencies in the node_modules
folder.
Once dependencies are resolved, you will need to move the folder SMASH
in to your node_modules
folder.
How to Use
The following section explains how to use the library in a new project.
1. Open Project Folder
Open an IDE/Text Editor for JavaScript like Sublime Text. The basic workflow presented here is also applicable if you prefer using a different editor or IDE.
Click on File
and select Open Folder
.
Select the folder of your SDK and click on Select Folder
to open it up in Sublime Text. The folder will become visible in the bar on the left.
2. Creating a Test File
Now right click on the folder name and select the New File
option to create a new test file. Save it as index.js
Now import the generated NodeJS library using the following lines of code:
var lib = require('lib');
Save changes.
3. Running The Test File
To run the index.js
file, open up the command prompt and navigate to the Path where the SDK folder resides. Type the following command to run the file:
node index.js
How to Test
These tests use Mocha framework for testing, coupled with Chai for assertions. These dependencies need to be installed for tests to run. Tests can be run in a number of ways:
Method 1 (Run all tests)
- Navigate to the root directory of the SDK folder from command prompt.
- Type
mocha --recursive
to run all the tests.
Method 2 (Run all tests)
- Navigate to the
../test/Controllers/
directory from command prompt. - Type
mocha *
to run all the tests.
Method 3 (Run specific controller's tests)
- Navigate to the
../test/Controllers/
directory from command prompt. - Type
mocha SMASH - APIController
to run all the tests in that controller file.
To increase mocha's default timeout, you can change the
TEST_TIMEOUT
parameter's value inTestBootstrap.js
.
Initialization
Authentication
In order to setup authentication in the API client, you need the following information.
Parameter | Description |
---|---|
uid | Your user ID |
secret | Your Private API Key |
key | Your Public API Key |
API client can be initialized as following:
const lib = require('lib');
// Configuration parameters and credentials
lib.Configuration.uid = "UID"; // Your user ID
lib.Configuration.secret = "SECRET"; // Your Private API Key
lib.Configuration.key = "KEY"; // Your Public API Key
Class Reference
List of Controllers
- AdvancedLogging
- WAFAndDDOSProtection
- Encryption
- CDN
- DNS
- CodeObfuscation
- Hosting
- DataManipulation
- ImageManipulation
- Verification
- TwoFactorAuthenticationAPI
- UserManagement
- LoginAndRegistration
AdvancedLogging
Get singleton instance
The singleton instance of the AdvancedLogging
class can be accessed from the API Client.
var controller = lib.AdvancedLogging;
loggingConfiguration
WAF Log Configuration
function loggingConfiguration(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
name | Required | Name of the WAF zone |
origin | Required | IP Address of the Web Application you wish to configure logging on |
activate | Required | Activate or Disable |
Example Usage
var input = [];
input['name'] = 'name';
input['origin'] = 'origin';
input['activate'] = 'activate';
controller.loggingConfiguration(input, function(error, response, context) {
});
loggingInfo
WAF Log Info
function loggingInfo(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
name | Required | Name of your WAF zone |
origin | Required | IP Address of the Web Application |
time | Optional | Specific times or dates to lookup separated by a comma in MMDDYYHHMMSS Format ( Month Month Day Day Year Year Year Hour Hour Minute Minute Second Second 01/01/0101;24:59:01) |
Example Usage
var input = [];
input['name'] = 'name';
input['origin'] = 'origin';
input['time'] = 'time';
controller.loggingInfo(input, function(error, response, context) {
});
WAFAndDDOSProtection
Get singleton instance
The singleton instance of the WAFAndDDOSProtection
class can be accessed from the API Client.
var controller = lib.WAFAndDDOSProtection;
wAFConfiguration
WAF and DDOS Configuration
function wAFConfiguration(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
name | Required | Name of your WAF zone |
rule | Required | Rule or rules to add or update separated by a comma |
Example Usage
var input = [];
input['name'] = 'name';
input['rule'] = 'rule';
controller.wAFConfiguration(input, function(error, response, context) {
});
wAFCreation
WAF and DDOS Creation
function wAFCreation(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
origin | Required | IP of the Web server you wish to protect |
cname | Required | Domain or domain names separated by a comma you wish to allow CNAME access |
Example Usage
var input = [];
input['origin'] = 'origin';
input['cname'] = 'cname';
controller.wAFCreation(input, function(error, response, context) {
});
Encryption
Get singleton instance
The singleton instance of the Encryption
class can be accessed from the API Client.
var controller = lib.Encryption;
dataAndFileEncryption
Data and File Encryption API
function dataAndFileEncryption(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
data | Required | GIT URL, file URL, direct upload of file, or data as a query string |
method | Required | Single or multiple encryption types to apply to data or files separated by a comma (DES, RSA, BLOWFISH, TWOFISH, AES, IDEA, PGP) |
bit | Required | Encryption key size (4096) |
Example Usage
var input = [];
input['data'] = 'data';
input['method'] = 'method';
input['bit'] = 15;
controller.dataAndFileEncryption(input, function(error, response, context) {
});
CDN
Get singleton instance
The singleton instance of the CDN
class can be accessed from the API Client.
var controller = lib.CDN;
cDNPushZone
CDN Push Zone API
function cDNPushZone(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
cname | Required | Domain or domain names separated by a comma you wish to allow CNAME access |
file | Required | GIT URL, file URL, or direct upload of file |
Example Usage
var input = [];
input['cname'] = 'cname';
input['file'] = 'file';
controller.cDNPushZone(input, function(error, response, context) {
});
cDNPullZone
CDN Pull Zone API
function cDNPullZone(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
origin | Required | Domain or domain names separated by a comma |
cname | Required | Domain or domain names separated by a comma you wish to allow CNAME access |
Example Usage
var input = [];
input['origin'] = 'origin';
input['cname'] = 'cname';
controller.cDNPullZone(input, function(error, response, context) {
});
DNS
Get singleton instance
The singleton instance of the DNS
class can be accessed from the API Client.
var controller = lib.DNS;
dNSConfiguration
DNS Configuration API
function dNSConfiguration(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
domain | Required | Domain or domain names separated by a comma |
records | Required | Records to append to domain separated by a comma (a;www.mydomain.com;127.0.0.0,cname;mydomain.com;otherdomain.com) |
Example Usage
var input = [];
input['domain'] = 'domain';
input['records'] = 'records';
controller.dNSConfiguration(input, function(error, response, context) {
});
dNSCreation
DNS Creation API
function dNSCreation(domain, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
domain | Required | Domain or domain names separated by a comma |
Example Usage
var domain = 'domain';
controller.dNSCreation(domain, function(error, response, context) {
});
CodeObfuscation
Get singleton instance
The singleton instance of the CodeObfuscation
class can be accessed from the API Client.
var controller = lib.CodeObfuscation;
obfuscationAndAntiTampering
Javascript and Node.JS Obfuscation and Anti-Tampering API
function obfuscationAndAntiTampering(app, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
app | Required | GIT URL or ZIP package containing your APP |
Example Usage
var app = 'app';
controller.obfuscationAndAntiTampering(app, function(error, response, context) {
});
Hosting
Get singleton instance
The singleton instance of the Hosting
class can be accessed from the API Client.
var controller = lib.Hosting;
hostingSetup
Node.JS and Static Web APP Hosting
function hostingSetup(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
app | Required | GIT URL or ZIP package containing your APP |
domain | Required | Domain or domain names separated by a comma |
Example Usage
var input = [];
input['app'] = 'app';
input['domain'] = 'domain';
controller.hostingSetup(input, function(error, response, context) {
});
DataManipulation
Get singleton instance
The singleton instance of the DataManipulation
class can be accessed from the API Client.
var controller = lib.DataManipulation;
httpsApiRestShApiD
Data Manipulation API
function httpsApiRestShApiD(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
data | Required | Data URL, data as a query string, or direct upload |
transform | Required | Transformations to perform |
Example Usage
var input = [];
input['data'] = 'data';
input['transform'] = 'transform';
controller.httpsApiRestShApiD(input, function(error, response, context) {
});
ImageManipulation
Get singleton instance
The singleton instance of the ImageManipulation
class can be accessed from the API Client.
var controller = lib.ImageManipulation;
imageManipulation
Image Manipulation API
function imageManipulation(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
image | Required | Image URL or direct upload |
transform | Required | Transformations to perform |
Example Usage
var input = [];
input['image'] = 'image';
input['transform'] = 'transform';
controller.imageManipulation(input, function(error, response, context) {
});
Verification
Get singleton instance
The singleton instance of the Verification
class can be accessed from the API Client.
var controller = lib.Verification;
userAddressVerification
User Address Verification API
function userAddressVerification(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
user | Required | Users UID, Username, or Email |
a | Required | Address Line One |
sa | Required | Address Line Two |
c | Required | Address City |
s | Required | Address State or Province |
z | Required | Address Zipcode |
address | Optional | Address as a one line input separated by commas |
Example Usage
var input = [];
input['user'] = 'user';
input['a'] = 'a';
input['sa'] = 'sa';
input['c'] = 'c';
input['s'] = 's';
input['z'] = 15;
input['address'] = 'address';
controller.userAddressVerification(input, function(error, response, context) {
});
userVerificationResponse
Users Verification Response API
function userVerificationResponse(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
user | Required | Users UID, Username, Or Email |
code | Required | Verification code entered by the user |
Example Usage
var input = [];
input['user'] = 'user';
input['code'] = 'code';
controller.userVerificationResponse(input, function(error, response, context) {
});
userVerification
User Verification API
function userVerification(user, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
user | Required | Users UID, Username, Or Email |
Example Usage
var user = 'user';
controller.userVerification(user, function(error, response, context) {
});
TwoFactorAuthenticationAPI
Get singleton instance
The singleton instance of the TwoFactorAuthenticationAPI
class can be accessed from the API Client.
var controller = lib.TwoFactorAuthenticationAPI;
m2FATokenResponse
Two Factor Authentication Token Reply
function m2FATokenResponse(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
user | Required | Users UID, Username or Email |
code | Required | Response From User Containing 2FA Code |
Example Usage
var input = [];
input['user'] = 'user';
input['code'] = 'code';
controller.m2FATokenResponse(input, function(error, response, context) {
});
twoFactorAuthentication
Two Factor Authentication API
function twoFactorAuthentication(to, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
to | Required | Users UID, Username, Email, Or Cellphone number |
Example Usage
var to = 'to';
controller.twoFactorAuthentication(to, function(error, response, context) {
});
UserManagement
Get singleton instance
The singleton instance of the UserManagement
class can be accessed from the API Client.
var controller = lib.UserManagement;
getUserInfo
Get User Info API
function getUserInfo(user, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
user | Required | Users User ID |
Example Usage
var user = 'user';
controller.getUserInfo(user, function(error, response, context) {
});
updateUser
Update User API
function updateUser(input, queryParams, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
user | Required | Users UID, Username, Or Email |
avatar | Required | Avatar Image URL |
customInput | Required | Custom input variable for users profile |
queryParameters | Optional | Additional optional query parameters are supported by this method |
Example Usage
var input = [];
input['user'] = 'user';
input['avatar'] = 'avatar';
input['customInput'] = custom input;
// key-value map for optional query parameters
var queryParams = [];
controller.updateUser(input, queryParams, function(error, response, context) {
});
deleteUser
Delete User API
function deleteUser(user, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
user | Required | Users UID, Username, or Email |
Example Usage
var user = 'user';
controller.deleteUser(user, function(error, response, context) {
});
LoginAndRegistration
Get singleton instance
The singleton instance of the LoginAndRegistration
class can be accessed from the API Client.
var controller = lib.LoginAndRegistration;
userRegistration
User Registration API
function userRegistration(input, queryParams, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
Required | Users Email | |
user | Required | Users Username |
password | Required | Users Password |
name | Optional | Users Name |
phone | Optional | Users Cellphone Number |
countrycode | Optional | Users Country Code (US = 1) |
address | Optional | Users Address |
queryParameters | Optional | Additional optional query parameters are supported by this method |
Example Usage
var input = [];
input['email'] = 'email';
input['user'] = 'user';
input['password'] = 'password';
input['name'] = 'name';
input['phone'] = 15;
input['countrycode'] = 15;
input['address'] = 'address';
// key-value map for optional query parameters
var queryParams = [];
controller.userRegistration(input, queryParams, function(error, response, context) {
});
userAuthentication
User Authentication API
function userAuthentication(input, callback)
Parameters
Parameter | Tags | Description |
---|---|---|
user | Required | Users Username or Email |
password | Required | Users Password |
Example Usage
var input = [];
input['user'] = 'user';
input['password'] = 'password';
controller.userAuthentication(input, function(error, response, context) {
});