@types/twitter
TypeScript icon, indicating that this package has built-in type declarations

1.7.4 • Public • Published

Installation

npm install --save @types/twitter

Summary

This package contains type definitions for twitter (https://github.com/desmondmorris/node-twitter).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/twitter.

index.d.ts

/// <reference types="node" />

import request = require("request");
import { EventEmitter } from "events";

export = Twitter;

declare class Twitter {
    readonly VERSION: string;
    readonly allow_promise: boolean;
    readonly request: typeof request;

    constructor(options: Twitter.AccessTokenOptions | Twitter.BearerTokenOptions);

    get(path: string, params: Twitter.RequestParams, callback: Twitter.Callback): void;
    get(path: string, callback: Twitter.Callback): void;
    get(path: string, params?: Twitter.RequestParams): Promise<Twitter.ResponseData>;

    post(path: string, params: Twitter.RequestParams, callback: Twitter.Callback): void;
    post(path: string, callback: Twitter.Callback): void;
    post(path: string, params?: Twitter.RequestParams): Promise<Twitter.ResponseData>;

    stream(
        method: "user" | "site" | string,
        params: { [key: string]: any },
        callback: (stream: EventEmitter) => void,
    ): void;
    stream(method: "user" | "site" | string, callback: (stream: EventEmitter) => void): void;
    stream(method: "user" | "site" | string, params?: { [key: string]: any }): EventEmitter;
}

declare namespace Twitter {
    interface Options {
        consumer_key: string;
        consumer_secret: string;
        rest_base?: string | undefined;
        stream_base?: string | undefined;
        user_stream_base?: string | undefined;
        site_stream_base?: string | undefined;
        media_base?: string | undefined;
        request_options?: request.CoreOptions | undefined;
    }

    interface AccessTokenOptions extends Options {
        access_token_key: string;
        access_token_secret: string;
    }

    interface BearerTokenOptions extends Options {
        bearer_token: string;
    }

    type Callback = (error: any, data: ResponseData, response: request.Response) => void;

    interface RequestParams {
        [key: string]: any;
        base?: string | undefined;
    }

    interface ResponseData {
        [key: string]: any;
    }
}

Additional Details

Credits

These definitions were written by BendingBender.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/twitter

Weekly Downloads

9,321

Version

1.7.4

License

MIT

Unpacked Size

6.77 kB

Total Files

5

Last publish

Collaborators

  • types