Class UserService

Handles interacting with resources related to user account

Hierarchy

Constructors

Properties

authProxyUrl?: URL

The URL to the proxy server to use only for authentication.

Methods

  • Get the details of a user.

    Parameters

    • id: string

      The username/id of the target user.

    Returns Promise<undefined | User>

    The details of the given user. If no user matches the given id, returns undefined.

    Example

    Fetching the details using username

    import { Rettiwt } from 'rettiwt-api';

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

    // Fetching the details of the User with username 'user1'
    rettiwt.user.details('user1')
    .then(res => {
    console.log(res);
    })
    .catch(err => {
    console.log(err);
    });

    Example

    Fetching the details using id

    import { Rettiwt } from 'rettiwt-api';

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

    // Fetching the details of the User with id '1234567890'
    rettiwt.user.details('1234567890')
    .then(res => {
    console.log(res);
    })
    .catch(err => {
    console.log(err);
    });
  • Follow a user.

    Parameters

    • id: string

      The id the user to be followed.

    Returns Promise<boolean>

    Whether following was successful or not.

    Throws

    Code 108 if given user id is invalid.

    Example

    import { Rettiwt } from 'rettiwt-api';

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

    // Following the User with id '1234567890'
    rettiwt.user.follow('1234567890')
    .then(res => {
    console.log(res);
    })
    .catch(err => {
    console.log(err);
    });
  • Get the list followers of a user.

    Parameters

    • id: string

      The id of the target user.

    • Optional count: number

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

    • Optional cursor: string

      The cursor to the batch of followers to fetch.

    Returns Promise<CursoredData<User>>

    The list of users following the target user.

    Example

    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 followers of the User with id '1234567890'
    rettiwt.user.followers('1234567890')
    .then(res => {
    console.log(res);
    })
    .catch(err => {
    console.log(err);
    });
  • Get the list of users who are followed by a user.

    Parameters

    • id: string

      The id of the target user.

    • Optional count: number

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

    • Optional cursor: string

      The cursor to the batch of following to fetch.

    Returns Promise<CursoredData<User>>

    The list of users followed by the target user.

    Example

    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 following of the User with id '1234567890'
    rettiwt.user.following('1234567890')
    .then(res => {
    console.log(res);
    })
    .catch(err => {
    console.log(err);
    });
  • Get the highlighted tweets of a user.

    Parameters

    • id: string

      The id of the target user.

    • Optional count: number

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

    • Optional cursor: string

      The cursor to the batch of followers to fetch.

    Returns Promise<CursoredData<Tweet>>

    The list of highlighted tweets of the target user.

    Example

    import { Rettiwt } from 'rettiwt-api';

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

    // Fetching the top 100 highlights of the User with id '1234567890'
    rettiwt.user.highlights('1234567890')
    .then(res => {
    console.log(res);
    })
    .catch(err => {
    console.log(err);
    });
  • Get the list of tweets liked by a user.

    Parameters

    • id: string

      The id of the target user.

    • Optional count: number

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

    • Optional cursor: string

      The cursor to the batch of likes to fetch.

    Returns Promise<CursoredData<Tweet>>

    The list of tweets liked by the target user.

    Example

    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 liked Tweets of the User with id '1234567890'
    rettiwt.user.likes('1234567890')
    .then(res => {
    console.log(res);
    })
    .catch(err => {
    console.log(err);
    });
  • Get the media timeline of a user

    Parameters

    • id: string

      The id of the target user.

    • Optional count: number

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

    • Optional cursor: string

      The cursor to the batch of media to fetch

    Returns Promise<CursoredData<Tweet>>

    The media timeline of the target user.

    Example

    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 timeline media tweets of the User with id '1234567890'
    rettiwt.user.timeline('1234567890')
    .then(res => {
    console.log(res);
    })
    .catch(err => {
    console.log(err);
    });
  • Get the reply timeline of a user.

    Parameters

    • id: string

      The id of the target user.

    • Optional count: number

      The number of replies to fetch, must be <= 20.

    • Optional cursor: string

      The cursor to the batch of replies to fetch.

    Returns Promise<CursoredData<Tweet>>

    The reply timeline of the target user.

    Example

    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 timeline replies of the User with id '1234567890'
    rettiwt.user.replies('1234567890')
    .then(res => {
    console.log(res);
    })
    .catch(err => {
    console.log(err);
    });

    Remarks

    If the target user has a pinned tweet, the returned reply timeline has one item extra and this is always the pinned tweet.

  • Makes an HTTP request according to the given parameters.

    Type Parameters

    • T

      The type of the returned response data.

    Parameters

    Returns Promise<T>

    The raw data response received.

    Example

    Fetching the raw details of a user with username 'user1'

    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 subscriptions of a user.

    Parameters

    • id: string

      The id of the target user.

    • Optional count: number

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

    • Optional cursor: string

      The cursor to the batch of subscriptions to fetch.

    Returns Promise<CursoredData<User>>

    The list of subscriptions by the target user.

    Example

    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 subscriptions of the User with id '1234567890'
    rettiwt.user.subscriptions('1234567890')
    .then(res => {
    console.log(res);
    })
    .catch(err => {
    console.log(err);
    });
  • Get the tweet timeline of a user.

    Parameters

    • id: string

      The id of the target user.

    • Optional count: number

      The number of timeline items to fetch, must be <= 20.

    • Optional cursor: string

      The cursor to the batch of timeline items to fetch.

    Returns Promise<CursoredData<Tweet>>

    The timeline of the target user.

    Example

    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 20 timeline tweets of the User with id '1234567890'
    rettiwt.user.timeline('1234567890')
    .then(res => {
    console.log(res);
    })
    .catch(err => {
    console.log(err);
    });

    Remarks

    • If the target user has a pinned tweet, the returned timeline has one item extra and this is always the pinned tweet.
    • If timeline is fetched without authenticating, then the most popular tweets of the target user are returned instead.
  • Unfollow a user.

    Parameters

    • id: string

      The id the user to be unfollowed.

    Returns Promise<boolean>

    Whether unfollowing was successful or not.

    Throws

    Code 34 if given user id is invalid.

    Example

    import { Rettiwt } from 'rettiwt-api';

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

    // Unfollowing the User with id '12345678'
    rettiwt.user.unfollow('12345678')
    .then(res => {
    console.log(res);
    })
    .catch(err => {
    console.log(err);
    });

Generated using TypeDoc