Tempico Labs SDK
Tempico Labs SDK for API. For node.js and the web.
It is the SDK for Tempico Labs API using in node.js and the browser.
It is written in clean ES6 Javascript. You can try SDK in browser.
Install
To install TmLabs for use in node or the browser with require('@tempicolabs/sdk')
, run:
npm i @tempicolabs/sdk --save
Or alternatively using Yarn, run:
yarn add @tempicolabs/sdk
SDK contain:
dist/tmlabs.umd.js
- Standard UMD package for node.js
dist/tmlabs.es.js
- ES6 Package for node.js using import
dist/tmlabs.js
- Unminified browser version
dist/tmlabs.min.js
- Minified browser version
src/*
- Sources. Javascript ES2016
Tempico Labs API Documentation
Read SDK Documentation.
Read the full API Documentation.
Usage
Try SDK in browser
Read Usage Guide
Examples
It is a wrapper for API. It uses fetch-ponyfill for HTTP requests and create-hash for hashing.
In the browser
<script src="https://cdn.jsdelivr.net/npm/@tempicolabs/sdk@latest/dist/tmlabs.min.js"></script>
<script>
var TmLabs = new TmLabs.default();
TmLabs.on('error', function(error, command){
console.error('[ SDK ERROR ]', error);
});
TmLabs.on('response', function(command, response){
console.info('response', response);
console.log('balanceRemaining', command.balanceRemaining);
});
TmLabs.on('command', function(args, command){
console.log('command', command)
});
TmLabs.fetch('dns', {
domain: 'google.com'
}).then(function(answer){
var ips = answer.content[Object.keys(answer.content)[0]];
console.log('Google.com IPs', ips)
return TmLabs.fetch('ip', {
ip: ips[0]
})
}).then(function(answer){
console.info('google ip info', answer.content)
console.log('History after IP command', TmLabs.history)
});
console.log('History with pending requests', TmLabs.history)
</script>
In Node.js
SDK also works in node.js, using the same npm package!
var TmLabs = require('@tempicolabs/sdk').default
TmLabs.on('error', function (error, command) {
console.error(error);
});
TmLabs.on('response', function (response, command) {
console.log('response', response);
console.log('balanceRemaining', command.balanceRemaining);
});
TmLabs.fetch('dns', {
domain: 'google.com'
}).then(function (response) {
console.log('after then response', response)
})
** You can use bundled version dist/tmlabs.umd.js
Package also contain FetchCommand Class for customizing fetch data from API.
For example in ES6:
import { FetchCommand } from '@tempicolabs/sdk'
(async function() {
const command = new FetchCommand({
method: 'ip'
})
command.on('error', (error, command) => {
console.error(error);
});
command.on('response', (response, command) => {
console.log('response object', response);
console.log('response code', command.status);
});
const response = await command.run({
ipaddr: '173.194.122.233'
})
console.log(response)
})();
** You can use bundled version in dist/tmlabs.es.js
for ES6
More examples you can find here
License
MIT. Copyright (c) Maxim Maximov and Tempico Labs, LLC.