Create a post

Call the create_post() function to create a Post Message.

Returns

The post object that was just created.

Usage

def create_post(
    account,
    post_content,
    post_type,
    ref,
    address,
    channel,
    session,
    api_server,
    inline,
    storage_engine,
)

Required Arguments

account - Account

Address the Post should be associated with or the address that submitted the Post.

post_content - Any

The content to save to the item_content.content of the post message.

To take full advantage of the search abilities, make the post_content an object with a tags key. Tags are searchable, see list all posts.

post_type - string

A lowercase string of your choice for the item_content.type of the post message.

ex: "amend", "blog", "chat", "comment"

post_content has a limit size of just under 16Mb, the biggest document size on MongoDB.

To save a document above 16Mb, the content should be stored in a Store Item and then make a reference for the item in a Post.

[Next Release] Right now there is a limit of about 1Mb on the post_content.

Optional Arguments

  • 4. ref - Any Default: None A searchable reference string of your choice to save to the item_content.ref. Can be the reference to another post, an address, transaction hash, etc.

  • 5. address - string Default: None Address the Post should be associated with or the address that submitted the Post. To post on behalf of an address that is not the account signing see the aggregate section on security key

  • 6. channel - string Default: "TEST" Channel of the message. Ideally, an application would decide and use one channel.

  • 7. session Default: None

  • 8. api_server - string Default: "https://api2.aleph.im" Target API server

  • 9. inline - boolean Default: true Should the message be stored as a separate file or inserted inline?

    ℹī¸ Set it to false for data that could fall under GDPR.

  • 10. storage_engine - string Default: "storage" Storage engine to use. Possible values: "storage", "ipfs"

Example

>>> from aleph_client.synchronous import create_post

>>> create_post(
      account, 
      {'content': 'test'}, 
      post_type='testtype', 
      channel='MY_CHANNEL')

{'chain': 'NULS2',
 'channel': 'MY_CHANNEL',
 'sender': 'NULSd6HgaaV62iEcTZSWoaTrA3U7Jr7Vv1nXS',
 'type': 'POST',
 'time': 1573570575.281997,
 'item_content': '{
   "type":"testtype",
   "address":"NULSd6HgaaV62iEcTZSWoaTrA3U7Jr7Vv1nXS",
   "content":{"content":"test"},
   "time":1573570575.2818618}',
 'item_hash': '02afdbf33ff2c6ddb46349298a4598a8801cec61dbaa8f3a17ba9d1ad6dd8cb1',
 'signature': 'G7yJjMCPgvX04Dd9rsz0oEuuRFa4PfuKAMOPA3Oblf6vd5YA1x15jvWLL2WycnnzYLEl0usjTiVxBl530ZOmYgw='}

Last updated