1.0.0 • Published 5 years ago

cos-sdk-js v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

cos-sdk-js

cos-sdk-js - JavaScript SDK for accessing contentos chain.

This SDK is automatically generated by the Swagger Codegen project with contentos Swagger-apis

Installation

For Node.js

npm

To publish the library as a npm, please follow the procedure in "Publishing npm packages".

Then install it via:

npm install cos-sdk-js --save

For browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file, that's to say your javascript file where you actually use this library):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}

Getting Started

Please follow the installation instruction and execute the following JS code:

var Cos = require('cos-sdk-js');

var api = new Cos.ApiServiceApi()

var body = new rpc.GrpcpbGetAccountByNameRequest(); 

var account_name = new rpc.PrototypeaccountName();

account_name.value = "initminer";

body.account_name = account_name;


var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.getAccountByName(body, callback);

Documentation for API Endpoints

All URIs are relative to http://localhost:8080

MethodHTTP requestDescription
broadcastTrxPOST /v1/broadcast_trx
getAccountByNamePOST /v1/get_account_by_name
getAccountRewardByNamePOST /v1/get_account_reward_by_name
getBlockTransactionsByNumPOST /v1/get_trx_by_num
getChainStatePOST /v1/chain_state
getFollowCountByNamePOST /v1/get_follow_count_by_name
getFollowerListByNamePOST /v1/get_follower_list_by_name
getFollowingListByNamePOST /v1/get_following_list_by_name
getPostListByCreatedPOST /v1/get_post_list_by_created
getReplyListByPostIdPOST /v1/get_reply_list_by_postid
getTrxByIdPOST /v1/get_trx_by_id
getWitnessListPOST /v1/get_witness_list

Documentation for Models

Documentation for Authorization

All endpoints do not require authorization.