An API for fetching data from TwitterAPI, without any rate limits!
It works well for small applications like the one side project you started and are never gonna finish
For complete documentation and API reference, head over to the documentation
Using the API as a GraphQL enables complex nested queries to fetch data from twitter.
To use the API as a server,
- Clone the repo's release branch
- Build the project using 'npm run build'
- Set the environment variables:
- APP_PORT -> The port number where the server will listen to
- DEVELOPMENT -> Whether to run the server in development mode or not - Start the server using 'npm run start'
- Make graphql requests to server listening on localhost:port/graphql
You can go to localhost:port/graphql to see the graphql schema
The API can also be used as a standalone npm package.
The limitation is that, large number of data cannot be fetched automatically, and the data needs to fetched in batches, by using cursors.
Further nested queries are not possible.
To use the API as an npm package,
- In your node project, install the package using 'npm install --save rettiwt-api'.
- import { Rettiwt } from 'rettiwt-api'.
const rettiwt = Rettiwt(). - Use the created Rettiwt instance to fetch data from Twitter.
This creates an instance of Rettiwt which can be used to fetch data from Twitter. This instance works as guest and no form of authentication is used. However, guest mode implies functionalities such fetching of user followings, followers, likes and tweet likes, retweets, quotes and replies is not possible. Whatever data can be viewed in Twitter without loggin in, can be accessed this way.
If you wan't full functionality, you need to use the cookie of a logged in Twitter account, which can be retrieved in the following way:
- Make the following query to the GraphQL server:
query {
Login(email: "your_twitter_email", userName: "your_twitter_username", password: "your_twitter_password") {
auth_token
ct0
kdt
twid
}
}
- This will give you 4 tokens: 'auth_token', 'ct0', 'kdt' and 'twid'.
- Pass the four tokens in the headers while making any request made to the GraphQL server for fetching data.
- Use the Rettiwt().account.login method to get back 4 tokens: 'auth_token', 'ct0', 'kdt' and 'twid'.
- Use these four tokens to initialize a new Rettiwt instance as follows:
const rettiwt = new Rettiwt({
auth_token: "received_auth_token",
ct0: "received_ct0_token",
kdt: "received_kdt_token",
twid: "received_twid_token"
});
- Use the created Rettiwt instance to fetch data.