2013-04-09 22:20:46 +02:00
[
{
2014-01-03 18:33:24 +01:00
"method" : "POST" ,
2014-01-03 18:37:37 +01:00
"endpoint" : "messages" ,
2013-08-08 17:45:25 +02:00
"example_response" : "{'msg': '', 'result': 'success', 'id': 12345678}" ,
2013-04-09 22:20:46 +02:00
"returns" : [
[
2013-08-08 17:45:25 +02:00
"id" ,
"The ID of the newly created message."
2013-04-09 22:20:46 +02:00
]
2013-06-19 23:51:07 +02:00
] ,
2013-08-08 17:45:25 +02:00
"call" : "Send a message" ,
2013-04-09 22:20:46 +02:00
"arguments" : [
[
2013-08-08 17:45:25 +02:00
"type" ,
"One of {private, stream}"
] ,
[
"content" ,
"The content of the message. Maximum message size of 10000 bytes."
2013-06-19 23:51:07 +02:00
] ,
2013-04-09 22:20:46 +02:00
[
2013-08-08 17:45:25 +02:00
"to" ,
"In the case of a stream message, a string identifying the stream. In the case of a private message, a JSON-encoded list containing the usernames of the recipients."
] ,
[
"subject" ,
2013-08-29 20:48:58 +02:00
"The topic for the message (Only required if type is \u201cstream\u201d). Maximum length of 60 characters."
2013-04-09 22:20:46 +02:00
]
2013-06-19 23:51:07 +02:00
] ,
2013-04-09 22:20:46 +02:00
"example_request" : {
2013-08-08 17:45:25 +02:00
"python" : "<div class=\"codehilite\"><pre>\n<span class=\"n\">client</span><span class=\"o\">.</span><span class=\"n\">send_message</span><span class=\"p\">({</span>\n <span class=\"s\">\"type\"</span><span class=\"p\">:</span> <span class=\"s\">\"private\"</span><span class=\"p\">,</span>\n <span class=\"s\">\"to\"</span><span class=\"p\">:</span> <span class=\"s\">\"wdaher@example.com\"</span><span class=\"p\">,</span>\n <span class=\"s\">\"content\"</span><span class=\"p\">:</span> <span class=\"s\">\"I come not, friends, to steal away your hearts.\"</span>\n<span class=\"p\">}</span>)\n<span class=\"n\">client</span><span class=\"o\">.</span><span class=\"n\">send_message</span><span class=\"p\">(</span><span class=\"n\"><span class=\"p\">{</span>\n <span class=\"s\">\"type\"</span><span class=\"p\">:</span> <span class=\"s\">\"stream\"</span><span class=\"p\">,</span>\n <span class=\"s\">\"to\"</span><span class=\"p\">:</span> <span class=\"s\">\"Denmark\"</span><span class=\"p\">,</span>\n <span class=\"s\">\"subject\"</span><span class=\"p\">:</span> <span class=\"s\">\"Castle\"</span><span class=\"p\">,</span>\n <span class=\"s\">\"content\"</span><span class=\"p\">:</span> <span class=\"s\">\"Something is rotten in the state of Denmark.\"</span>\n<span class=\"p\">}</span></span><span class=\"p\">)</span>\n</pre></div>\n" ,
2017-01-29 03:38:43 +01:00
"curl" : "<h5>Stream message</h5>\n<div class=\"codehilite\"><pre>curl https://zulip.example.com/api/v1/messages <span class=\"se\">\\</span>\n -u BOT_EMAIL_ADDRESS:BOT_API_KEY <span class=\"se\">\\</span>\n -d <span class=\"s2\">\"type=stream\"</span> <span class=\"se\">\\</span>\n -d <span class=\"s2\">\"to=Denmark\"</span> <span class=\"se\">\\</span>\n -d <span class=\"s2\">\"subject=Castle\"</span> <span class=\"se\">\\</span>\n -d <span class=\"s2\">\"content=Something is rotten in the state of Denmark.\"</span>\n</pre></div>\n<h5>Private message</h5>\n<div class=\"codehilite\"><pre>curl https://zulip.example.com/api/v1/messages <span class=\"se\">\\</span>\n -u BOT_EMAIL_ADDRESS:BOT_API_KEY <span class=\"se\">\\</span>\n -d <span class=\"s2\">\"type=private\"</span> <span class=\"se\">\\</span>\n -d <span class=\"s2\">\"to=othello@example.com\"</span> <span class=\"se\">\\</span>\n -d <span class=\"s2\">\"content=I come not, friends, to steal away your hearts.\"</span>\n</pre></div>"
2013-04-09 22:20:46 +02:00
}
2013-06-19 23:51:07 +02:00
} ,
2013-04-09 22:20:46 +02:00
{
2014-01-03 18:33:24 +01:00
"method" : "POST" ,
2014-01-03 18:37:37 +01:00
"endpoint" : "register" ,
2013-08-08 17:45:25 +02:00
"example_response" : "{'msg': '', 'last_event_id': -1, 'result': 'success', 'queue_id': '1375801870:2942'}" ,
2013-04-09 22:20:46 +02:00
"returns" : [
[
2013-08-08 17:45:25 +02:00
"queue_id" ,
"The ID of the queue that has been allocated for your client"
] ,
[
"last_event_id" ,
"The initial value of the `last_event_id` value for to pass to `GET /api/v1/events`."
2013-04-09 22:20:46 +02:00
]
2013-06-19 23:51:07 +02:00
] ,
2013-08-08 17:45:25 +02:00
"call" : "Register a queue to receive new messages" ,
2013-04-09 22:20:46 +02:00
"arguments" : [
[
2013-08-08 17:45:25 +02:00
"event_types" ,
2013-12-11 22:30:11 +01:00
"(optional) A JSON-encoded array indicating which types of events you're interested in. Values that you might find useful include: <ul><li><strong>message</strong> (messages),</li> <li><strong>subscriptions</strong> (changes in your subscriptions),</li> <li><strong>realm_user</strong> (changes in the list of users in your realm), and</li> <li><strong>pointer</strong> (changes in your pointer).</li></ul>\n If you do not specify this argument, you will receive all events, and have to filter out the events not relevant to your client in your client code. For most applications, one is only interested in messages, so one specifies: <strong>event_types=[\"message\"]</strong>"
2013-06-19 23:51:07 +02:00
] ,
2013-04-09 22:20:46 +02:00
[
2013-08-08 17:45:25 +02:00
"apply_markdown" ,
"(optional) set to \u201ctrue\u201d if you would like the content to be rendered in HTML format (by default, the API returns the raw text that the user entered)"
]
] ,
"example_request" : {
2013-08-10 02:42:20 +02:00
"python" : "<div class=\"codehilite\"><pre><span class=\"n\">client</span><span class=\"o\">.</span><span class=\"n\">register<span class=\"p\">()</span>\n</span></pre></div>" ,
2017-01-29 03:38:43 +01:00
"curl" : "<div class=\"codehilite\"><pre>curl https://zulip.example.com/api/v1/register <span class=\"se\">\\</span>\n -u othello-bot@example.com:a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 <span class=\"se\">\\</span>\n -d <span class=\"s2\">'event_types=[\"message\"]'</span>\n</pre></div>"
2013-08-08 17:45:25 +02:00
}
} ,
{
2014-01-03 18:33:24 +01:00
"method" : "GET" ,
2014-01-03 18:37:37 +01:00
"endpoint" : "events" ,
2013-08-08 17:45:25 +02:00
"example_response" :
" { ' r e s u l t ' : ' s u c c e s s ' ,
' m s g ' : ' ' ,
' e v e n t s ' : [
{ ' t y p e ' : ' m e s s a g e ' ,
' i d ' : 0 ,
' m e s s a g e ' : {
' c o n t e n t _ t y p e ' : ' t e x t / x - m a r k d o w n ' ,
' a v a t a r _ u r l ' : ' h t t p s : //url/for/othello-bots/avatar',
' t i m e s t a m p ' : 1375978403 ,
' d i s p l a y _ r e c i p i e n t ' : ' D e n m a r k ' ,
' s e n d e r _ i d ' : 13215 ,
' s e n d e r _ f u l l _ n a m e ' : ' O t h e l l o B o t ' ,
' s e n d e r _ e m a i l ' : ' o t h e l l o - b o t @ e x a m p l e . c o m ' ,
' s e n d e r _ s h o r t _ n a m e ' : ' o t h e l l o - b o t ' ,
2017-03-14 23:31:05 +01:00
' s e n d e r _ r e a l m _ s t r ' : ' e x a m p l e ' ,
2013-08-08 17:45:25 +02:00
' c o n t e n t ' : ' S o m e t h i n g i s r o t t e n i n t h e s t a t e o f D e n m a r k . ' ,
' g r a v a t a r _ h a s h ' : ' 17 d 93357 c c a 1e793739836 e c b c 7 a 9 b f 7 ' ,
' r e c i p i e n t _ i d ' : 12314 ,
' c l i e n t ' : ' w e b s i t e ' ,
' s u b j e c t _ l i n k s ' : [ ] ,
' s u b j e c t ' : ' C a s t l e ' ,
' t y p e ' : ' s t r e a m ' ,
' i d ' : 12345678 ,
}
} ,
{ ' t y p e ' : ' m e s s a g e ' ,
' i d ' : 1 ,
' m e s s a g e ' : {
' c o n t e n t _ t y p e ' : ' t e x t / x - m a r k d o w n ' ,
' a v a t a r _ u r l ' : ' h t t p s : //url/for/othello-bots/avatar',
' t i m e s t a m p ' : 1375978404 ,
' d i s p l a y _ r e c i p i e n t ' : [ { ' f u l l _ n a m e ' : ' H a m l e t o f D e n m a r k ' ,
' e m a i l ' : ' h a m l e t @ e x a m p l e . c o m ' ,
' s h o r t _ n a m e ' : ' h a m l e t ' ,
' i d ' : 31572 } ] ,
' s e n d e r _ i d ' : 13215 ,
' s e n d e r _ f u l l _ n a m e ' : ' O t h e l l o B o t ' ,
' s e n d e r _ e m a i l ' : ' o t h e l l o - b o t @ e x a m p l e . c o m ' ,
' s e n d e r _ s h o r t _ n a m e ' : ' o t h e l l o - b o t ' ,
2017-03-14 23:31:05 +01:00
' s e n d e r _ r e a l m _ s t r ' : ' e x a m p l e ' ,
2013-08-08 17:45:25 +02:00
' c o n t e n t ' : ' I c o m e n o t , f r i e n d s , t o s t e a l a w a y y o u r h e a r t s . ' ,
' g r a v a t a r _ h a s h ' : ' 17 d 93357 c c a 1e793739836 e c b c 7 a 9 b f 7 ' ,
' r e c i p i e n t _ i d ' : 18391 ,
' c l i e n t ' : ' w e b s i t e ' ,
' s u b j e c t _ l i n k s ' : [ ] ,
' s u b j e c t ' : ' ' ,
' t y p e ' : ' p r i v a t e ' ,
' i d ' : 12345679 ,
}
}
]
} " ,
"returns" : [
[
"events" ,
2013-12-11 23:44:55 +01:00
"an array (possibly zero-length if dont_block is set) of events with IDs newer than `last_event_id`. Event IDs are guaranted to be increasing, but they are not guaranteed to be consecutive."
2013-08-08 17:45:25 +02:00
]
] ,
"call" : "Get new events from an events queue" ,
"arguments" : [
[
"queue_id" ,
2013-12-11 22:29:07 +01:00
"The ID of a queue that you registered via <code>POST /api/v1/register</code>"
2013-06-19 23:51:07 +02:00
] ,
2013-04-09 22:20:46 +02:00
[
2013-08-08 17:45:25 +02:00
"last_event_id" ,
"The highest event ID in this queue that you've received and wish to acknowledge. See the code for <tt>call_on_each_event</tt> in the <tt>zulip</tt> Python module for an example implementation of correctly processing each event exactly once."
2013-06-19 23:51:07 +02:00
] ,
2013-04-09 22:20:46 +02:00
[
2013-08-08 17:45:25 +02:00
"dont_block" ,
"(optional) set to \u201ctrue\u201d if the client is requesting a nonblocking reply. If not specified, the request will block until either a new event is available or a few minutes have passed, in which case the server will send the client a heartbeat event."
2013-04-09 22:20:46 +02:00
]
2013-06-19 23:51:07 +02:00
] ,
2013-04-09 22:20:46 +02:00
"example_request" : {
2013-08-08 17:45:25 +02:00
"python" : "<div class=\"codehilite\"><pre><span class=\"n\">client</span><span class=\"o\">.</span><span class=\"n\">get_events<span class=\"p\">()</span>\n</span></pre></div> or if you want the event queues managed for you, <div class=\"codehilite\"><pre><span class=\"n\">client</span><span class=\"o\">.</span><span class=\"n\">call_on_each_event<span class=\"p\">()</span>\n</span></pre></div>" ,
2017-01-29 03:38:43 +01:00
"curl" : "<div class=\"codehilite\"><pre>curl -G https://zulip.example.com/api/v1/events <span class=\"se\">\\</span>\n -u othello-bot@example.com:a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 <span class=\"se\">\\</span>\n -d <span class=\"s2\">\"queue_id=1375801870:2942\"</span> <span class=\"se\">\\</span>\n -d <span class=\"s2\">\"last_event_id=-1\"</span>\n</pre></div>"
2013-04-09 22:20:46 +02:00
}
}
2013-07-23 22:15:12 +02:00
]