API documentation

Connecting your device to our REST API is very easy !!

Notarize data

Just call the tssApi function, personalizing its 3 parameters: userId, apiKey and data.

In javascript/nodejs, just copy and paste this code:

// you only have to personalize these 3 values:
const userId  = '10';                                                                // get your API User Number at https://console.timestampserver.com
const apiKey  = '76d90aa07f4e44a233a756bc47cb5215dc3329ca7e1f7be33a2dad68990bb94b';  // get your API key         at https://console.timestampserver.com
const data    = 'this is the data string you want to certify on the Blockchain';      // data string


// and call the API function:
tssApi(userId, apiKey, data);


// function definition
async function tssApi(userId, apiKey, data) {
  try {
    // token
    const jwt = require("jsonwebtoken");
    const token	= 'Bearer ' + jwt.sign({"data": data}, apiKey, { algorithm: 'HS256', expiresIn: '10m'});
    
    // http request
    const axios = require('axios');
    let obj = {};
        obj.url                     = 'https://api.timestampserver.com/v1/post';
        obj.port                    = 3000;
        obj.method                  = 'post';
        obj.headers                 = {};
        obj.headers.User            = '' + userId;
        obj.headers.Authorization   = '' + token;
        obj.headers["Content-Type"] = 'application/json';
        obj.data                    = {};
    const response = await axios(obj);
    
	// do whatever you want with the response, i.e.:
	console.log(response.data);
    
	return response;
  }
  catch (error) {
    // do whatever you want to catch the response error, i.e.:
	console.log(error);
  }
}

If everything goes right, the function will return a response object with the "txid" (the Bitcoin transaction ID) in the response.data.txid property.
If any error happened, the function will return a response object with the details of the error.


In this example we have used 2 external modules:

These modules need to be installed in your folder project prior to calling the tssApi function.

You can install them calling NPM in your command line:

npm install jsonwebtoken axios

You can upload up to 5555 bytes of data in each HTTP request to our API.
If you need bigger data size, please contact us !!


------------------------------------------------------------------

Check notarization

You can check the notarized data sending a HTTPS GET request to the endpoint https://api.timestampserver.com/v1/get/txid
setting the parameter txid to <txid> (the txid of the notarization you want to check).

In javascript/nodejs, just copy and paste this code:

// you only have to personalize 1 parameter:
const txid  = 'cf5aafbd3b14fa3a69ae1bd1a4d71465a04337ff44b76ea0e6133239ff7752a0';

// call the function:
checkNotarization(txid);


// function definition
async function checkNotarization(txid) {
  try {
    
    // http request
    const axios = require('axios');
    let obj = {};
        obj.url                     = 'https://api.timestampserver.com/v1/get/txid/?txid=' + txid;
        obj.port                    = 3000;
        obj.method                  = 'GET';
    const response = await axios(obj);
    
    // do whatever you want with the response, i.e.:
    console.log(response.data);
      //[
      //  {
      //    txid: 'cf5aafbd3b14fa3a69ae1bd1a4d71465a04337ff44b76ea0e6133239ff7752a0',
      //    network: 'mainnet',
      //    datetime: '2022-09-06T18:42:02.000Z',
      //    data: '7b896d3bc9654981de44087f907090b54ed1e2d562e3d377a6143f6354eb1fdd 543426369119'
      //  }
      //]
    
    return response;
  }
  catch (error) {
    // do whatever you want to catch the response error, i.e.:
    console.log(error);
  }
}

You can also check the notarized data of a transaction ID (txid) from your browser.
For example, to get the data from txid cf5aafbd3b14fa3a69ae1bd1a4d71465a04337ff44b76ea0e6133239ff7752a0, type:

https://api.timestampserver.com/v1/get/txid/?txid=cf5aafbd3b14fa3a69ae1bd1a4d71465a04337ff44b76ea0e6133239ff7752a0


------------------------------------------------------------------

Ping

You can check if the TimeStampServer REST API endpoint is running
sending a HTTPS GET request to
(or accessing from your browser to):

https://api.timestampserver.com/v1/ping


------------------------------------------------------------------


Last notarization

You can check the last transaction submitted from TimeStampServer REST API to the Blockchain nodes
sending a HTTPS GET request to
(or accessing from your browser to):

https://api.timestampserver.com/v1/get/lastTx


------------------------------------------------------------------