https://github.com/oliverjash/twitter-api-ts
TypeScript compatible Twitter API client
https://github.com/oliverjash/twitter-api-ts
api-client javascript twitter twitter-api typescript
Last synced: 3 months ago
JSON representation
TypeScript compatible Twitter API client
- Host: GitHub
- URL: https://github.com/oliverjash/twitter-api-ts
- Owner: OliverJAsh
- Created: 2017-05-19T11:38:19.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-08-11T18:13:29.000Z (almost 7 years ago)
- Last Synced: 2025-03-01T06:42:02.277Z (3 months ago)
- Topics: api-client, javascript, twitter, twitter-api, typescript
- Language: TypeScript
- Homepage:
- Size: 107 KB
- Stars: 64
- Watchers: 4
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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 = either.Either`.This library is written in TypeScript and is published in JavaScript with type declaration files.
## Installation
```
yarn add twitter-api-ts
```## Example
``` ts
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
});
```## Development
```
yarn
yarn compile
yarn lint
```[io-ts]: https://github.com/gcanti/io-ts
[fp-ts]: https://github.com/gcanti/fp-ts