Home
Softono

Twitter Api Ts

Open source TypeScript
65
Stars
3
Forks
1
Issues
2
Watchers
8 years
Last Commit

 About Twitter Api Ts

TypeScript compatible Twitter API client

Platforms

Web Self-hosted

Languages

TypeScript

Links

Need Help Installing Twitter Api Ts?

We provide expert installation service for this software. Our team will install, configure, and secure Twitter Api Ts on your server. plans start at just $30.

Twitter Api Ts

View on GitHub

twitter-api-ts

TypScript compatible Twitter API client.

  • io-ts is used to perform IO validation for type safety.
  • fp-ts is used for its Task, Either, and Option types.
  • Request functions return types of type Response<T> = either.Either<ErrorResponse, T>.

This library is written in TypeScript and is published in JavaScript with type declaration files.

Installation

yarn add twitter-api-ts

Example

import { fetchHomeTimeline } from 'twitter-api-ts';
import * as option from 'fp-ts/lib/Option';

const CONSUMER_KEY = 'YOUR_CONSUMER_KEY';
const CONSUMER_SECRET = 'YOUR_CONSUMER_SECRET';
const TOKEN = 'YOUR_TOKEN';
const TOKEN_SECRET = 'YOUR_TOKEN_SECRET';

fetchHomeTimeline({
    oAuth: {
        consumerKey: CONSUMER_KEY,
        consumerSecret: CONSUMER_SECRET,
        token: option.some(TOKEN),
        tokenSecret: option.some(TOKEN_SECRET),
    },
    query: {
        count: option.some(50),
    },
})
    // We use fp-ts’ Task type, which is lazy. Running the task returns a
    // promise.
    .run()
    .then(response => {
        console.log(response);
        // => Either<ErrorResponse, TwitterAPITimelineResponseT>
    });

Development

yarn
yarn compile
yarn lint