api: Clean up the README.md somewhat.

This commit is contained in:
Tim Abbott 2016-12-13 22:15:22 -08:00
parent 9a6e0cf940
commit 0010b519fd

View file

@ -3,9 +3,10 @@
The [Zulip API](https://zulip.com/api) Python bindings require the The [Zulip API](https://zulip.com/api) Python bindings require the
following Python libraries: following Python libraries:
* simplejson
* requests (version >= 0.12.1) * requests (version >= 0.12.1)
* simplejson
* six
* typing (version >= 3.5.2.2)
#### Installing #### Installing
@ -36,22 +37,23 @@ file is as follows:
If omitted, these settings have the following defaults: If omitted, these settings have the following defaults:
site=https://api.zulip.com
insecure=false insecure=false
cert_bundle=<the default CA bundle trusted by Python> cert_bundle=<the default CA bundle trusted by Python>
Alternatively, you may explicitly use "--user" and "--api-key" in our Alternatively, you may explicitly use "--user", "--api-key", and
examples, which is especially useful if you are running several bots `--site` in our examples, which is especially useful when testing. If
which share a home directory. you are running several bots which share a home directory, we
recommend using `--config` to specify the path to the `zuliprc` file
for a specific bot.
The command line equivalents for other configuration options are: The command line equivalents for other configuration options are:
--site=<your Zulip server's URI>
--insecure --insecure
--cert-bundle=<file> --cert-bundle=<file>
You can obtain your Zulip API key, create bots, and manage bots all You can obtain your Zulip API key, create bots, and manage bots all
from your Zulip [settings page](https://zulip.com/#settings). from your Zulip settings page; with current Zulip there's also a
button to download a `zuliprc` file for your account/server pair.
A typical simple bot sending API messages will look as follows: A typical simple bot sending API messages will look as follows:
@ -71,6 +73,9 @@ When you want to send a message:
} }
zulip_client.send_message(message) zulip_client.send_message(message)
If you are parsing arguments, you may find it useful to use Zulip's
option group; see any of our API examples for details on how to do this.
Additional examples: Additional examples:
client.send_message({'type': 'stream', 'content': 'Zulip rules!', client.send_message({'type': 'stream', 'content': 'Zulip rules!',
@ -83,7 +88,14 @@ keys: msg, result. For successful calls, result will be "success" and
msg will be the empty string. On error, result will be "error" and msg will be the empty string. On error, result will be "error" and
msg will describe what went wrong. msg will describe what went wrong.
#### Examples
The API bindings package comes with several nice example scripts that
show how to use the APIs; they are installed as part of the API
bindings bundle.
#### Logging #### Logging
The Zulip API comes with a ZulipStream class which can be used with the The Zulip API comes with a ZulipStream class which can be used with the
logging module: logging module:
@ -112,6 +124,7 @@ Alternatively, if you don't want to use your ~/.zuliprc file:
zulip-send --user shakespeare-bot@example.com \ zulip-send --user shakespeare-bot@example.com \
--api-key a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 \ --api-key a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 \
--site https://zulip.example.com \
hamlet@example.com cordelia@example.com -m \ hamlet@example.com cordelia@example.com -m \
"Conscience doth make cowards of us all." "Conscience doth make cowards of us all."