Skip to main content
Module

x/deno_twitter_api/twitterApi.ts>TwitterApi

A Deno Module to make accessing the Twitter API from Deno a bit easier.
Latest
class TwitterApi
import { TwitterApi } from "https://deno.land/x/deno_twitter_api@v1.1.0/twitterApi.ts";

Constructors

new
TwitterApi(keys: Keys)

This class is used to access the twitter api

The link for the implementation rules can be found here: https://developer.twitter.com/en/docs/basics/authentication/guides/authorizing-a-request

[consumerApiKey], [consumerApiSecret], [accessToken], and [accessTokenSecret] come from the link above. They are unique for each app and user. You will need to generate your own and pass them in when creating the TwitterOauth object.

Properties

private
baseUrl: string
private
oauth_consumer_key: string
private
oauth_consumer_secret: string
private
readonly
oauth_signature_method: string
private
oauth_token: string
private
oauth_token_secret: string
private
readonly
oauth_version: string

Methods

private
createAuthHeader(
oauth_nonce: string,
oauth_timestamp: string,
oauth_signature: string,
): string
private
createSignature(
oauth_nonce: string,
oauth_timestamp: string,
unnamed 2: { options: Options; method: "GET" | "POST"; url: string; },
): string
private
encodeAuthHeaderKeyValuePair(key: string, value: string): string
private
generateNonce(): string
private
getCurrentTimestamp(): string
private
percentEncode(val: string): string
get(url: string, options?: Options): Promise<Response>

Makes a get request to the twitter api The [url] should not include https://api.twitter.com/1.1/

Good: lists/statuses.json

Bad: https://api.twitter.com/1.1/lists/statuses.json

getBaseUrl(): string
post(url: string, options?: Options): Promise<Response>

Makes a post request to the twitter api The [url] should not include https://api.twitter.com/1.1/

Good: lists/statuses.json

Bad: https://api.twitter.com/1.1/lists/statuses.json

request(
method: "GET" | "POST",
url: string,
options?: Options,
): Promise<Response>

Makes a post request to the twitter api The [url] should not include https://api.twitter.com/1.1/

Good: lists/statuses.json

Bad: https://api.twitter.com/1.1/lists/statuses.json

setBaseUrl(baseUrl: string): void