From 4d547a28d4a18eec73be326bb7d0273826651a08 Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Mon, 22 May 2023 14:29:16 +0000 Subject: [PATCH] GITBOOK-215: Adding runkit examples to provider page --- developers/apis/provider.md | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/developers/apis/provider.md b/developers/apis/provider.md index 3c10391c..f4cb6c7a 100644 --- a/developers/apis/provider.md +++ b/developers/apis/provider.md @@ -1,4 +1,4 @@ -# Provider REST API +# Provider [https://v4.provider.oceanprotocol.com](https://v4.provider.oceanprotocol.com) @@ -25,7 +25,7 @@ Returns: Json object containing the last-used nonce value. The nonce endpoint is Example: ``` -POST /api/services/nonce?userAddress=0x990922334 +GET /api/services/nonce?userAddress=0x990922334 ``` Response: @@ -36,6 +36,18 @@ Response: } ``` +#### Javascript Example + +```runkit nodeVersion="18.x.x" +const axios = require('axios') + +const response = await axios( `https://v4.provider.oceanprotocol.com/api/services/nonce?userAddress=0x0db823218e337a6817e6d7740eb17635deadafaf`) + +console.log(response.status) +console.log(response.data) + +``` + ### Encrypt endpoint #### GET /api/services/encrypt @@ -57,6 +69,21 @@ Response: b'0x04b2bfab1f4e...7ed0573' ``` +#### Javascript Example + +```runkit nodeVersion="18.x.x" +const fetch = require('cross-fetch') + +const data = "test" +const response = await fetch('https://v4.provider.oceanprotocol.com/api/services/encrypt?chainId=1', { + method: 'POST', + body: JSON.stringify(data), + headers: { 'Content-Type': 'application/octet-stream' } + }) +console.log(response) + +``` + ### Decrypt endpoint #### POST /api/services/decrypt