Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/julienxx/clj-slack
Use Slack REST API from Clojure
https://github.com/julienxx/clj-slack
client-lib clj clojure slack slackapi
Last synced: 6 days ago
JSON representation
Use Slack REST API from Clojure
- Host: GitHub
- URL: https://github.com/julienxx/clj-slack
- Owner: julienXX
- License: epl-1.0
- Created: 2014-03-10T16:50:53.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-02-16T14:08:15.000Z (9 months ago)
- Last Synced: 2024-05-08T22:54:48.164Z (6 months ago)
- Topics: client-lib, clj, clojure, slack, slackapi
- Language: Clojure
- Homepage:
- Size: 229 KB
- Stars: 131
- Watchers: 10
- Forks: 36
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# clj-slack
clj-slack is a Clojure library to talk to the [Slack](http://slack.com) REST API. It supports almost the entire Slack API.
![Build Status](https://travis-ci.org/julienXX/clj-slack.svg?branch=master)
## Documentation
Slack API methods are described [here](https://api.slack.com/methods).
clj-slack documentation is available [here](https://cljdoc.org/d/org.julienxx/clj-slack/0.8.3/doc/readme).
## Usage
This is on [Clojars](https://clojars.org/org.julienxx/clj-slack) of course. Just add ```[org.julienxx/clj-slack "0.8.3"]``` to your ```:dependencies``` in your project.clj file.
Get your access token by creating a new app or [here](https://api.slack.com/custom-integrations/legacy-tokens). If you create a new Slack app, **don't forget to add the relevant scopes to your app**.
Your need to create a connection map like ```{:api-url "https://slack.com/api" :token "YOUR TOKEN"}``` and pass it as the first argument of every functions in clj-slack. Of course you can change api-url for debugging or testing purposes.
You can pass [clj-http](https://github.com/dakrone/clj-http) options in the connection map if needed.
clj-slack will throw an Exception if the connection map you're trying to use is not valid.
Example:
```clojure
(require 'clj-slack.users)
(def connection {:api-url "https://slack.com/api" :token "YOUR TOKEN"})
(clj-slack.users/list connection)
```You can use optional params described in [Slack API](https://api.slack.com/methods) by passing them through a map.
```clojure
(require 'clj-slack.stars)
(def connection {:api-url "https://slack.com/api" :token "YOUR TOKEN"})
(clj-slack.stars/list connection {:count "2" :page "3"})
```Uploading a file:
```clojure
(require 'clj-slack.files)
(def connection {:api-url "https://slack.com/api" :token "YOUR TOKEN"})
(clj-slack.files/upload connection (clojure.java.io/input-stream "/path/to/file/file.ext") {:channels "CHANNEL_ID", :title "This is a file.})
```## Testing
In order to run the tests, you have to set 3 environment variables:
- `TOKEN` a legacy Slack token
- `CLIENT_ID` a OAuth client id
- `CLIENT_SECRET` a OAuth client secret
then run `lein test`.## License
Copyright (C) 2014-2023 Julien Blanchard
Distributed under the Eclipse Public License, the same as Clojure.