Class ListService

The base service that handles all HTTP requests.

Hierarchy (View Summary)

Constructors

Properties

Methods

Constructors

Properties

config: RettiwtConfig

The config object.

Methods

  • Get the list of members of a tweet list.

    Parameters

    • id: string

      The ID of target list.

    • Optionalcount: number

      The number of members to fetch, must be <= 100.

    • Optionalcursor: string

      The cursor to the batch of members to fetch.

    Returns Promise<CursoredData<User>>

    The list tweets in the given list.

    import { Rettiwt } from 'rettiwt-api';

    // Creating a new Rettiwt instance using the given 'API_KEY'
    const rettiwt = new Rettiwt({ apiKey: API_KEY });

    // Fetching the first 100 members of the Twitter list with id '1234567890'
    rettiwt.list.members('1234567890')
    .then(res => {
    console.log(res);
    })
    .catch(err => {
    console.log(err);
    });

    Due a bug in Twitter API, the count is ignored when no cursor is provided and defaults to 100.

  • Makes an HTTP request according to the given parameters.

    Type Parameters

    • T = unknown

      The type of the returned response data.

    Parameters

    Returns Promise<T>

    The raw data response received.

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

    // Creating a new FetcherService instance using the given 'API_KEY'
    const fetcher = new FetcherService({ apiKey: API_KEY });

    // Fetching the details of the User with username 'user1'
    fetcher.request(EResourceType.USER_DETAILS_BY_USERNAME, { id: 'user1' })
    .then(res => {
    console.log(res);
    })
    .catch(err => {
    console.log(err);
    });
  • Get the list of tweets from a tweet list.

    Parameters

    • id: string

      The ID of target list.

    • Optionalcount: number

      The number of tweets to fetch, must be <= 100.

    • Optionalcursor: string

      The cursor to the batch of tweets to fetch.

    Returns Promise<CursoredData<Tweet>>

    The list tweets in the given list.

    import { Rettiwt } from 'rettiwt-api';

    // Creating a new Rettiwt instance using the given 'API_KEY'
    const rettiwt = new Rettiwt({ apiKey: API_KEY });

    // Fetching the most recent 100 tweets of the Twitter list with id '1234567890'
    rettiwt.list.tweets('1234567890')
    .then(res => {
    console.log(res);
    })
    .catch(err => {
    console.log(err);
    });

    Due a bug in Twitter API, the count is ignored when no cursor is provided and defaults to 100.