A simple Node.js Twitter API
Create a Twitter application from Twitter developer platform.
$ git clone https://github.com/pierrechls/twitter-api.git
$ yarn install
- Create .env file by running :
$ cp .env.example .env
- Set your configuration :
# API
API_URL="<YOUR_API_URL>" # Your local API URL (for example: `http://localhost)
API_PORT="<YOUR_API_PORT>" # Your local API port (for example: `3000`)
# TWITTER
TWITTER_USERNAME="<YOUR_TWITTER_USERNAME>" # Username
TWITTER_CONSUMER_KEY="<YOUR_CONSUMER_KEY>" # API key
TWITTER_CONSUMER_SECRET="<YOUR_CONSUMER_SECRET>" # API secret key
TWITTER_ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>" # Access token
TWITTER_ACCESS_TOKEN_SECRET="<YOUR_ACCESS_TOKEN_SECRET>" # Access token secret
$ yarn server
Method | URL | Description | Twitter API reference |
---|---|---|---|
GET |
/tweets |
Returns a collection of the most recent Tweets posted by the user indicated by the screen_name or user_id parameters. | statuses/user_timeline |
NB : you want another Twitter API ? Please open an issue or create a pull request
You have to create a Heroku application from here
Adding your Heroku application remote url to your local repository :
$ heroku git:remote -a <YOUR_HEROKU_APP_NAME>
Set environnement settings to your Heroku application :
$ heroku config:set TWITTER_USERNAME="<YOUR_TWITTER_USERNAME>" \
TWITTER_CONSUMER_KEY="<YOUR_CONSUMER_KEY>" \
TWITTER_CONSUMER_SECRET="<YOUR_CONSUMER_SECRET>" \
TWITTER_ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>" \
TWITTER_ACCESS_TOKEN_SECRET="<YOUR_ACCESS_TOKEN_SECRET>"
NB : you can also set yours Heroku config vars from the interface by going into the Settings application tab
$ git push heroku master
Please refer to the Twitter developer documentation.
Contributing to twitter-api it's a piece of ๐ฐ. You have an idea about a new feature ? Fork the repo, do your stuff and open a pull request ! You can also report a problem or a suggestion by opening an issue.
Project developed by pierrechls.