ExTwitter

Provides access interfaces for the Twitter API.

Summary

configure()

Returns current OAuth configuration settings for accessing twitter server

configure(oauth)

Provides OAuth configuration settings for accessing twitter server

configure(scope, oauth)

Provides OAuth configuration settings for accessing twitter server

destroy_status(id)

POST statuses/destroy/:id

destroy_status(id, options)

POST statuses/destroy/:id

favorites()

GET favorites/list

favorites(options)

GET favorites/list

follower_ids(id_or_options)

GET followers/ids

follower_ids(id, options)

GET followers/ids

followers(id_or_options)

GET followers/list

followers(id, options)

GET followers/list

friend_ids(id_or_options)

GET friends/ids

friend_ids(id, options)

GET friends/ids

friends(id_or_options)

GET friends/list

friends(id, options)

GET friends/list

geo_search(query)

GET geo/search

geo_search(query, options)

GET geo/search

home_timeline()

GET statuses/home_timeline

home_timeline(options)

GET statuses/home_timeline

list_members(options)

GET lists/members

list_members(list, owner)

GET lists/members

list_members(list, owner, options)

GET lists/members

list_memberships()

GET lists/memberships

list_memberships(options)

GET lists/memberships

list_subscribers(options)

GET lists/subscribers

list_subscribers(list, owner)

GET lists/subscribers

list_subscribers(list, owner, options)

GET lists/subscribers

list_timeline(options)

GET lists/statuses

list_timeline(list, owner)

GET lists/statuses

list_timeline(list, owner, options)

GET lists/statuses

lists(id_or_screen_name)

GET lists/list

lists(id_or_screen_name, options)

GET lists/list

lookup_status(id)

GET statuses/lookup

lookup_status(id, options)

GET statuses/lookup

mentions_timeline()

GET statuses/mentions_timeline

mentions_timeline(options)

GET statuses/mentions_timeline

rate_limit_status()

GET application/rate_limit_status

rate_limit_status(options)

GET application/rate_limit_status

request(method, path)

Provides general twitter API access interface

request(method, path, params)

Provides general twitter API access interface

retweeter_ids(id)

GET statuses/retweeters/ids

retweeter_ids(id, options)

GET statuses/retweeters/ids

retweets(id)

GET statuses/retweets/:id

retweets(id, options)

GET statuses/retweets/:id

retweets_of_me()

GET statuses/retweets_of_me

retweets_of_me(options)

GET statuses/retweets_of_me

reverse_geocode(lat, long)

GET geo/reverse_geocode

reverse_geocode(lat, long, options)

GET geo/reverse_geocode

search(query)

GET search/tweets

search(query, options)

GET search/tweets

show(id)

GET statuses/show/:id

show(id, options)

GET statuses/show/:id

stream_control(pid, atom2)

An interface to control the stream

stream_control(pid, atom2, options)

An interface to control the stream

stream_filter(options)

POST statuses/filter

stream_filter(options, timeout)

POST statuses/filter

stream_sample()

GET statuses/sample

stream_sample(options)

GET statuses/sample

trends(id)

GET trends/place

trends(id, options)

GET trends/place

update(status)

POST statuses/update

update(status, options)

POST statuses/update

user(id_or_screen_name)

GET users/show

user(id_or_screen_name, options)

GET users/show

user_lookup(id_or_options)

GET users/lookup

user_lookup(screen_name, options)

GET users/lookup

user_search(query)

GET users/search

user_search(query, options)

GET users/search

user_timeline()

GET statuses/user_timeline

user_timeline(options)

GET statuses/user_timeline

Functions

configure()

Specs:

Returns current OAuth configuration settings for accessing twitter server.

configure(oauth)

Specs:

Provides OAuth configuration settings for accessing twitter server.

The specified configuration applies globally. Use ExTwitter.configure/2 for setting different configurations on each processes.

Examples

ExTwitter.configure(
  consumer_key: System.get_env("TWITTER_CONSUMER_KEY"),
  consumer_secret: System.get_env("TWITTER_CONSUMER_SECRET"),
  access_token: System.get_env("TWITTER_ACCESS_TOKEN"),
  access_token_secret: System.get_env("TWITTER_ACCESS_SECRET")
)
configure(scope, oauth)

Specs:

  • configure(:global | :process, Keyword.t) :: :ok

Provides OAuth configuration settings for accessing twitter server.

Options

The scope can have one of the following values.

  • :global - configuration is shared for all processes.

  • :process - configuration is isolated for each process.

Examples

ExTwitter.configure(
  :process,
  consumer_key: System.get_env("TWITTER_CONSUMER_KEY"),
  consumer_secret: System.get_env("TWITTER_CONSUMER_SECRET"),
  access_token: System.get_env("TWITTER_ACCESS_TOKEN"),
  access_token_secret: System.get_env("TWITTER_ACCESS_SECRET")
)
destroy_status(id)

Specs:

POST statuses/destroy/:id

Examples

ExTwitter.destroy_status(446328507694845952)

Reference

https://dev.twitter.com/docs/api/1.1/post/statuses/destroy/%3Aid

destroy_status(id, options)

Specs:

POST statuses/destroy/:id

Examples

ExTwitter.destroy_status(446328507694845952, trim_user: true)

Reference

https://dev.twitter.com/docs/api/1.1/post/statuses/destroy/%3Aid

favorites()

Specs:

GET favorites/list

Reference

https://dev.twitter.com/docs/api/1.1/get/favorites/list

favorites(options)

Specs:

GET favorites/list

Examples

ExTwitter.favorites(screen_name: "twitter", count: 1)

Reference

https://dev.twitter.com/docs/api/1.1/get/favorites/list

follower_ids(id_or_options)

Specs:

GET followers/ids

Specify one of the screen_name, user_id or options in the argument.

Examples

ExTwitter.follower_ids("twitter")
ExTwitter.follower_ids(783214)
ExTwitter.follower_ids(count: 1)

Reference

https://dev.twitter.com/docs/api/1.1/get/followers/ids

follower_ids(id, options)

Specs:

GET followers/ids

Examples

ExTwitter.follower_ids("twitter", count: 1)
ExTwitter.follower_ids(783214, count: 1)

Reference

https://dev.twitter.com/docs/api/1.1/get/followers/ids

followers(id_or_options)

Specs:

GET followers/list

Specify one of the screen_name, user_id or options in the argument.

Examples

ExTwitter.followers("twitter")
ExTwitter.followers(783214)
ExTwitter.followers(count: 1)

Reference

https://dev.twitter.com/docs/api/1.1/get/followers/list

followers(id, options)

Specs:

GET followers/list

Examples

ExTwitter.followers("twitter", count: 1)
ExTwitter.followers(783214, count: 1)

Reference

https://dev.twitter.com/docs/api/1.1/get/followers/list

friend_ids(id_or_options)

Specs:

GET friends/ids

Specify one of the screen_name, user_id or options in the argument.

Examples

ExTwitter.friend_ids("twitter")
ExTwitter.friend_ids(783214)
ExTwitter.friend_ids(count: 1)

Reference

https://dev.twitter.com/docs/api/1.1/get/friends/ids

friend_ids(id, options)

Specs:

GET friends/ids

Examples

ExTwitter.friend_ids("twitter", count: 1)
ExTwitter.friend_ids(783214, count: 1)

Reference

https://dev.twitter.com/docs/api/1.1/get/friends/ids

friends(id_or_options)

Specs:

GET friends/list

Specify one of the screen_name, user_id or options in the argument.

Examples

ExTwitter.friends("twitter")
ExTwitter.friends(783214)
ExTwitter.friends(count: 1)

Reference

https://dev.twitter.com/docs/api/1.1/get/friends/list

friends(id, options)

Specs:

GET friends/list

Examples

ExTwitter.friends("twitter", count: 1)
ExTwitter.friends(783214, count: 1)

Reference

https://dev.twitter.com/docs/api/1.1/get/friends/list

geo_search(query)

Specs:

GET geo/search

Examples

ExTwitter.geo_search("new york")

Reference

https://dev.twitter.com/docs/api/1.1/get/geo/search

geo_search(query, options)

Specs:

GET geo/search

Examples

ExTwitter.geo_search("new york", max_results: 1)

Reference

https://dev.twitter.com/docs/api/1.1/get/geo/search

home_timeline()

Specs:

GET statuses/home_timeline

Reference

https://dev.twitter.com/docs/api/1.1/get/statuses/home_timeline

home_timeline(options)

Specs:

GET statuses/home_timeline

Examples

ExTwitter.home_timeline(count: 1)

Reference

https://dev.twitter.com/docs/api/1.1/get/statuses/home_timeline

list_members(options)

Specs:

GET lists/members

Examples

ExTwitter.list_members(slug: "twitter-engineering", owner_screen_name: "twitter")

Reference

https://dev.twitter.com/docs/api/1.1/get/lists/members

list_members(list, owner)

Specs:

GET lists/members

Examples

ExTwitter.list_members("twitter-engineering", "twitter")

Reference

https://dev.twitter.com/docs/api/1.1/get/lists/members

list_members(list, owner, options)

Specs:

GET lists/members

Examples

ExTwitter.list_members("twitter-engineering", "twitter", count: 1)

Reference

https://dev.twitter.com/docs/api/1.1/get/lists/members

list_memberships()

Specs:

GET lists/memberships

Reference

https://dev.twitter.com/docs/api/1.1/get/lists/memberships

list_memberships(options)

Specs:

GET lists/memberships

Examples

ExTwitter.list_memberships(screen_name: "twitter", count: 2)

Reference

https://dev.twitter.com/docs/api/1.1/get/lists/memberships

list_subscribers(options)

Specs:

GET lists/subscribers

Examples

ExTwitter.list_subscribers(slug: "twitter-engineering", owner_screen_name: "twitter")

Reference

https://dev.twitter.com/docs/api/1.1/get/lists/subscribers

list_subscribers(list, owner)

Specs:

GET lists/subscribers

Examples

ExTwitter.list_subscribers("twitter-engineering", "twitter")

Reference

https://dev.twitter.com/docs/api/1.1/get/lists/subscribers

list_subscribers(list, owner, options)

Specs:

GET lists/subscribers

Examples

ExTwitter.list_subscribers("twitter-engineering", "twitter", count: 1)

Reference

https://dev.twitter.com/docs/api/1.1/get/lists/subscribers

list_timeline(options)

Specs:

GET lists/statuses

Examples

ExTwitter.list_timeline(slug: "twitter-engineering", owner_screen_name: "twitter")

Reference

https://dev.twitter.com/docs/api/1.1/get/lists/statuses

list_timeline(list, owner)

Specs:

GET lists/statuses

Examples

ExTwitter.list_timeline("twitter-engineering", "twitter")

Reference

https://dev.twitter.com/docs/api/1.1/get/lists/statuses

list_timeline(list, owner, options)

Specs:

GET lists/statuses

Examples

ExTwitter.list_timeline("twitter-engineering", "twitter", count: 1)

Reference

https://dev.twitter.com/docs/api/1.1/get/lists/statuses

lists(id_or_screen_name)

Specs:

GET lists/list

Examples

ExTwitter.lists("twitter")
ExTwitter.lists(783214)

Reference

https://dev.twitter.com/docs/api/1.1/get/lists/list

lists(id_or_screen_name, options)

Specs:

GET lists/list

Examples

ExTwitter.lists("twitter", count: 1)
ExTwitter.lists(783214, count: 1)

Reference

https://dev.twitter.com/docs/api/1.1/get/lists/list

lookup_status(id)

Specs:

GET statuses/lookup

Examples

ExTwitter.lookup_status("504692034473435136,502883389347622912")

Reference

https://dev.twitter.com/docs/api/1.1/get/statuses/lookup

lookup_status(id, options)

Specs:

GET statuses/lookup

Examples

ExTwitter.lookup_status("504692034473435136,502883389347622912", trim_user: true)

Reference

https://dev.twitter.com/docs/api/1.1/get/statuses/lookup

mentions_timeline()

Specs:

GET statuses/mentions_timeline

Reference

https://dev.twitter.com/docs/api/1.1/get/statuses/mentions_timeline

mentions_timeline(options)

Specs:

GET statuses/mentions_timeline

Examples

ExTwitter.mentions_timeline(count: 1)

Reference

https://dev.twitter.com/docs/api/1.1/get/statuses/mentions_timeline

rate_limit_status()

Specs:

  • rate_limit_status :: Map

GET application/rate_limit_status

Examples

status = ExTwitter.rate_limit_status
limit = status["resources"]["statuses"]["/statuses/home_timeline"]["remaining"]

Reference

https://dev.twitter.com/docs/api/1.1/get/application/rate_limit_status

rate_limit_status(options)

Specs:

GET application/rate_limit_status

Examples

ExTwitter.rate_limit_status(resources: "statuses")

Reference

https://dev.twitter.com/docs/api/1.1/get/application/rate_limit_status

request(method, path)

Specs:

  • request(:get | :post, String.t) :: Map

Provides general twitter API access interface.

This method simply returns parsed json in Map structure.

Examples

ExTwitter.request(:get, "1.1/statuses/home_timeline.json")
request(method, path, params)

Specs:

Provides general twitter API access interface.

This method simply returns parsed json in Map structure.

Examples

ExTwitter.request(:get, "1.1/search/tweets.json", [q: "elixir", count: 1])
retweeter_ids(id)

Specs:

GET statuses/retweeters/ids

Examples

ExTwitter.retweeter_ids(444144169058308096)

Reference

https://dev.twitter.com/docs/api/1.1/get/statuses/retweeters/ids

retweeter_ids(id, options)

Specs:

GET statuses/retweeters/ids

Examples

ExTwitter.retweeter_ids(444144169058308096, stringify_ids: true)

Reference

https://dev.twitter.com/docs/api/1.1/get/statuses/retweeters/ids

retweets(id)

Specs:

GET statuses/retweets/:id

Examples

ExTwitter.retweets(444144169058308096)

Reference

https://dev.twitter.com/docs/api/1.1/get/statuses/retweets/%3Aid

retweets(id, options)

Specs:

GET statuses/retweets/:id

Examples

ExTwitter.retweets(444144169058308096, count: 1)

Reference

https://dev.twitter.com/docs/api/1.1/get/statuses/retweets/%3Aid

retweets_of_me()

Specs:

GET statuses/retweets_of_me

Reference

https://dev.twitter.com/docs/api/1.1/get/statuses/retweets_of_me

retweets_of_me(options)

Specs:

GET statuses/retweets_of_me

Examples

ExTwitter.retweets_of_me(count: 1)

Reference

https://dev.twitter.com/docs/api/1.1/get/statuses/retweets_of_me

reverse_geocode(lat, long)

Specs:

GET geo/reverse_geocode

Examples

ExTwitter.reverse_geocode(37.7821120598956, -122.400612831116)

Reference

https://dev.twitter.com/docs/api/1.1/get/geo/reverse_geocode

reverse_geocode(lat, long, options)

Specs:

GET geo/reverse_geocode

Examples

ExTwitter.reverse_geocode(37.7821120598956, -122.400612831116, max_results: 1)

Reference

https://dev.twitter.com/docs/api/1.1/get/geo/reverse_geocode

search(query)

Specs:

GET search/tweets

Examples

ExTwitter.search("test")

Reference

https://dev.twitter.com/docs/api/1.1/get/search/tweets

search(query, options)

Specs:

GET search/tweets

Examples

ExTwitter.search("test", count: 1)

Reference

https://dev.twitter.com/docs/api/1.1/get/search/tweets

show(id)

Specs:

GET statuses/show/:id

Examples

ExTwitter.show(446328507694845952)

Reference

https://dev.twitter.com/docs/api/1.1/get/statuses/show/%3Aid

show(id, options)

Specs:

GET statuses/show/:id

Examples

ExTwitter.show(446328507694845952, trim_user: true)

Reference

https://dev.twitter.com/docs/api/1.1/get/statuses/show/%3Aid

stream_control(pid, atom2)

Specs:

  • stream_control(pid, :stop) :: :ok

An interface to control the stream.

This method is for controlling stream, and it doesn’t make twitter API call.

Options

The pid is the process id where stream is being processed.

Examples

ExTwitter.stream_control(pid, :stop)
stream_control(pid, atom2, options)

Specs:

  • stream_control(pid, :stop, [{:timeout, Integer}]) :: :ok

An interface to control the stream.

This method is for handling elixir’s stream which can keep running infinitely. It doesn’t make twitter API call.

Options

The options can have following values, in addition to the twitter API’s parameter.

  • :receive_messages - true/false flag whether to receive control messages in addition to normal tweets. default is false.

The pid is the process id where stream is processed.

The timeout is the maximum wait time (in milliseconds) to complete the message handling.

Examples

ExTwitter.stream_control(pid, :stop, timeout: 50)
stream_filter(options)

Specs:

POST statuses/filter

Returns public statuses that match one or more filter predicates. This method returns the Stream that holds the list of tweets. Specify at least one of the [follow, track, locations] options.

Options

The options can have following values, in addition to the twitter API’s parameter.

  • :receive_messages - true/false flag whether to receive control messages in addition to normal tweets. default is false.

Examples

ExTwitter.stream_filter(track: "apple")

Reference

https://dev.twitter.com/docs/api/1.1/post/statuses/filter

stream_filter(options, timeout)

Specs:

POST statuses/filter

Returns public statuses that match one or more filter predicates. This method returns the Stream that holds the list of tweets. Specify at least one of the [follow, track, locations] options.

Options

The options can have following values, in addition to the twitter API’s parameter.

  • :receive_messages - true/false flag whether to receive control messages in addition to normal tweets. default is false.

The timeout is the maximum milliseconds to wait until receiving next tweet. Specifying :infinity makes it wait infinitely.

Examples

ExTwitter.stream_filter(track: "apple", timeout: 60000)

Reference

https://dev.twitter.com/docs/api/1.1/post/statuses/filter

stream_sample()

Specs:

GET statuses/sample

Returns a small random sample of all public statuses. This method returns the Stream that holds the list of tweets.

Reference

https://dev.twitter.com/docs/api/1.1/get/statuses/sample

stream_sample(options)

Specs:

GET statuses/sample

Returns a small random sample of all public statuses. This method returns the Stream that holds the list of tweets.

Options

The options can have following values, in addition to the twitter API’s parameter.

  • :receive_messages - true/false flag whether to receive control messages in addition to normal tweets. default is false.

Reference

https://dev.twitter.com/docs/api/1.1/get/statuses/sample

trends(id)

Specs:

GET trends/place

Examples

ExTwitter.trends(1)

Reference

https://dev.twitter.com/rest/reference/get/trends/place

trends(id, options)

Specs:

GET trends/place

Examples

ExTwitter.trends(1, exclude: true)

Reference

https://dev.twitter.com/rest/reference/get/trends/place

update(status)

Specs:

POST statuses/update

Examples

ExTwitter.update("update sample")

Reference

https://dev.twitter.com/docs/api/1.1/post/statuses/update

update(status, options)

Specs:

POST statuses/update

Examples

ExTwitter.update("update sample", trim_user: true)

Reference

https://dev.twitter.com/docs/api/1.1/post/statuses/update

user(id_or_screen_name)

Specs:

GET users/show

Examples

ExTwitter.user("elixirlang")
ExTwitter.user(507309896)

Reference

https://dev.twitter.com/docs/api/1.1/get/users/show

user(id_or_screen_name, options)

Specs:

GET users/show

Examples

ExTwitter.user("elixirlang", include_entities: false)
ExTwitter.user(507309896, include_entities: false)

Reference

https://dev.twitter.com/docs/api/1.1/get/users/show

user_lookup(id_or_options)

Specs:

GET users/lookup

Examples

ExTwitter.user_lookup("twitter")
ExTwitter.user_lookup(783214)
ExTwitter.user_lookup(screen_name: "twitter")

Reference

https://dev.twitter.com/docs/api/1.1/get/users/lookup

user_lookup(screen_name, options)

Specs:

GET users/lookup

Examples

ExTwitter.user_lookup("twitter", include_entities: false)
ExTwitter.user_lookup(783214, include_entities: false)

Reference

https://dev.twitter.com/docs/api/1.1/get/users/lookup

user_search(query)

Specs:

GET users/search

Examples

ExTwitter.user_search("elixirlang")

Reference

https://dev.twitter.com/docs/api/1.1/get/users/search

user_search(query, options)

Specs:

GET users/search

Examples

ExTwitter.user_search("elixirlang", count: 1)

Reference

https://dev.twitter.com/docs/api/1.1/get/users/search

user_timeline()

Specs:

GET statuses/user_timeline

Reference

https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline

user_timeline(options)

Specs:

GET statuses/user_timeline

Examples

ExTwitter.user_timeline(count: 1)

Reference

https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline