Rishikant181 / Rettiwt-API

A CLI tool and an API for fetching data from Twitter for free!
https://rishikant181.github.io/Rettiwt-API/
MIT License
303 stars 31 forks source link

Made FetcherService public which provides a way to access the raw response data #536

Closed Rishikant181 closed 1 month ago

Rishikant181 commented 1 month ago

The FetcherService is the class that directly interacts with the Twitter API. The TweetService and UserService classes actually use the fetcher service underneath to make requests to Twitter API, and then perform some level of post-processing of the returned response to filter out the required data.

Making the FetcherService public provides a way to get the raw response from Twitter as is, without any post processing or potential data loss. This is especially helpful for consumers who want more control over the data they receive and want to handle the data according to their own logic.

The following example demonstrates it's use in case of fetching the details of a given user:

import { FetcherService, EResourceType } from 'rettiwt-api'

// Initializing a new FetcherService instance
// Note how the initialization is similar to that of the 'Rettiwt' instance
const fetcher = new FetcherService({ apiKey: API_KEY, logging: true });

// Fetching the details of the user with the username 'user1'
fetcher.request(EResourceType.USER_DETAILS_BY_USERNAME, { id: 'user1' })
.then(res => {
    console.log(res);
})
.catch(err => {
    console.log(err);
});