GetMessages
Usage
Import the Any declaration to interact with the GetMessages function to retrieve the messages of your choice.
Then call the GetMessages function. Notice this function can be called without providing any parameters. It will returns by default the 20 lastest messages posted on the network.
Parameters
Parameter | Description |
---|---|
pagination - optional number | Number of messages per page. |
page - optional number | The page index to show. |
addresses - optional string[] | Array of addresses referenced in attribute sender of messages. |
channels - optional string[] | Array of channels. |
chains - optional Chain[] | Array of chains. Note with this params the call to the API can take a certain time. |
refs - optional string[] | Arrays of refs listed in messages. |
tags - optional string[] | Array of tags. This params is dedicated to Post Message. |
contentTypes - optional string[] | Array of content types to find. This params is dedicated for Post Message. |
contentKeys - optional string[] | Array of content keys. This params is dedicated for Aggregate Message. |
hashes - optional string[] | List of Hashes to resolve. |
messageType - optional MessageType | The type of message you are waiting for: post, aggregate, forget, store, program. |
StartDate - optional Date | Use the time attribute to filter messages. Only message wicht passed this date will be retrieved. |
EndDate - optional Date | Use the time attribute to filter messages. Only message wicht anterior to this date will be retrieved. |
APIServer - optional string | The APIServer to use to resolve the request. The default one is: https://api2.aleph.im |
Result
GetMessages will returns a Promise response with this content:
You have 2 choices to get along with fetched data:
A. Keep default
By default, the GetMessages method will return a response like this:
This will allow you to get with auto-completion generic information about the messages like the sender, date, chain, ... that does not depend on its type (Post, Store, Aggregate, ...).
B. Use Typeguards
This is the safest way to handle messages retrieved by GetMessage or GetMessages. You can find more informaton about them on their dedicated page.
Last updated