@apimarket/apimarket
Client library for api.market
Last updated 9 months ago by apimarket .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @apimarket/apimarket 
SYNC missed versions from official npm registry.

About

This repository contains a library for interacting with the Aikon marketplace.

It wraps the Open Rights Exchange protocol to simplify the buying and selling of APIs in the marketplace.

Usage

Client

The apimarket_config.json is the keyfile which stores the address to connect to the ORE blockchain. It also stores the verifierAuthKey which is used to authrorize verifier to transfer the CPU amount from user's account to API provider's account for the API call. You can download this file from the api.market website.

IMPORTANT: The verifierAuthKey cannot be used for any other functions such as CPU transfer. It can only be used to authrorize verifier.

An example configuration file looks like:

{
  "accountName": "ajscf...",
  "verifierAuthKey": "U2Fsd...",
  "verifier": "https...",
  "verifierAccountName": "verif..."
}

To call an ORE-enabled API, use the config file, connect to the ORE blockchain and make the request. Here is some fully-functional sample code:

const { ApiMarketClient } = require('@apimarket/apimarket')
const config = require("apimarket_config.json");

//Setup and connect to the blockchain using your wallet and password in the config
let apimarketClient = new ApiMarketClient(config);
await apimarketClient.connect()

// call api - passing in the parameters it needs
// you specify the api to call using it's unique name registered on the ORE blockchain
// pass the query parameters as http-url-params and the body parameters as http-body-params if both query and body parameters // exist. Otherwise just pass the parameters to the apimarketClient.fetch directly.
// example: const params =  {"httpBodyParams": {
//   "imageurl": "https://console.cloud.google.com/storage/browser/apimarket-contest-2018-07-1-coffee/10465_full_jpg.jpg"
//   },
//   "httpUrlParams": {
//     "env": "staging"
//   }
// }

// if only query or body parameters exist, pass them directly to apimarketClient.fetch
const params = {"imageurl":"https://console.cloud.google.com/storage/browser/apimarket-contest-2018-07-1-coffee/10465_full_jpg.jpg"}
const response = await apimarketClient.fetch("cloud.hadron.contest-2018-07", params)

//View results
console.log(response)

Publish NPM Package

PREREQISITE:

Option 1) Use an .npmrc token

  • Include an .npmrc file in the user's root or project root e.g. ~/.npmrc or .../{projectroot}/.npmrc
  • To create an .npmrc file, copy the .npmrc.example file and insert the token (retrieved from LastPass)

OR

Option 2) log-in to npmjs with npm login (using account apimarket)

To publish an updated package...

  • Update version number in package.json (and example's package.json)
  • npm publish --tag staging - to publish staging version
  • npm publish - to publish the production version

package name will be: @apimarket/apimarket@{version}

Current Tags

  • 1.0.6                                ...           latest (9 months ago)

46 Versions

  • 1.0.6                                ...           9 months ago
  • 1.0.5                                ...           9 months ago
  • 1.0.4                                ...           9 months ago
  • 1.0.3                                ...           9 months ago
  • 1.0.2                                ...           10 months ago
  • 1.0.1                                ...           10 months ago
  • 1.0.0                                ...           a year ago
  • 0.7.19                                ...           a year ago
  • 0.7.18                                ...           a year ago
  • 0.7.17                                ...           a year ago
  • 0.7.16                                ...           a year ago
  • 0.7.15                                ...           a year ago
  • 0.7.14                                ...           a year ago
  • 0.7.13                                ...           a year ago
  • 0.7.12                                ...           a year ago
  • 0.7.11                                ...           a year ago
  • 0.7.9                                ...           a year ago
  • 0.7.8                                ...           a year ago
  • 0.7.7                                ...           a year ago
  • 0.7.6                                ...           a year ago
  • 0.7.5                                ...           a year ago
  • 0.7.4                                ...           a year ago
  • 0.7.3                                ...           a year ago
  • 0.7.1                                ...           a year ago
  • 0.7.0                                ...           a year ago
  • 0.5.26                                ...           a year ago
  • 0.5.25                                ...           a year ago
  • 0.5.24                                ...           a year ago
  • 0.5.23                                ...           a year ago
  • 0.5.22                                ...           a year ago
  • 0.5.21                                ...           a year ago
  • 0.5.20                                ...           a year ago
  • 0.5.19                                ...           a year ago
  • 0.5.18                                ...           a year ago
  • 0.5.17                                ...           a year ago
  • 0.5.16                                ...           a year ago
  • 0.5.15                                ...           a year ago
  • 0.5.14                                ...           a year ago
  • 0.5.13                                ...           a year ago
  • 0.5.12                                ...           a year ago
  • 0.5.11                                ...           a year ago
  • 0.5.10                                ...           a year ago
  • 0.5.9                                ...           a year ago
  • 0.5.8                                ...           a year ago
  • 0.5.7                                ...           a year ago
  • 0.5.6                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 46
This Month 138
Last Day 0
Last Week 46
Last Month 94
Dependencies (19)
Dev Dependencies (5)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |