Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/syucream/hastodon
mastodon client module for Haskell
https://github.com/syucream/hastodon
haskell mastodon
Last synced: 23 days ago
JSON representation
mastodon client module for Haskell
- Host: GitHub
- URL: https://github.com/syucream/hastodon
- Owner: syucream
- License: mit
- Created: 2017-04-19T15:32:21.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-10T13:38:51.000Z (almost 2 years ago)
- Last Synced: 2024-05-23T03:04:25.119Z (6 months ago)
- Topics: haskell, mastodon
- Language: Haskell
- Homepage:
- Size: 57.6 KB
- Stars: 31
- Watchers: 6
- Forks: 9
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Hastodon
[![Build Status](https://travis-ci.org/syucream/hastodon.svg?branch=master)](https://travis-ci.org/syucream/hastodon)
[![Hackage-Deps](https://img.shields.io/hackage-deps/v/Hastodon.svg)](http://packdeps.haskellers.com/feed?needle=Hastodon)mastodon client module for Haskell
## Quickstart
If you don't have client id and client secret, call postApps at first. (Alternatively, look in the web client, under the development section of your mastodon profile settings)
```haskell
import Web.Hastodon
appRes <- postApps "mastodon.social" "HastodonClientApp"
case appRes of
Right app -> do
let clientId = oauthClientClientId app
let clientSecret = oauthClientClientSecret app
```Fill client id, client secret, the email address used to sign up for the instance and password, then call functions.
```haskell
import Web.Hastodonmain :: IO ()
main = do
let clientId = "???"
let clientSecret = "???"
let email = "???"
let password = "???"
maybeClient <- mkHastodonClient clientId clientSecret email password "mastodon.social"
case maybeClient of
Just client -> do
timeline <- getAccountById client 93150
print timeline
result <- postStatus client "test toot from hastodon!"
print result
Nothing -> do
putStrLn "Failed to log in. Be careful regarding the spelling of your email and password."
```### Streaming
Streaming requires a little more ceremony, as well as familiarity with the [`Conduit`](https://hackage.haskell.org/package/conduit-1.3.0.2) library.```haskell
{-# LANGUAGE OverloadedStrings #-}
import Web.Hastodon
import Conduit
import qualified Data.ByteString.Char8 as BSmain :: IO ()
main = do
let inst = "mastodon.social"
let token = "???" -- from /settings/applications
let client = HastodonClient instance token -- or use mkHastodonClient as above
runConduitRes $ streamUser client .| mapC showSR .| stdoutC
where showSR (SNotification n) = "got notification: " `BS.append` (sb n) `BS.append` "\n"
showSR (SUpdate s) = "got status: " `BS.append` (sb s) `BS.append` "\n"
showSR (SDelete i) = "got delete: " `BS.append` (BS.pack i) `BS.append` "\n"
showSR Thump = "got thump\n"
sb v = BS.pack $ show v
```## Status of implementations
### Mastodon APIs
- [x] GET /api/v1/accounts/:id
- [x] GET /api/v1/accounts/verify_credentials
- [ ] PATCH /api/v1/accounts/update_credentials
- [x] GET /api/v1/accounts/:id/followers
- [x] GET /api/v1/accounts/:id/following
- [x] GET /api/v1/accounts/:id/statuses
- [x] POST /api/v1/accounts/:id/follow
- [x] POST /api/v1/accounts/:id/unfollow
- [x] POST /api/v1/accounts/:id/block
- [x] POST /api/v1/accounts/:id/unblock
- [x] POST /api/v1/accounts/:id/mute
- [x] POST /api/v1/accounts/:id/unmute
- [x] GET /api/v1/accounts/relationships
- [x] GET /api/v1/accounts/search
- [x] POST /api/v1/apps
- [x] GET /api/v1/blocks
- [x] GET /api/v1/favourites
- [x] GET /api/v1/follow_requests
- [x] POST /api/v1/follow_requests/:id/authorize
- [x] POST /api/v1/follow_requests/:id/reject
- [ ] POST /api/v1/follows
- [x] GET /api/v1/instance
- [x] POST /api/v1/media
- [x] GET /api/v1/mutes
- [x] GET /api/v1/notifications
- [x] GET /api/v1/notifications/:id
- [x] POST /api/v1/notifications/clear
- [x] GET /api/v1/reports
- [ ] POST /api/v1/reports
- [x] GET /api/v1/search
- [x] GET /api/v1/statuses/:id
- [x] GET /api/v1/statuses/:id/context
- [x] GET /api/v1/statuses/:id/card
- [x] GET /api/v1/statuses/:id/reblogged_by
- [x] GET /api/v1/statuses/:id/favourited_by
- [x] POST /api/v1/statuses
- [ ] DELETE /api/v1/statuses/:id
- [x] POST /api/v1/statuses/:id/reblog
- [x] POST /api/v1/statuses/:id/unreblog
- [x] POST /api/v1/statuses/:id/favourite
- [x] POST /api/v1/statuses/:id/unfavourite
- [x] GET /api/v1/timelines/home
- [x] GET /api/v1/timelines/public
- [x] GET /api/v1/timelines/tag/:hashtag### Streaming
- [x] GET /api/v1/streaming/user
- [x] GET /api/v1/streaming/public
- [x] GET /api/v1/streaming/public/local
- [x] GET /api/v1/streaming/hashtag
- [x] GET /api/v1/streaming/list### Auth
- [x] the interface of POST /oauth/token
## License
MIT
## Author
Ryo Okubo
### Contributors
* [KirinDave](https://github.com/KirinDave)
* [as-capabl](https://github.com/as-capabl)
* [william42](https://github.com/william42)
* [swizzard](https://github.com/swizzard)