1mbsite-node
NodeJS Library for interacting with the 1MB API
Last updated a year ago by twistedasylummc .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install 1mbsite-node 
SYNC missed versions from official npm registry.

1mbsite NodeJS Version Weekly Downloads Licence

1mbsite NodeJS is an NPM package built to communicate with the 1mbsite API.

Note: No functions in this package are synchronous, they all have callback parameters which are run when the request package returns data

Getting Started

Before you begin, you must install the NPM package by executing the following command:

npm install 1mbsite-node --save

When using this API you will need to provide your 1mbsite account key, you can obtain your account key by logging in here and clicking the API category in the settings. There you should see your account key.

Once you have this done, you can require 1mbsite-node by doing the following:

const mbsite = require("1mbsite-node");

After requiring the 1mbsite-node library you need to create a new API instance by doing the following:

const API = mbsite.API;

Now you are ready to use the API.

Examples

Verifying your API key

Note: This process is not required as this method is called in the constructor of the API class.

API.verifyKey(function(result){
// Code here will be executed when the request has returned data
});

The verifyKey() method requires a callback parameter. A JSON object is passed through the callback and has an "error" key and a "data key". The data key here is unused but the error key will be true on success, or an error string on failure.

Deploying to your 1mb.site

API.deploy("resource", "code", function(result){
// Code here will be executed when the request has returned data
});

The deploy() method requires a string parameter for the resource you want to deploy to, another string parameter for the code you want to deploy and a callback parameter. The callback parameter passes through a JSON object which has the keys "error" and "data". Once again, the data key is unused but the error key either returns true on success, or an error string on failure.

Viewing a 1mb.site resource

API.viewSite("site name", "resource", function(result){
// Code here will be executed when the request has returned data
});

The viewSite() method requires a string parameter for the site name (a username), another string parameter for the resource you want to view and a callback parameter. The callback parameter passes through a JSON object with the keys "error" and "data". If there are no errors, the error key will be false and the data key will be a string of the code of the provided resource. If there is an error, the error will be a string error and the data key will be false.

Listing a sites resources

API.listResources("site name", function(result){
// Code here will be executed when the request has returned data
});

The listResources() method requires a string parameter for the site name (a username) and a callback parameter. The callback parameter passes through a JSON object with the keys "error" and "data". If there is an error, the error key will be an error string, but if there is no error, error will be false and the data key will be an array with all the resources on a site.

API made with :heart: by TwistedAsylumMC!

Current Tags

  • 1.0.3                                ...           latest (a year ago)

4 Versions

  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0 [deprecated]           ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 1
Last Week 6
Last Month 23
Dependencies (2)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |