Skip to content

Implementation of Twitter internal API (Twitter graphql API) in Go

License

Notifications You must be signed in to change notification settings

Jel1ySpot/twitter-openapi-go-generated

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go API client for openapi

Twitter OpenAPI(Swagger) specification

Overview

This API client was generated from twitter-openapi by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 0.0.1
  • Package version: 1.0.0
  • Generator version: 7.9.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import openapi "github.com/Jel1ySpot/twitter-openapi-go-generated"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value openapi.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value openapi.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using openapi.ContextOperationServerIndices and openapi.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to https://x.com/i/api

Class Method HTTP request Description
DefaultAPI GetProfileSpotlightsQuery Get /graphql/{pathQueryId}/ProfileSpotlightsQuery
DefaultAPI GetTweetResultByRestId Get /graphql/{pathQueryId}/TweetResultByRestId
OtherAPI Other Get /other
PostAPI PostCreateBookmark Post /graphql/{pathQueryId}/CreateBookmark
PostAPI PostCreateRetweet Post /graphql/{pathQueryId}/CreateRetweet
PostAPI PostCreateTweet Post /graphql/{pathQueryId}/CreateTweet
PostAPI PostDeleteBookmark Post /graphql/{pathQueryId}/DeleteBookmark
PostAPI PostDeleteRetweet Post /graphql/{pathQueryId}/DeleteRetweet
PostAPI PostDeleteTweet Post /graphql/{pathQueryId}/DeleteTweet
PostAPI PostFavoriteTweet Post /graphql/{pathQueryId}/FavoriteTweet
PostAPI PostUnfavoriteTweet Post /graphql/{pathQueryId}/UnfavoriteTweet
TweetAPI GetBookmarks Get /graphql/{pathQueryId}/Bookmarks
TweetAPI GetHomeLatestTimeline Get /graphql/{pathQueryId}/HomeLatestTimeline
TweetAPI GetHomeTimeline Get /graphql/{pathQueryId}/HomeTimeline
TweetAPI GetLikes Get /graphql/{pathQueryId}/Likes
TweetAPI GetListLatestTweetsTimeline Get /graphql/{pathQueryId}/ListLatestTweetsTimeline
TweetAPI GetSearchTimeline Get /graphql/{pathQueryId}/SearchTimeline
TweetAPI GetTweetDetail Get /graphql/{pathQueryId}/TweetDetail
TweetAPI GetUserHighlightsTweets Get /graphql/{pathQueryId}/UserHighlightsTweets
TweetAPI GetUserMedia Get /graphql/{pathQueryId}/UserMedia
TweetAPI GetUserTweets Get /graphql/{pathQueryId}/UserTweets
TweetAPI GetUserTweetsAndReplies Get /graphql/{pathQueryId}/UserTweetsAndReplies
UserAPI GetUserByRestId Get /graphql/{pathQueryId}/UserByRestId
UserAPI GetUserByScreenName Get /graphql/{pathQueryId}/UserByScreenName
UserListAPI GetFavoriters Get /graphql/{pathQueryId}/Favoriters
UserListAPI GetFollowers Get /graphql/{pathQueryId}/Followers
UserListAPI GetFollowersYouKnow Get /graphql/{pathQueryId}/FollowersYouKnow
UserListAPI GetFollowing Get /graphql/{pathQueryId}/Following
UserListAPI GetRetweeters Get /graphql/{pathQueryId}/Retweeters
UsersAPI GetUsersByRestIds Get /graphql/{pathQueryId}/UsersByRestIds
V11GetAPI GetFriendsFollowingList Get /1.1/friends/following/list.json
V11GetAPI GetSearchTypeahead Get /1.1/search/typeahead.json
V11PostAPI PostCreateFriendships Post /1.1/friendships/create.json
V11PostAPI PostDestroyFriendships Post /1.1/friendships/destroy.json
V20GetAPI GetSearchAdaptive Get /2/search/adaptive.json

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

Accept

  • Type: API key
  • API key parameter name: Accept
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: Accept and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"Accept": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

AcceptEncoding

  • Type: API key
  • API key parameter name: Accept-Encoding
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: AcceptEncoding and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"AcceptEncoding": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

AcceptLanguage

  • Type: API key
  • API key parameter name: Accept-Language
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: AcceptLanguage and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"AcceptLanguage": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

ActiveUser

  • Type: API key
  • API key parameter name: x-twitter-active-user
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: ActiveUser and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"ActiveUser": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

AuthType

  • Type: API key
  • API key parameter name: x-twitter-auth-type
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: AuthType and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"AuthType": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

BearerAuth

  • Type: HTTP Bearer token authentication

Example

auth := context.WithValue(context.Background(), openapi.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)

ClientLanguage

  • Type: API key
  • API key parameter name: x-twitter-client-language
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: ClientLanguage and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"ClientLanguage": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

ClientTransactionId

  • Type: API key
  • API key parameter name: x-client-transaction-id
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: ClientTransactionId and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"ClientTransactionId": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

ClientUuid

  • Type: API key
  • API key parameter name: x-client-uuid
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: ClientUuid and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"ClientUuid": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

CookieAuthToken

  • Type: API key
  • API key parameter name: auth_token
  • Location:

Note, each API key must be added to a map of map[string]APIKey where the key is: CookieAuthToken and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"CookieAuthToken": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

CookieCt0

  • Type: API key
  • API key parameter name: ct0
  • Location:

Note, each API key must be added to a map of map[string]APIKey where the key is: CookieCt0 and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"CookieCt0": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

CookieGt0

  • Type: API key
  • API key parameter name: gt0
  • Location:

Note, each API key must be added to a map of map[string]APIKey where the key is: CookieGt0 and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"CookieGt0": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

CsrfToken

  • Type: API key
  • API key parameter name: x-csrf-token
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: CsrfToken and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"CsrfToken": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

GuestToken

  • Type: API key
  • API key parameter name: x-guest-token
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: GuestToken and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"GuestToken": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

Referer

  • Type: API key
  • API key parameter name: Referer
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: Referer and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"Referer": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

SecChUa

  • Type: API key
  • API key parameter name: Sec-Ch-Ua
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: SecChUa and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"SecChUa": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

SecChUaMobile

  • Type: API key
  • API key parameter name: Sec-Ch-Ua-Mobile
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: SecChUaMobile and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"SecChUaMobile": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

SecChUaPlatform

  • Type: API key
  • API key parameter name: Sec-Ch-Ua-Platform
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: SecChUaPlatform and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"SecChUaPlatform": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

SecFetchDest

  • Type: API key
  • API key parameter name: Sec-Fetch-Dest
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: SecFetchDest and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"SecFetchDest": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

SecFetchMode

  • Type: API key
  • API key parameter name: Sec-Fetch-Mode
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: SecFetchMode and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"SecFetchMode": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

SecFetchSite

  • Type: API key
  • API key parameter name: Sec-Fetch-Site
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: SecFetchSite and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"SecFetchSite": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

UserAgent

  • Type: API key
  • API key parameter name: user-agent
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: UserAgent and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"UserAgent": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author

[email protected]

About

Implementation of Twitter internal API (Twitter graphql API) in Go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages