Giter Site home page Giter Site logo

jerryodd485 / whisper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from p1atdev/whisper

0.0 0.0 0.0 43 KB

A client that wraps the API behind Twitter.

Home Page: https://deno.land/x/whisper

License: MIT License

TypeScript 96.44% Dockerfile 3.56%

whisper's Introduction

Whisper

A client that wraps the API behind Twitter.

deno module deno compatibility vr scripts codecov Testing Lint

Features

  • You can use endpoints not officially provided
    • GraphQL endpoint (UserByScreenName, UserTweets, etc...)
    • "i" endpoint (/users/email_available.json, etc...)
  • You can use the hidden api without any tokens
    • Whisper uses the official web client's token

Example

Full example code can be seen on /test/example.test.ts

User By Screen Name (GraphQL endpoint)

const client = new TwitterAPI(Bearer.Web);

const query = new RequestQuery({
  variables: {
    screen_name: "deno_land",
    withSafetyModeUserFields: true,
    withSuperFollowsUserFields: true,
  },
});

const res = await client.request({
  method: "GET",
  urlType: "gql",
  path: "UserByScreenName",
  query: query,
});

const json = await res.json();

assertEquals(json.data.user.result.rest_id, "1108769816230293504");

Search Adaptive (v2 endpoint)

const client = new TwitterAPI(Bearer.Web);

const query = new RequestQuery({
  q: "from:@deno_land",
  count: 3,
});

const res = await client.request({
  method: "GET",
  urlType: "i/api/2",
  path: "/search/adaptive.json",
  query: query,
});

const json = await res.json();

assertExists(json.globalObjects.users["1108769816230293504"]);

User Tweets (GraphQL endpoint)

const client = new TwitterAPI(Bearer.Web);

const query = new RequestQuery({
  variables: {
    userId: "1108769816230293504",
    count: 4,
    includePromotedContent: false,
    withVoice: false,
    withDownvotePerspective: true,
    withReactionsMetadata: false,
    withReactionsPerspective: false,
    withSuperFollowsTweetFields: false,
    withSuperFollowsUserFields: false,
  },
  features: {
    tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled:
      false,
    interactive_text_enabled: true,
    standardized_nudges_misinfo: true,
    responsive_web_edit_tweet_api_enabled: true,
    responsive_web_enhance_cards_enabled: false,
    vibe_api_enabled: true,
    dont_mention_me_view_api_enabled: true,
    responsive_web_uc_gql_enabled: true,
  },
});

const res = await client.request({
  method: "GET",
  urlType: "gql",
  path: "UserTweets",
  query: query,
});

const json = await res.json();

const timeline = json.data.user.result.timeline;

console.dir(timeline, { depth: 10 });

// Output:
//
// {
//   timeline: {
//     instructions: [
//       { type: "TimelineClearCache" },
//       {
//         type: "TimelineAddEntries",
//         entries: [
//           {
//             entryId: "tweet-1558145641565474816",
//             sortIndex: "1558145641565474816",
//             content: {
//               entryType: "TimelineTimelineItem",
//               __typename: "TimelineTimelineItem",
//               itemContent: {
//                 itemType: "TimelineTweet",
//                 __typename: "TimelineTweet",
//                 tweet_results: {
//                   result: {
//                     __typename: "Tweet",
//                     rest_id: "1558145641565474816",
//                     core: [Object],
//                     card: [Object],
//                     unmention_info: [Object],
//                     unified_card: [Object],
//                     edit_control: [Object],
//                     legacy: [Object]
//                   }
//                 },
//                 tweetDisplayType: "Tweet",
//                 ruxContext: "HHwWgMCqnZTN0p8rAAAA"
//  ...

Email Available (i endpoint)

const client = new TwitterAPI(Bearer.Web);

const query = new RequestQuery({
  email: "[email protected]",
});

const res = await client.request({
  method: "GET",
  urlType: "i/api/i",
  path: "/users/email_available.json",
  query: query,
});

const json = await res.json();

assertEquals(json.valid, false);
assertEquals(json.taken, false);

Note

Request parameters and response types are not supported in this module due to the rapidly changing unofficial API specifications. Beware that Twitter will change its API specification without notice.

whisper's People

Contributors

p1atdev avatar jerryodd485 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.