2.1.9 • Published 6 years ago

smash-api v2.1.9

Weekly downloads
22
License
-
Repository
github
Last release
6 years ago

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

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

Version Check

Now use npm to resolve all dependencies by running the following command in the root directory (of the SDK folder):

npm install

Resolve Dependencies

Resolve Dependencies

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.

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.

Open Project

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.

Create new file

Save new file

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

Run file

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)

  1. Navigate to the root directory of the SDK folder from command prompt.
  2. Type mocha --recursive to run all the tests.

Method 2 (Run all tests)

  1. Navigate to the ../test/Controllers/ directory from command prompt.
  2. Type mocha * to run all the tests.

Method 3 (Run specific controller's tests)

  1. Navigate to the ../test/Controllers/ directory from command prompt.
  2. 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 in TestBootstrap.js.

Run Tests

Initialization

Authentication

In order to setup authentication in the API client, you need the following information.

ParameterDescription
uidYour user ID
secretYour Private API Key
keyYour 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

Class: AdvancedLogging

Get singleton instance

The singleton instance of the AdvancedLogging class can be accessed from the API Client.

var controller = lib.AdvancedLogging;

Method: loggingConfiguration

WAF Log Configuration

function loggingConfiguration(input, callback)

Parameters

ParameterTagsDescription
nameRequiredName of the WAF zone
originRequiredIP Address of the Web Application you wish to configure logging on
activateRequiredActivate or Disable

Example Usage

    var input = [];
        input['name'] = 'name';
        input['origin'] = 'origin';
        input['activate'] = 'activate';

    controller.loggingConfiguration(input, function(error, response, context) {

    
    });

Method: loggingInfo

WAF Log Info

function loggingInfo(input, callback)

Parameters

ParameterTagsDescription
nameRequiredName of your WAF zone
originRequiredIP Address of the Web Application
timeOptionalSpecific 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) {

    
    });

Back to List of Controllers

Class: WAFAndDDOSProtection

Get singleton instance

The singleton instance of the WAFAndDDOSProtection class can be accessed from the API Client.

var controller = lib.WAFAndDDOSProtection;

Method: wAFConfiguration

WAF and DDOS Configuration

function wAFConfiguration(input, callback)

Parameters

ParameterTagsDescription
nameRequiredName of your WAF zone
ruleRequiredRule 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) {

    
    });

Method: wAFCreation

WAF and DDOS Creation

function wAFCreation(input, callback)

Parameters

ParameterTagsDescription
originRequiredIP of the Web server you wish to protect
cnameRequiredDomain 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) {

    
    });

Back to List of Controllers

Class: Encryption

Get singleton instance

The singleton instance of the Encryption class can be accessed from the API Client.

var controller = lib.Encryption;

Method: dataAndFileEncryption

Data and File Encryption API

function dataAndFileEncryption(input, callback)

Parameters

ParameterTagsDescription
dataRequiredGIT URL, file URL, direct upload of file, or data as a query string
methodRequiredSingle or multiple encryption types to apply to data or files separated by a comma (DES, RSA, BLOWFISH, TWOFISH, AES, IDEA, PGP)
bitRequiredEncryption key size (4096)

Example Usage

    var input = [];
        input['data'] = 'data';
        input['method'] = 'method';
        input['bit'] = 15;

    controller.dataAndFileEncryption(input, function(error, response, context) {

    
    });

Back to List of Controllers

Class: CDN

Get singleton instance

The singleton instance of the CDN class can be accessed from the API Client.

var controller = lib.CDN;

Method: cDNPushZone

CDN Push Zone API

function cDNPushZone(input, callback)

Parameters

ParameterTagsDescription
cnameRequiredDomain or domain names separated by a comma you wish to allow CNAME access
fileRequiredGIT 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) {

    
    });

Method: cDNPullZone

CDN Pull Zone API

function cDNPullZone(input, callback)

Parameters

ParameterTagsDescription
originRequiredDomain or domain names separated by a comma
cnameRequiredDomain 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) {

    
    });

Back to List of Controllers

Class: DNS

Get singleton instance

The singleton instance of the DNS class can be accessed from the API Client.

var controller = lib.DNS;

Method: dNSConfiguration

DNS Configuration API

function dNSConfiguration(input, callback)

Parameters

ParameterTagsDescription
domainRequiredDomain or domain names separated by a comma
recordsRequiredRecords 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) {

    
    });

Method: dNSCreation

DNS Creation API

function dNSCreation(domain, callback)

Parameters

ParameterTagsDescription
domainRequiredDomain or domain names separated by a comma

Example Usage

    var domain = 'domain';

    controller.dNSCreation(domain, function(error, response, context) {

    
    });

Back to List of Controllers

Class: CodeObfuscation

Get singleton instance

The singleton instance of the CodeObfuscation class can be accessed from the API Client.

var controller = lib.CodeObfuscation;

Method: obfuscationAndAntiTampering

Javascript and Node.JS Obfuscation and Anti-Tampering API

function obfuscationAndAntiTampering(app, callback)

Parameters

ParameterTagsDescription
appRequiredGIT URL or ZIP package containing your APP

Example Usage

    var app = 'app';

    controller.obfuscationAndAntiTampering(app, function(error, response, context) {

    
    });

Back to List of Controllers

Class: Hosting

Get singleton instance

The singleton instance of the Hosting class can be accessed from the API Client.

var controller = lib.Hosting;

Method: hostingSetup

Node.JS and Static Web APP Hosting

function hostingSetup(input, callback)

Parameters

ParameterTagsDescription
appRequiredGIT URL or ZIP package containing your APP
domainRequiredDomain or domain names separated by a comma

Example Usage

    var input = [];
        input['app'] = 'app';
        input['domain'] = 'domain';

    controller.hostingSetup(input, function(error, response, context) {

    
    });

Back to List of Controllers

Class: DataManipulation

Get singleton instance

The singleton instance of the DataManipulation class can be accessed from the API Client.

var controller = lib.DataManipulation;

Method: httpsApiRestShApiD

Data Manipulation API

function httpsApiRestShApiD(input, callback)

Parameters

ParameterTagsDescription
dataRequiredData URL, data as a query string, or direct upload
transformRequiredTransformations to perform

Example Usage

    var input = [];
        input['data'] = 'data';
        input['transform'] = 'transform';

    controller.httpsApiRestShApiD(input, function(error, response, context) {

    
    });

Back to List of Controllers

Class: ImageManipulation

Get singleton instance

The singleton instance of the ImageManipulation class can be accessed from the API Client.

var controller = lib.ImageManipulation;

Method: imageManipulation

Image Manipulation API

function imageManipulation(input, callback)

Parameters

ParameterTagsDescription
imageRequiredImage URL or direct upload
transformRequiredTransformations to perform

Example Usage

    var input = [];
        input['image'] = 'image';
        input['transform'] = 'transform';

    controller.imageManipulation(input, function(error, response, context) {

    
    });

Back to List of Controllers

Class: Verification

Get singleton instance

The singleton instance of the Verification class can be accessed from the API Client.

var controller = lib.Verification;

Method: userAddressVerification

User Address Verification API

function userAddressVerification(input, callback)

Parameters

ParameterTagsDescription
userRequiredUsers UID, Username, or Email
aRequiredAddress Line One
saRequiredAddress Line Two
cRequiredAddress City
sRequiredAddress State or Province
zRequiredAddress Zipcode
addressOptionalAddress 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) {

    
    });

Method: userVerificationResponse

Users Verification Response API

function userVerificationResponse(input, callback)

Parameters

ParameterTagsDescription
userRequiredUsers UID, Username, Or Email
codeRequiredVerification code entered by the user

Example Usage

    var input = [];
        input['user'] = 'user';
        input['code'] = 'code';

    controller.userVerificationResponse(input, function(error, response, context) {

    
    });

Method: userVerification

User Verification API

function userVerification(user, callback)

Parameters

ParameterTagsDescription
userRequiredUsers UID, Username, Or Email

Example Usage

    var user = 'user';

    controller.userVerification(user, function(error, response, context) {

    
    });

Back to List of Controllers

Class: TwoFactorAuthenticationAPI

Get singleton instance

The singleton instance of the TwoFactorAuthenticationAPI class can be accessed from the API Client.

var controller = lib.TwoFactorAuthenticationAPI;

Method: m2FATokenResponse

Two Factor Authentication Token Reply

function m2FATokenResponse(input, callback)

Parameters

ParameterTagsDescription
userRequiredUsers UID, Username or Email
codeRequiredResponse From User Containing 2FA Code

Example Usage

    var input = [];
        input['user'] = 'user';
        input['code'] = 'code';

    controller.m2FATokenResponse(input, function(error, response, context) {

    
    });

Method: twoFactorAuthentication

Two Factor Authentication API

function twoFactorAuthentication(to, callback)

Parameters

ParameterTagsDescription
toRequiredUsers UID, Username, Email, Or Cellphone number

Example Usage

    var to = 'to';

    controller.twoFactorAuthentication(to, function(error, response, context) {

    
    });

Back to List of Controllers

Class: UserManagement

Get singleton instance

The singleton instance of the UserManagement class can be accessed from the API Client.

var controller = lib.UserManagement;

Method: getUserInfo

Get User Info API

function getUserInfo(user, callback)

Parameters

ParameterTagsDescription
userRequiredUsers User ID

Example Usage

    var user = 'user';

    controller.getUserInfo(user, function(error, response, context) {

    
    });

Method: updateUser

Update User API

function updateUser(input, queryParams, callback)

Parameters

ParameterTagsDescription
userRequiredUsers UID, Username, Or Email
avatarRequiredAvatar Image URL
customInputRequiredCustom input variable for users profile
queryParametersOptionalAdditional 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) {

    
    });

Method: deleteUser

Delete User API

function deleteUser(user, callback)

Parameters

ParameterTagsDescription
userRequiredUsers UID, Username, or Email

Example Usage

    var user = 'user';

    controller.deleteUser(user, function(error, response, context) {

    
    });

Back to List of Controllers

Class: LoginAndRegistration

Get singleton instance

The singleton instance of the LoginAndRegistration class can be accessed from the API Client.

var controller = lib.LoginAndRegistration;

Method: userRegistration

User Registration API

function userRegistration(input, queryParams, callback)

Parameters

ParameterTagsDescription
emailRequiredUsers Email
userRequiredUsers Username
passwordRequiredUsers Password
nameOptionalUsers Name
phoneOptionalUsers Cellphone Number
countrycodeOptionalUsers Country Code (US = 1)
addressOptionalUsers Address
queryParametersOptionalAdditional 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) {

    
    });

Method: userAuthentication

User Authentication API

function userAuthentication(input, callback)

Parameters

ParameterTagsDescription
userRequiredUsers Username or Email
passwordRequiredUsers Password

Example Usage

    var input = [];
        input['user'] = 'user';
        input['password'] = 'password';

    controller.userAuthentication(input, function(error, response, context) {

    
    });

Back to List of Controllers

2.1.9

6 years ago

2.1.7

6 years ago

2.1.6

6 years ago

2.1.5

6 years ago

1.2.0

7 years ago