Management
reviewed: 29 March 2024
Nota bene
All requests should be sent via POST
method to https://pheix.org/api
endpoint.
Store data
Request
{
"credentials": {
"token": "0x95c27722267bc8f668a84688374dc8feb53af09e564b43598df3390881c89f3d"
},
"method": "GET",
"route": "/api/ethelia/event/store",
"payload": {
"code": "20240329",
"topic": "sample-data",
"payload": {
"value": 15,
"title": "Sample data title"
}
}
}
Arguments:
token
— current access token;method
— API transport method/direction, onlyGET
value is supported;route
— API data storing route:/api/ethelia/event/store
;payload
— lightweight data structure, free to use any key-value pairs here.
Response
TOKEN="0x95c27722267bc8f668a84688374dc8feb53af09e564b43598df3390881c89f3d" && \
VALUE=`date +%s` && \
curl -X POST https://pheix.org/api \
-H 'Content-Type: application/json' \
-d '{"credentials":{"token":"'$TOKEN'"},"method":"GET","route":"/api/ethelia/event/store","payload":{"code":"20240329","topic":"sample-data","payload":{"value":'$VALUE',"title":"Sample data title"}}}'
{
"content": {
"chainid": 62,
"event": "sample-data",
"notification": false,
"result": "success"
},
"msg": "/api/ethelia/event/store fetch is successful",
"render": "0.403889579",
"status": 1
}
Important
Record identifier in database on blockchain is shown as content.chainid
value.
Search data
Request
{
"credentials": {
"token": "0x95c27722267bc8f668a84688374dc8feb53af09e564b43598df3390881c89f3d"
},
"method": "GET",
"route": "/api/ethelia/event/search",
"payload": {
"search": {
"target": "1",
"value": "*"
}
}
}
token
— current access token;method
— API transport method/direction, onlyGET
value is supported;route
— API data search route:/api/ethelia/event/search
;payload.search.target
— search target specifier:1
— search bypayload.code
;2
— search bypayload.topic
.
payload.search.value
— search key phrase, meta character*
might be used to search for any value.
Response
TOKEN="0x95c27722267bc8f668a84688374dc8feb53af09e564b43598df3390881c89f3d" && \
SEARCHTARGET="1" && \
SEARCHKEYPHRASE="20240329" && \
curl -X POST https://pheix.org/api \
-H 'Content-Type: application/json' \
-d '{"credentials":{"token":"'$TOKEN'"},"method":"GET","route":"/api/ethelia/event/search","payload":{"search":{"target":"'$SEARCHTARGET'","value":"'$SEARCHKEYPHRASE'"}}}'
{
"content": {
"component_render": "0.347872805",
"tparams": {
"events": [
[
"0xe1b4cb4187233b153c559e86ea9661ce7af11a9a",
"20240329",
"Fri, 29 Mar 2024 06:36:06 GMT",
"eyJ2YWx1ZSI6MTcxMTY5NDE2NiwidGl0bGUiOiJTYW1wbGUgZGF0YSB0aXRsZSJ9",
"sample-data"
]
]
}
},
"msg": "/api/ethelia/event/search fetch is successful",
"render": "0.348812532",
"status": 1
}
Explanation of content.tparams.events
values:
Lightweight data (events), found by the search request, is available as array at content.tparams.events
. Each element is represented by array as well:
- Element at
0
— sender address on Ethereum; - Element at
1
— event code; - Element at
2
— event creation date; - Element at
3
— event payload in base64; - Element at
4
— event topic.
Event payload element at index 3
could be decoded in command line:
PAYLOAD="eyJ2YWx1ZSI6MTcxMTY5NDE2NiwidGl0bGUiOiJTYW1wbGUgZGF0YSB0aXRsZSJ9" && \
echo $PAYLOAD | base64 --decode | jq .
{
"value": 1711694166,
"title": "Sample data title"
}