gatsby-source-twitter
Source plugin for pulling data into Gatsby from Twitter Search API.
How to use
// In your gatsby-config.js
module.exports = {
plugins: [
{
resolve: `gatsby-source-twitter`,
options: {
q: `@wesbos`,
credentials: {
consumer_key: "INSERT_HERE_YOUR_CONSUMER_KEY",
consumer_secret: "INSERT_HERE_YOUR_CONSUMER_SECRET",
bearer_token: "INSERT_HERE_YOUR_BEARER_TOKEN"
},
tweet_mode: 'extended'
}
}
],
}
Plugin options
- q: A search query. Reference to Twitter Search Tweets API
- count: Number of tweet (default 100)
- credential: You have to create an App on Twitter and creating a bearer token following this instructions using your consumer key and consumer secret
- tweet_mode: Define how tweets are rendered. Possible values
compat
orextended
(default:compat
) More Details - result_type: Default
mixed
, could bemixed
,recent
orpopular
- fetchAllResults: Fetch all pages result
How to query your Tweets data using GraphQL
Below is a sample query for fetching all Tweets nodes.
query PageQuery {
allTweet {
edges {
node {
created_at
full_text
user {
name
}
}
}
}
}
Warning:
id
field is not the tweet id, but Gatbsy internal node id. Useid_str
if you need to use the tweet id