GithubHelp home page GithubHelp logo

creachadair / twitter Goto Github PK

View Code? Open in Web Editor NEW
31.0 2.0 2.0 580 KB

A Go client for the Twitter v2 API (in development).

License: MIT License

Go 100.00%
go golang twitter-api-v2 library experimental twitter twitter-api

twitter's Introduction

twitter

Note: It is no longer practical or worthwhile for me to continue work on this library, as Twitter now charges $100 per month for minimal API access. I have therefore archived the repository.

This repository provides Go package that implements an experimental client for the Twitter API v2. It is no longer under active development.

This was an experiment, and is not ready for production use. In particular, test coverage is not nearly as good as it should be. There are replay tests using responses captured from the production service, but a lot of invariants remain unverified.

The documentation could also use more work. All the packages and exported types have doc comments, but working examples are lacking. Normal test-based examples are tricky because there is not (as far as I know) a good test double for the API.

API Index

Here is the current status of v2 API endpoint implementations.

Edits

  • DELETE 2/tweets/:id
  • PUT 2/tweets/:id/hidden
  • POST 2/users/:id/blocking
  • DELETE 2/users/:id/blocking/:other
  • POST 2/users/:id/bookmarks
  • DELETE 2/users/:id/bookmarks/:tid
  • POST 2/users/:id/following
  • DELETE 2/users/:id/following/:other
  • POST 2/users/:id/likes
  • DELETE 2/users/:id/likes/:tid
  • POST 2/users/:id/muting
  • DELETE 2/users/:id/muting/:other
  • POST 2/users/:id/pinned_lists
  • DELETE 2/users/:id/pinned_lists/:lid
  • POST 2/users/:id/retweets
  • DELETE 2/users/:id/retweets/:tid

Lists

  • GET 2/lists
  • POST 2/lists
  • DELETE 2/lists/:id
  • PUT 2/lists/:id
  • GET 2/lists/:id/followers
  • GET 2/lists/:id/members
  • POST 2/lists/:id/members
  • DELETE 2/lists/:id/members/:userid
  • GET 2/lists/:id/tweets
  • GET 2/lists/:id/pinned_lists

Rules

  • GET 2/tweets/search/stream/rules
  • POST 2/tweets/search/stream/rules
  • POST 2/tweets/search/stream/rules, dry_run=true

Tweets

  • GET 2/tweets
  • POST 2/tweets
  • GET 2/tweets/:id/liking_users
  • GET 2/tweets/:id/quote_tweets
  • GET 2/tweets/count/all (requires academic access)
  • GET 2/tweets/count/recent
  • GET 2/tweets/sample/stream
  • GET 2/tweets/search/all (requires academic access)
  • GET 2/tweets/search/recent
  • GET 2/tweets/search/stream

Users

  • GET 2/users
  • GET 2/users/:id/blocking
  • GET 2/users/:id/bookmarks
  • GET 2/users/:id/followed_lists
  • GET 2/users/:id/followers
  • GET 2/users/:id/following
  • GET 2/users/:id/liked_tweets
  • GET 2/users/:id/list_memberships
  • GET 2/users/:id/mentions
  • GET 2/users/:id/muting
  • GET 2/users/:id/owned_lists
  • GET 2/users/:id/retweeted_by
  • GET 2/users/:id/tweets
  • GET 2/users/by
  • GET 2/users/me

twitter's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

nankys lwandsyj

twitter's Issues

Parse and report JSON error messages when requests fail

On error, the v2 API reports a JSON text along with the status code. The exact format isn't clear, but it has the general shape:

{
  "errors": [ {"message": "you done broke it", "code": 45} ]
}

The response codes are defined here: https://developer.twitter.com/en/docs/response-codes. In the wild, though, the format varies quite a bit. Sometimes the top-level message has status and details as additional keys:

{
  "errors": [
    {
      "parameters": {
        "expansions": [
          "3"
        ]
      },
      "message": "The `expansions` query parameter value [3] is not one of [pinned_tweet_id]"
    }
  ],
  "title": "Invalid Request",
  "detail": "One or more parameters to your request was invalid.",
  "type": "https://api.twitter.com/2/problems/invalid-request"
}

Other times everything is inside the array:

{
  "errors": [
    {
      "detail": "Could not find user with username: [fal27f87fse].",
      "title": "Not Found Error",
      "resource_type": "user",
      "parameter": "username",
      "value": "fal27f87fse",
      "type": "https://api.twitter.com/2/problems/resource-not-found"
    }
  ]
}

The API docs don't appear to document the expected formats. Figure out some reasonable way to interpret these values, and attach them to error values.

MediaFields is missing URL

Hi. Thanks for the nice library!

MediaFields is missing URL. We have to make a custom struct to get the media url.
I would be happy to see this fixed.

type MediaFields struct {
	URL bool
}

Add support for the streaming search API

See https://developer.twitter.com/en/docs/twitter-api/tweets/filtered-stream/api-reference/get-tweets-search-stream et seq.

Streaming will require another client method to read from the body progressively. The caller will probably have to plumb in a callback, and we'll have to do something to handle cancellation. Provisionally: When ctx ends, force-close the body to unblock the reader. I'm not sure if that's racy, or if it will trigger a panic, so do some experiments.

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.