
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
gatsby-source-twitter
Advanced tools
Source plugin for pulling data into Gatsby from Twitter Search API.
Actually the plugin support a bunch of API endopoints
Check Twitter documentation for more details
To start using this plugin you have to create an App on developer and then create a bearer token to use application authentication
Note: Only api that use application authentication will works. User authentication api are not supported
Here an example of the configuration
// In your gatsby-config.js
module.exports = {
plugins: [
{
resolve: `gatsby-source-twitter`,
options: {
credentials: {
consumer_key: "INSERT_HERE_YOUR_CONSUMER_KEY",
consumer_secret: "INSERT_HERE_YOUR_CONSUMER_SECRET",
bearer_token: "INSERT_HERE_YOUR_BEARER_TOKEN",
},
queries: {
nameofthequery: {
endpoint: "statuses/user_timeline",
params: {
screen_name: "gatsbyjs",
include_rts: false,
exclude_replies: true,
tweet_mode: "extended",
},
},
nameofanotherthequery: {
endpoint: "search/tweets",
params: {
q: "#gatsbyjs",
tweet_mode: "extended",
},
},
},
},
},
],
}
Check this repository for more example.
You have to create an App on Twitter and creating a bearer token following this instructions using your consumer key and consumer secret
You have to specify a object where each key is a query to Twitter API.
Choose a name for the query (you will use later to retrieve data), for example gatsbyHashtag
, but you can use whatever you want.
queries: {
gatsbyHashtag: {
endpoint: "search/tweets",
params: {
q: "#gatsbyjs",
tweet_mode: "extended",
},
},
},
endpoint
option.search/tweets
)Now that you fetch some data from Twitter, you can access it with a GraphQL query.
The below gatsbyHashtag
query will became allTwitterGatsbyHashtag
Below is a sample query for fetching all Tweets nodes.
query {
allTwitterGatsbyHashtag {
edges {
node {
full_text # or text depending by endpoint params
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
3.x.x version contains some breaking changes. Here an example of how to migrate from 2.x version
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'
}
options: {
credentials: {
consumer_key: "INSERT_HERE_YOUR_CONSUMER_KEY",
consumer_secret: "INSERT_HERE_YOUR_CONSUMER_SECRET",
bearer_token: "INSERT_HERE_YOUR_BEARER_TOKEN",
},
queries: {
wesbos: {
endpoint: "search/tweets",
params: {
q: "@wesbos",
tweet_mode: "extended",
},
},
},
},
query {
allTwitterWesbos {
edges {
node {
created_at
full_text
user {
name
}
}
}
}
}
FAQs
Fetch data from Twitter API
We found that gatsby-source-twitter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.