twitter-crystal
Version, currently 0.2.13 versions
- 0.2.1latestDec 30, 2017
- 0.2.0not indexedSep 3, 2020
- 0.1.0not indexedSep 3, 2020
github.com/sferik/twitter-crystal
A library to access the Twitter API using Crystal
82 stars
2 dependents
License: Apache
Installation
# Add this to your shard.yml
dependencies:
twitter-crystal:
github: sferik/twitter-crystal
version: ~> 0.2.1Then run:
shards installshard.yml
- Crystal
0.23.1- License
- Apache
- Author
- Erik Michaels-Ober <sferik@gmail.com>
Dependencies
This version declares no dependencies.
README
A library to access the Twitter API using [Crystal][]
-----------------------------------------------------
[crystal]: http://crystal-lang.org/
[][travis]
[travis]: https://travis-ci.org/sferik/twitter-crystal
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
twitter-crystal:
github: sferik/twitter-crystal
version: ~> 0.2.1
```
In your terminal run:
```bash
$ 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:
```crystal
require "twitter-crystal"
```
## Usage
After the installation, you can use twitter-crystal by creating a client object:
```crystal
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](https://dev.twitter.com/oauth/overview/application-owner-access-tokens).
**Post/Delete a tweet**
```crystal
# post a tweet
client.update("Good morning")
# delete a tweet
client.destroy_status(897099923128172545)
```
**Follow a user(by screen name or user_id)**
```crystal
client.follow("kenta_s_dev")
client.follow(776284343173906432)
```
**Unfollow a user(by screen name or user_id)**
```crystal
client.unfollow("kenta_s_dev")
client.unfollow(776284343173906432)
```
**Search users**
```crystal
client.user_search("Crystal lang") # returns maximum of 20 users
```
**Fetch users by user_id/screen_name**
```crystal
client.users("kenta_s_dev")
# fetch multiple users(maximum is 100)
client.users("sferik", "yukihiro_matz", "dhh")
```
**Fetch followers' IDs**
```crystal
client.follower_ids
```
**Fetch followees' IDs**
```crystal
# 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**
```crystal
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](https://dev.twitter.com/rest/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](https://dev.twitter.com/rest/public). There are a lot of things need to be done. Pull Requests are welcome :)
## Contributors
- [sferik](https://github.com/sferik) Erik Michaels-Ober - creator
- [kenta-s](https://github.com/kenta-s) Kenta Shirai - maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.2.1- Tagged
- Dec 30, 2017
- Commit
04ea3c7e936f- Crystal
0.23.1- Indexed
- yes
Dependents
Repository
github.com/sferik/twitter-crystal
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 12, 2026
- Synced
- Aug 12, 2026
- Versions
- 3