• Stars
    star
    82
  • Rank 396,546 (Top 8 %)
  • Language
    Crystal
  • License
    Other
  • Created about 10 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A library to access the Twitter API using Crystal

A library to access the Twitter API using Crystal

Build Status

Installation

Add this to your application's shard.yml:

dependencies:
  twitter-crystal:
    github: sferik/twitter-crystal
    version: ~> 0.2.1

In your terminal run:

$ crystal deps

This will get the latest code from this github repository and copy it to a lib directory. All that's left is to require it:

require "twitter-crystal"

Usage

After the installation, you can use twitter-crystal by creating a client object:

require "twitter-crystal"

consumer_key        = "your consumer key"
consumer_secret     = "your consumer secret"
access_token        = "your access token"
access_token_secret = "your access token secret "

client = Twitter::REST::Client.new(consumer_key, consumer_secret, access_token, access_token_secret)

All the necessary keys can be generated by creating a Twitter application.

Post/Delete a tweet

# post a tweet
client.update("Good morning")

# delete a tweet
client.destroy_status(897099923128172545)

Fetch a particular Tweet by ID

client.status(950491199454044162)

Follow a user(by screen name or user_id)

client.follow("kenta_s_dev")
client.follow(776284343173906432)

Unfollow a user(by screen name or user_id)

client.unfollow("kenta_s_dev")
client.unfollow(776284343173906432)

Search users

client.user_search("Crystal lang") # returns maximum of 20 users

Fetch users by user_id/screen_name

client.users("kenta_s_dev")

# fetch multiple users(maximum is 100)
client.users("sferik", "yukihiro_matz", "dhh")

Fetch followers' IDs

client.follower_ids

Fetch followees' IDs

# In Twitter API documents, followees are called 'friends'.
client.friend_ids

You can also call Twitter's API directly using the get or post method

client.get("/1.1/users/show.json", { "screen_name" => "sferik" })
client.post("/1.1/statuses/update.json", { "status" => "The world is your oyster." })

If you want to call the API directly, refer to the API reference.

Contributing

  1. Fork it ( https://github.com/sferik/twitter-crystal/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Pull Requests are very welcome!

The goal of the project is to implement all methods to call Twitter REST API. There are a lot of things need to be done. Pull Requests are welcome :)

Contributors

  • sferik Erik Michaels-Ober - creator
  • kenta-s Kenta Shirai - maintainer

More Repositories

1

t-ruby

A command-line power tool for Twitter.
Ruby
5,425
star
2

twitter-ruby

A Ruby interface to the Twitter API.
Ruby
4,578
star
3

active_emoji

A collection of emoji aliases for core Ruby methods
Ruby
572
star
4

multi_xml

A generic swappable back-end for XML parsing
Ruby
157
star
5

sign-in-with-twitter

A Ruby on Rails application that demonstrates how to use the Sign in with Twitter workflow using the twitter gem and OmniAuth.
Ruby
137
star
6

openai-ruby

Wrapper for calling OpenAI and GPT-3's HTTP APIs
Ruby
110
star
7

mtgox

Ruby wrapper for the Mt. Gox Trade API
Ruby
83
star
8

dotfiles

Configuration files for all of my Unix utilities
Shell
80
star
9

merb-admin

MerbAdmin is a Merb plugin that provides an easy-to-use interface for managing your data
Ruby
70
star
10

mlb-ruby

A Ruby library for retrieving Major League Baseball teams, players, and transactions.
Ruby
65
star
11

x-ruby

A Ruby interface to the X API.
Ruby
61
star
12

openai-crystal

OpenAI API client library to access GPT-3 in Crystal
Crystal
44
star
13

spellout

A command-line tool that converts input into the International Radiotelephony Spelling Alphabet
Crystal
26
star
14

tradehill

Ruby wrapper for the TradeHill API
Ruby
14
star
15

pager

Git-style automatic paging in Ruby
Ruby
14
star
16

buftok

BufferedTokenizer extracts token delimited entities from a sequence of arbitrary inputs
Ruby
10
star
17

wc.cr

A POSIX-compliant implementation of the wc command-line utility, written in 50 lines of Crystal.
Shell
10
star
18

soundcloud-crystal

A library to access the SoundCloud API using Crystal
Crystal
10
star
19

x-crystal

A Crystal interface to the X API.
Crystal
9
star
20

gems

Ruby wrapper for the RubyGems.org API
Ruby
9
star
21

got

A Go port of the t Ruby gem
Go
4
star
22

geoip_server_test_data

Test data for https://github.com/JackDanger/geoip_server
4
star
23

410_in_140

A Twitter API v1 server in 140 characters
Ruby
4
star
24

hyperimage

Ruby
4
star
25

mwrc2012-app

Ruby
3
star
26

rspec-demo

Ruby
3
star
27

ruby

Get info about your Ruby environment
Ruby
3
star
28

timer

JavaScript countdown clock
3
star
29

ajax-demo

Ruby
3
star
30

nyt

iOS home screen icon for The New York Times newsstand app
3
star
31

backbone-todo

TODO app implemented in Backbone.js
JavaScript
2
star
32

movies

Ruby
2
star
33

rubysl-json

Ruby Standard Library - json
C
2
star
34

gitter

An API server that provides my personal GitHub and Twitter activity data in JSON format
Ruby
2
star
35

todo

Ruby
2
star
36

isitruby200

An app to check whether your code is Ruby 2.0.0 compatible.
CSS
2
star
37

carrierwave-demo

Rails app to demonstrate file uploads with CarrierWave
Ruby
2
star
38

git-demo

This is a demo of how to use git
1
star
39

wdi

Ruby
1
star
40

library

Ruby
1
star
41

nynnets

Little exercises for Nynne
Ruby
1
star
42

rectangle

Ruby
1
star
43

sferik.github.com

Test deployment with GitHub
1
star
44

rubysl-etc

Ruby Standard Library - etc
Ruby
1
star
45

wsj

iOS home screen icon for The Wall Street Journal newsstand app
CSS
1
star
46

d3-demo

1
star
47

translations

Generation and translation of transcripts from talks on Confraks
Ruby
1
star