Skip to content
This repository has been archived by the owner on Dec 26, 2022. It is now read-only.

Receive MAM Message

Yang Hau edited this page Jul 20, 2020 · 4 revisions

Receive Masked Authenticated Message

In this API, tangle-accelerator provides user ability to fetch all messages under a unique channel. This API will return the ID of next channel (chid1). Header of Content-Type with application/json is required.

POST /mam/recv

Request

Parameters

Name Type Required or Optional Description
chid string Required The channel ID the message exist in. It is an 81-trytes long string.
protocol string Required The protocol the current request used. Now we support only MAM_v1.

Sample Request

{
	"data_id": {
		"chid": "JVYTMGBIWU9NMUKUOVBAVBVW9QMSOOGUK9SB9OMILKMEVHWMPFALZBGPEBRAXESZZKEUGK9QEHAABTOIJ"
	},
	"protocol": "MAM_V1"
}

Response

Result

Name Type Description
payload array A array which is composed of several messages. Each element in this array is the message in the query Channel
chid1 string Channel ID of next Channel. It would be returned when the current fetched channel is full of Messages

Sample Response

Channel is still available
{
	"payload": ["This is message No1", "This is message No2"]
}
Run out channel capacity
{
	"payload": ["This is message No1", "This is message No2", "This is message No3"],
	"chid1": "THIS9IS9AN9ADDRESS9USED9BY9TAGNLEACCELERATOR9999999999999999999999999999999999999"
}

curl Example

$ curl http://node.deviceproof.org:5566/mam/recv \
    -X POST \
    -H 'Content-Type: application/json' \
    -d '{"data_id": {"chid": "JVYTMGBIWU9NMUKUOVBAVBVW9QMSOOGUK9SB9OMILKMEVHWMPFALZBGPEBRAXESZZKEUGK9QEHAABTOIJ"},"protocol": "MAM_V1"
}'

Errors

In the following conditions that a client who send a request will receive an HTTP error code 400 and JSON object in response body.

  • The absence of any required field
  • chid field is less than 81 trytes