twitter-conduit

Twitter API package with conduit interface and Streaming API support.

https://github.com/himura/twitter-conduit

LTS Haskell 22.40:0.6.1
Stackage Nightly 2023-12-26:0.6.1
Latest on Hackage:0.6.1

See all snapshots twitter-conduit appears in

BSD-3-Clause licensed by HATTORI Hiroki, Hideyuki Tanaka, Takahiro HIMURA
Maintained by Takahiro HIMURA
This version can be pinned in stack with:twitter-conduit-0.6.1@sha256:819d9ede6da5124a97900581706024149c70a87248f54b3ee6cc9a3b7aaaaa3e,3845

twitter-conduit: An Conduit based Twitter API library for Haskell

CI Hackage Hackage-Deps

About

This is an conduit based Twitter API library for Haskell, including Streaming API supports.

Documentation is available in hackage.

Quick Start

For a runnable example, see sample/simple.hs. You can find other various examples in sample directory.

Run Samples

Build

Building with Cabal

$ cabal v2-build all

Building with Stack

To build with Stack, you should create top-level stack.yaml file first. An example of stack.yaml is like below:

resolver: lts-18.12
packages:
- .
- sample
extra-deps:
- twitter-types-0.11.0
- twitter-types-lens-0.11.0

then, run stack.

$ stack build

Run

First, you must obtain consumer key and secret from Twitter Application Management page, and you have to set those values to environment variables as shown below:

$ export OAUTH_CONSUMER_KEY="YOUR APPLICATION CONSUMER KEY"
$ export OAUTH_CONSUMER_SECRET="YOUR APPLICATION CONSUMER SECRET"

Before you run examples, you must prepare OAuth access token and secret. You can obtain access token and secret by using either PIN or web callback.

If you would like to use the PIN method, you run simply as below, and follow instructions:

$ cabal run oauth_pin

On the other hand, If you would like to use the callback method, do as follows:

$ cabal run oauth_callback

and open http://localhost:3000/signIn in your browser.

In both cases, you can obtain OAUTH_ACCESS_TOKEN and OAUTH_ACCESS_SECRET variables, then you should set those values to environment variables as shown below:

$ export OAUTH_ACCESS_TOKEN="YOUR ACCESS TOKEN"
$ export OAUTH_ACCESS_SECRET="YOUR ACCESS SECRET"

Finally, you can access Twitter UserStream as follows:

$ cabal run userstream

Examples

TODO

Authors and Credits

twitter-conduit initially was written by Takahiro Himura. We would like to thank everyone who supported and contributed to the development of this library.

Changes

0.6.1

  • Export TweetMode (Extended) #92

0.6.0

  • Support extended tweets #83
  • Remove deprecated module Web.Twitter.Conduit.ParametersDeprecated #81

0.5.1

  • Add result_type to searchTweets #78.

0.5.0

  • Support for OverloadedLabels

    twitter-conduit now supports the OverloadedLabels extensions for overloaded parameters in APIRequest (e.g.: #count, #max_id).

    We can now write:

    homeTimeline & #count ?~ 200
    

    instead of:

    import qualified Web.Twitter.Conduit.Parameters as P
    
    homeTimeline & P.count ?~ 200
    

    NOTE: See Web.Twitter.Conduit.ParametersDeprecated module if you would like to use classic value lenses.

  • Drop supports conduit < 1.3 and http-conduit < 2.3 #69.

  • Web.Twitter.Conduit.Status is no longer re-exported by Web.Twitter.Conduit in order to avoid name conflictions (e.g. update, lookup) #71.

  • Add alias for functions in Web.Twitter.Conduit.Status with statuses- prefix #71. (e.g. Web.Twitter.Conduit.Api.statusesHomeTimeline for Web.Twitter.Conduit.Status.homeTimeline)

  • Drop supports network < 2.6 #74.

  • Support tweet_mode parameter #72.

0.4.0

  • Follow direct message API changes #65 #62
  • Changed WithCursor type 5b9e9d7a
    • Added type parameter to WithCursor to supports Text as the next cursor type.
    • Changed {previous,next}Cursor in WithCursor to be optional
  • Changed APIRequest type to take HTTP Method f25fd9b3

0.3.0

  • Upgrade http-conduit dependencies to: http-conduit >= 2.0 && < 2.4 #59

0.2.2

  • Upgrade http-conduit and http-client dependencies to: http-conduit >= 2.1.8 && http-client >= 0.4.30 #51
  • Added include_email parameter to AccountVerifyCredentials #49
  • Added extAltText parameter to showId #50

0.2.1

  • Added fullText parameter to direct message calls #47
  • Replaced SearchStatus with Status type #46
  • Added accountUpdateProfile #45
  • Added listsMembersCreateAll and listsMembersDestroyAll
  • Parameter lenses in Web.Twitter.Conduit re-exported from Web.Twitter.Conduit.Parameters are deprecated

0.2.0

  • Changed the signature of functions defined in Web.Twitter.Conduit.Base, because Manager of http-conduit 2.0 and later does not need MonadResource. #43
  • Removed TwitterBaseM
  • Removed TW monad
  • Re-exported OAuth (..) and Credential (..) from authenticate-oauth
  • Re-exported def from data-default
  • Re-exported Manager, newManager and tlsManagerSettings from http-conduit

0.1.3

  • Make TWToken and TWInfo an instance of Read and Typeable #42

0.1.2

  • Streaming API: Support multiple filters #41
  • Include parameters in body for POST requests #40

0.1.1.1

  • Fix warnings on GHC 7.10
  • Fix doctest when twitter-feed package exists

0.1.1

  • Add sourceWithSearchResult and sourceWithSearchResult'