originstamp-client-fetch
TypeScript icon, indicating that this package has built-in type declarations

2.0.3 • Public • Published

OriginStamp TypeScript Fetch Client

Build Status

A TypeScript Fetch implementation of the OriginStamp API. For endpoint documentation see OriginStamp Documentation.

For more information, please visit https://originstamp.com.

Install

npm install originstamp-client-fetch@2.0.0 --save

Specifications

Environment

  • Node.js
  • Webpack
  • Browserify

Language level

  • ES5 - you must have a Promises/A+ library installed
  • ES6

Module system

  • CommonJS
  • ES6 module system

It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via package.json. (Reference)

Getting Started

The following contains an example for Angular (can be easily transferred to other TypeScript/JavaScript projects):

import {Component} from '@angular/core';
import {APIKeyApi, BulkApi, ProofApi, SchedulerApi, TimestampApi, WebhookApi} from 'originstamp-client-fetch';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})
export class AppComponent {

    constructor() {
        this.test();
    }

    private test(): void {
        const hash = '<INPUT_HASH>';
        const seedId = '<SEED_ID>';
        const authorization = '<YOUR_API_KEY>';


        const apiKeyApi = new APIKeyApi();
        apiKeyApi.getApiKeyUsage(authorization).then(result => {
            console.log(result);
        });

        const schedulerApi = new SchedulerApi();
        schedulerApi.getActiveCurrencies(authorization).then(result => {
            console.log(result);
        });

        const timestampApi = new TimestampApi();
        timestampApi.createTimestamp(authorization, {
            hash: hashString,
            comment: 'comment',
            notifications: null
        }).then(result => {
            console.log(result);
        });

        timestampApi.getHashStatus(authorization, hashString).then(result => {
            console.log(result);
        });

        timestampApi.getSeedStatus(authorization, seedId).then(result => {
            console.log(result);
        });

        const proofApi = new ProofApi();
        proofApi.getProof(authorization, {proof_type: 1, hash_string: hashString, currency: 0}).then(result => {
            console.log(result);
        });

        const bulkApi = new BulkApi();
        bulkApi.createBulkTimestamp(authorization, {
            timestamps: [{
                hash: hashString,
                comment: 'comment',
                notifications: null
            }]
        }).then(result => {
            console.log(result);
        });
        bulkApi.getSeedStatus(authorization, seedId).then(result => {
            console.log(result);
        });

        const webhookApi = new WebhookApi();
        // ...
    }
}

For more information on the requests and the DTOs, we refer to our JavaScript Client.

Author

mail@originstamp.com

Package Sidebar

Install

npm i originstamp-client-fetch

Weekly Downloads

15

Version

2.0.3

License

MIT

Unpacked Size

249 kB

Total Files

14

Last publish

Collaborators

  • pehret
  • dennis-tra-os
  • danmuf