How to start using SPDR using APIs

How to start using SPDR using APIs

SPDR Admin
·Jan 17, 2022·

3 min read

How to start using SPDR using APIs

Register API (One time)

The user can register to the portal: thespiderman.io/register

API.png

The user can give their details like email, number and company name and set up a username and password.

Login using the API

Once the user gets the username and password, he/she can call the API to get the auth token from login API. The auth token is set for 1 hour at the moment. This can be changed based on the request from the customer.

curl --location --request POST 'https://hlapi.getthespiderman.com/login' \
--header 'Content-Type: application/json' \
--data-raw '{
    "username": "Test.User",
    "password": "SamplePassword123!"
}'

Once the auth token is received after login, it can be used to call the APIs for create, retrieve, update assets.

Register with HyperLedger

Once you get the auth token, you can register your org with SPDR Hyperledger using the following API:

curl --location --request POST 'https://hlapi.getthespiderman.com/hl/register' \
--header 'Authorization: eyJraWQiOiIzRVhMd1NPU1B0SnVyN3VqWGdQQXdlVzhQSmE4NXNCOGR3N3N6c01hWlpnPSIsImFsZyI6IlJTMjU2In0.eyJvcmlnaW5fanRpIjoiMGZhYmJiZTktYTE1YS00ZTI5LWI2YjUtNGJiNDIzNjRjN2U4Iiwic3ViIjoiNmVkYmM5NDEtZDVlMC00NTQ3LTkzYzQtY2I1NGM4Njk2OWExIiwiZXZlbnRfaWQiOiIzZmM3NTU5NS0zMDcyLTQxMWItOTFkYy0yM2QzMDE3YTZiYzciLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiYXV0aF90aW1lIjoxNjQyMTYyMDg4LCJpc3MiOiJodHRwczpcL1wvY29nbml0by1pZHAuYXAtc291dGgtMS5hbWF6b25hd3MuY29tXC9hcC1zb3V0aC0xX0k1NHB3OWYxMCIsImV4cCI6MTY0MjE2NTY4OCwiaWF0IjoxNjQyMTYyMDg4LCJqdGkiOiI5ZmIxMjcyYS1iNDQwLTQwNDItOTBjNi03YTNjMTE4NGE5YTUiLCJjbGllbnRfaWQiOiI3Ym91YzBmb3FxcTlucTcwZWxodTUwbGhiNiIsInVzZXJuYW1lIjoic3VzaGFudHRlc3QyOSJ9.sEccqZNNleosIPykVY_RdAx1kbIk-tlv02I0MvA7-AQyw8ZW-lBoFaLcfzWZ9VAPs_2QFhQeJ_8aJFuStT6JzCuY1F3F-dm1tUTGgAWiViC88AOjSZrfkZM3lfa-pb36uquuxL2lc4z5MFIton56c1ATYSRFDEDm-Ng5mMHjdTEOxSLL7mWQfYLyQZhkYxnsKlOeDmss_V68Pbd7JUAlY0hwuX7jsN4CQURdeBGMgowuAj1NvDr83qUBlsxboqUZNRF4L9RaxGGCZ9SZd5mmVLvN59wCsqA2lG44OY_XEOVuNlejYmapl2rXrhJ1hZpEmr7slMLN_W8fyFw3nlktIw' \
--header 'Content-Type: application/json' \
--data-raw '{
    "org": "Org2MSP",
    "userId": "tom2"
}'

Create Asset API

The following API can be called to create a new asset into theSpiderman.

curl --location --request POST 'https://hlapi.getthespiderman.com/hl/createAsset' \
--header 'Authorization: eyJraWQiOiIzRVhMd1NPU1B0SnVyN3VqWGdQQXdlVzhQSmE4NXNCOGR3N3N6c01hWlpnPSIsImFsZyI6IlJTMjU2In0.eyJvcmlnaW5fanRpIjoiOWZlOWZmMDItYTA2Zi00MzAzLTg0MTQtNjRkMzdiNDNlNDAzIiwic3ViIjoiNmVkYmM5NDEtZDVlMC00NTQ3LTkzYzQtY2I1NGM4Njk2OWExIiwiZXZlbnRfaWQiOiI2MDY2ZGJjOC0xMzAwLTRjOTYtODM1My0wYWU3YjAzM2Q0YzYiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiYXV0aF90aW1lIjoxNjQyMTY2MTE1LCJpc3MiOiJodHRwczpcL1wvY29nbml0by1pZHAuYXAtc291dGgtMS5hbWF6b25hd3MuY29tXC9hcC1zb3V0aC0xX0k1NHB3OWYxMCIsImV4cCI6MTY0MjE2OTcxNSwiaWF0IjoxNjQyMTY2MTE1LCJqdGkiOiIyNDNhZWFhZC0yMGQxLTQ0YzctODcxNy0yZjg3NDQ5NjBjYTkiLCJjbGllbnRfaWQiOiI3Ym91YzBmb3FxcTlucTcwZWxodTUwbGhiNiIsInVzZXJuYW1lIjoic3VzaGFudHRlc3QyOSJ9.H_35IwWBP3UGNAPFbbBzcxbSBgSeNpL3BIZ3wZwNlswE7AQyINbIdwv9sTWBKTyi-gPcuStitMUZlQLSj7qc2jJ6Y9pLBI3L0ExshiOiobKpu42jFa5DWL5W7f24ATwr-ZmtuGOoNZWveOZZCLyE95ZoSgTot9APAHBJGWHqVBLHlGids-m3_VeDekOCDk3OpTvY4uk2jCtcrjHFGTmwRBk7sIau3t0Y5xxQVi8GHV-gNsbeGbzk9C-gaRjmGKtOcMLRt_fgfUj4jja8ZFU557OTJ4bsSakDI9vbKR3H09_FjugSzRd3IDAGrVKQDCQ6p69xqYlFG1FgFtqxu0ZMgQ' \
--header 'Content-Type: application/json' \
--data-raw '{
    "org" : "Org2MSP",
    "userId" : "tom2",
    "data" : {
        "ID" : "assetss12900",
        "color" : "green",
        "filehash": "aaaaa",
        "size" : 10,
        "appraisedValue" :500,
        "owner" : "TestUser"
    }
}'

Transfer Asset

If you want to transfer any existing asset to a new owner, you can use the following API to execute the transaction:

curl --location --request POST 'https://hlapi.getthespiderman.com/hl/transferAsset' \
--header 'Authorization: eyJraWQiOiIzRVhMd1NPU1B0SnVyN3VqWGdQQXdlVzhQSmE4NXNCOGR3N3N6c01hWlpnPSIsImFsZyI6IlJTMjU2In0.eyJvcmlnaW5fanRpIjoiYjUzNmZiMzctMGRkYi00MTYyLTkyMGQtYjdlZmE1ZWQyYjRmIiwic3ViIjoiNmVkYmM5NDEtZDVlMC00NTQ3LTkzYzQtY2I1NGM4Njk2OWExIiwiZXZlbnRfaWQiOiI3MWJjYjZmYi0zNjdiLTRiOGMtYWQxMC1lODI1Mjc3ZDJkNGYiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiYXV0aF90aW1lIjoxNjQyMTY5ODU0LCJpc3MiOiJodHRwczpcL1wvY29nbml0by1pZHAuYXAtc291dGgtMS5hbWF6b25hd3MuY29tXC9hcC1zb3V0aC0xX0k1NHB3OWYxMCIsImV4cCI6MTY0MjE3MzQ1NCwiaWF0IjoxNjQyMTY5ODU0LCJqdGkiOiJmZWRmZGQwOC1kMTA3LTQxZTAtYWY1NS01ZDY0MzFlMmJkNWMiLCJjbGllbnRfaWQiOiI3Ym91YzBmb3FxcTlucTcwZWxodTUwbGhiNiIsInVzZXJuYW1lIjoic3VzaGFudHRlc3QyOSJ9.egszHeYmw-8fmbaBsHoQzuDRQcKP3lzayw59DZXC3EsN5RWdeUYmk4iRFzGETLgJeos1keh-mx60xeM4TP3NZqyIYO0yZbgT7mlXNDDSUaFcMhfErwOJRzeZl5NwhcKc6k520QjPFvW8ThCsezciS8XHOypCtmNVDUNyOPZ6h9-ASWElbOQ_7Y7gexm3tPde-9kt7rJS302wE_3wUcm3XF3n7QQisY4M0x0UNJLgmJIHuSXrE1WU4A0YP1XR05ZoM1QB4NN3zdj5s1wYe6_d3pLtl9DhP4k4CJmbzotO_ODPen8LjRMxyHVxXhB0-Y9xfPabK7xn-s_yL_Xc-IrSjA' \
--header 'Content-Type: application/json' \
--data-raw '{
    "org" : "Org1MSP",
    "userId" : "tom6",
    "data" : {
        "id" : "assetss32900",
        "newOwner" : "new london"
    }
}'

Retrieve all assets

The following API can be called to retrieve all the assets created by the user.

curl --location --request GET 'https://hlapi.getthespiderman.com/hl/getAllAssets?org=Org1MSP&userId=tom' \
--header 'Authorization: eyJraWQiOiIzRVhMd1NPU1B0SnVyN3VqWGdQQXdlVzhQSmE4NXNCOGR3N3N6c01hWlpnPSIsImFsZyI6IlJTMjU2In0.eyJvcmlnaW5fanRpIjoiOWZlOWZmMDItYTA2Zi00MzAzLTg0MTQtNjRkMzdiNDNlNDAzIiwic3ViIjoiNmVkYmM5NDEtZDVlMC00NTQ3LTkzYzQtY2I1NGM4Njk2OWExIiwiZXZlbnRfaWQiOiI2MDY2ZGJjOC0xMzAwLTRjOTYtODM1My0wYWU3YjAzM2Q0YzYiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiYXV0aF90aW1lIjoxNjQyMTY2MTE1LCJpc3MiOiJodHRwczpcL1wvY29nbml0by1pZHAuYXAtc291dGgtMS5hbWF6b25hd3MuY29tXC9hcC1zb3V0aC0xX0k1NHB3OWYxMCIsImV4cCI6MTY0MjE2OTcxNSwiaWF0IjoxNjQyMTY2MTE1LCJqdGkiOiIyNDNhZWFhZC0yMGQxLTQ0YzctODcxNy0yZjg3NDQ5NjBjYTkiLCJjbGllbnRfaWQiOiI3Ym91YzBmb3FxcTlucTcwZWxodTUwbGhiNiIsInVzZXJuYW1lIjoic3VzaGFudHRlc3QyOSJ9.H_35IwWBP3UGNAPFbbBzcxbSBgSeNpL3BIZ3wZwNlswE7AQyINbIdwv9sTWBKTyi-gPcuStitMUZlQLSj7qc2jJ6Y9pLBI3L0ExshiOiobKpu42jFa5DWL5W7f24ATwr-ZmtuGOoNZWveOZZCLyE95ZoSgTot9APAHBJGWHqVBLHlGids-m3_VeDekOCDk3OpTvY4uk2jCtcrjHFGTmwRBk7sIau3t0Y5xxQVi8GHV-gNsbeGbzk9C-gaRjmGKtOcMLRt_fgfUj4jja8ZFU557OTJ4bsSakDI9vbKR3H09_FjugSzRd3IDAGrVKQDCQ6p69xqYlFG1FgFtqxu0ZMgQ'

Update Asset

If you want to change any details of the current asset, you can do it by executing the update API call:

curl --location --request POST 'https://hlapi.getthespiderman.com/hl/updateAsset' \
--header 'Authorization: eyJraWQiOiIzRVhMd1NPU1B0SnVyN3VqWGdQQXdlVzhQSmE4NXNCOGR3N3N6c01hWlpnPSIsImFsZyI6IlJTMjU2In0.eyJvcmlnaW5fanRpIjoiYjUzNmZiMzctMGRkYi00MTYyLTkyMGQtYjdlZmE1ZWQyYjRmIiwic3ViIjoiNmVkYmM5NDEtZDVlMC00NTQ3LTkzYzQtY2I1NGM4Njk2OWExIiwiZXZlbnRfaWQiOiI3MWJjYjZmYi0zNjdiLTRiOGMtYWQxMC1lODI1Mjc3ZDJkNGYiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiYXV0aF90aW1lIjoxNjQyMTY5ODU0LCJpc3MiOiJodHRwczpcL1wvY29nbml0by1pZHAuYXAtc291dGgtMS5hbWF6b25hd3MuY29tXC9hcC1zb3V0aC0xX0k1NHB3OWYxMCIsImV4cCI6MTY0MjE3MzQ1NCwiaWF0IjoxNjQyMTY5ODU0LCJqdGkiOiJmZWRmZGQwOC1kMTA3LTQxZTAtYWY1NS01ZDY0MzFlMmJkNWMiLCJjbGllbnRfaWQiOiI3Ym91YzBmb3FxcTlucTcwZWxodTUwbGhiNiIsInVzZXJuYW1lIjoic3VzaGFudHRlc3QyOSJ9.egszHeYmw-8fmbaBsHoQzuDRQcKP3lzayw59DZXC3EsN5RWdeUYmk4iRFzGETLgJeos1keh-mx60xeM4TP3NZqyIYO0yZbgT7mlXNDDSUaFcMhfErwOJRzeZl5NwhcKc6k520QjPFvW8ThCsezciS8XHOypCtmNVDUNyOPZ6h9-ASWElbOQ_7Y7gexm3tPde-9kt7rJS302wE_3wUcm3XF3n7QQisY4M0x0UNJLgmJIHuSXrE1WU4A0YP1XR05ZoM1QB4NN3zdj5s1wYe6_d3pLtl9DhP4k4CJmbzotO_ODPen8LjRMxyHVxXhB0-Y9xfPabK7xn-s_yL_Xc-IrSjA' \
--header 'Content-Type: application/json' \
--data-raw '{
    "org" : "Org1MSP",
    "userId" : "tom6",
    "data" : {
        "ID" : "assetss32900",
        "color" : "red",
        "filehash": "aaaaa",
        "size" : 10,
        "appraisedValue" :500,
        "owner" : "london"
    }
}'

Delete Asset

If you wish to delete an asset, please use the following API:

curl --location --request POST 'https://hlapi.getthespiderman.com/hl/deleteAsset' \
--header 'Authorization: eyJraWQiOiIzRVhMd1NPU1B0SnVyN3VqWGdQQXdlVzhQSmE4NXNCOGR3N3N6c01hWlpnPSIsImFsZyI6IlJTMjU2In0.eyJvcmlnaW5fanRpIjoiYjUzNmZiMzctMGRkYi00MTYyLTkyMGQtYjdlZmE1ZWQyYjRmIiwic3ViIjoiNmVkYmM5NDEtZDVlMC00NTQ3LTkzYzQtY2I1NGM4Njk2OWExIiwiZXZlbnRfaWQiOiI3MWJjYjZmYi0zNjdiLTRiOGMtYWQxMC1lODI1Mjc3ZDJkNGYiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiYXV0aF90aW1lIjoxNjQyMTY5ODU0LCJpc3MiOiJodHRwczpcL1wvY29nbml0by1pZHAuYXAtc291dGgtMS5hbWF6b25hd3MuY29tXC9hcC1zb3V0aC0xX0k1NHB3OWYxMCIsImV4cCI6MTY0MjE3MzQ1NCwiaWF0IjoxNjQyMTY5ODU0LCJqdGkiOiJmZWRmZGQwOC1kMTA3LTQxZTAtYWY1NS01ZDY0MzFlMmJkNWMiLCJjbGllbnRfaWQiOiI3Ym91YzBmb3FxcTlucTcwZWxodTUwbGhiNiIsInVzZXJuYW1lIjoic3VzaGFudHRlc3QyOSJ9.egszHeYmw-8fmbaBsHoQzuDRQcKP3lzayw59DZXC3EsN5RWdeUYmk4iRFzGETLgJeos1keh-mx60xeM4TP3NZqyIYO0yZbgT7mlXNDDSUaFcMhfErwOJRzeZl5NwhcKc6k520QjPFvW8ThCsezciS8XHOypCtmNVDUNyOPZ6h9-ASWElbOQ_7Y7gexm3tPde-9kt7rJS302wE_3wUcm3XF3n7QQisY4M0x0UNJLgmJIHuSXrE1WU4A0YP1XR05ZoM1QB4NN3zdj5s1wYe6_d3pLtl9DhP4k4CJmbzotO_ODPen8LjRMxyHVxXhB0-Y9xfPabK7xn-s_yL_Xc-IrSjA' \
--header 'Content-Type: application/json' \
--data-raw '{
    "org" : "Org1MSP",
    "userId" : "tom6",
    "data" : {
        "id" : "assetss32900"
    }
}'

Asset History

If the user needs to retrieve all the historical assets including the deleted ones, he/she can utilize this API:

curl --location --request GET 'https://hlapi.getthespiderman.com/hl/getAssetHistory?org=Org1MSP&userId=tom6&id=asset1' \
--header 'Authorization: eyJraWQiOiIzRVhMd1NPU1B0SnVyN3VqWGdQQXdlVzhQSmE4NXNCOGR3N3N6c01hWlpnPSIsImFsZyI6IlJTMjU2In0.eyJvcmlnaW5fanRpIjoiYjUzNmZiMzctMGRkYi00MTYyLTkyMGQtYjdlZmE1ZWQyYjRmIiwic3ViIjoiNmVkYmM5NDEtZDVlMC00NTQ3LTkzYzQtY2I1NGM4Njk2OWExIiwiZXZlbnRfaWQiOiI3MWJjYjZmYi0zNjdiLTRiOGMtYWQxMC1lODI1Mjc3ZDJkNGYiLCJ0b2tlbl91c2UiOiJhY2Nlc3MiLCJzY29wZSI6ImF3cy5jb2duaXRvLnNpZ25pbi51c2VyLmFkbWluIiwiYXV0aF90aW1lIjoxNjQyMTY5ODU0LCJpc3MiOiJodHRwczpcL1wvY29nbml0by1pZHAuYXAtc291dGgtMS5hbWF6b25hd3MuY29tXC9hcC1zb3V0aC0xX0k1NHB3OWYxMCIsImV4cCI6MTY0MjE3MzQ1NCwiaWF0IjoxNjQyMTY5ODU0LCJqdGkiOiJmZWRmZGQwOC1kMTA3LTQxZTAtYWY1NS01ZDY0MzFlMmJkNWMiLCJjbGllbnRfaWQiOiI3Ym91YzBmb3FxcTlucTcwZWxodTUwbGhiNiIsInVzZXJuYW1lIjoic3VzaGFudHRlc3QyOSJ9.egszHeYmw-8fmbaBsHoQzuDRQcKP3lzayw59DZXC3EsN5RWdeUYmk4iRFzGETLgJeos1keh-mx60xeM4TP3NZqyIYO0yZbgT7mlXNDDSUaFcMhfErwOJRzeZl5NwhcKc6k520QjPFvW8ThCsezciS8XHOypCtmNVDUNyOPZ6h9-ASWElbOQ_7Y7gexm3tPde-9kt7rJS302wE_3wUcm3XF3n7QQisY4M0x0UNJLgmJIHuSXrE1WU4A0YP1XR05ZoM1QB4NN3zdj5s1wYe6_d3pLtl9DhP4k4CJmbzotO_ODPen8LjRMxyHVxXhB0-Y9xfPabK7xn-s_yL_Xc-IrSjA'
 
Share this