See root documentation of API Reference.
import requests
import os
import json
base_url = "https://memory.backbench.io/"
user = os.environ['benchName'].split(":")
data = {
"cmd": "",
"auth": {
"userId": user[0],
"benchId":user[1],
"accessKey": os.environ['ACCESS_KEY']
},
"args": {}
}
def get(key):
temp = data
temp["cmd"] = "bb:mem:get"
temp["args"] = {"key": key}
res = requests.post(base_url, json=temp)
temp = res.json()
if "errorMessage" in temp:
return None
return temp['reply']
def set(key, value):
temp = data
temp["cmd"] = "bb:mem:set"
temp["args"] = {"key": key, "value": value}
res = requests.post(base_url, json=temp)
return True
def delete(key):
temp = data
temp["cmd"] = "bb:mem:del"
temp["args"] = {"key": key}
res = requests.post(base_url, json=temp)
return True
def log(msg):
temp = data
temp["cmd"] = "bb:log"
temp["args"] = {"message": msg}
res = requests.post(base_url, json=temp)
return True