You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm following this twitter api documentation to get detailed information for a tweet, but I can't seem to get the full tweet details (retweet count, hearts, geotags etc etc) with this API. I'm only getting this response for a tweet from the API:
I've put the proper query parameters (like expansions, tweet.fields), but nothing seems to be getting me a detailed report of the tweet. This is what my code looks like:
constneedle=require("needle");constYOUR_BEARER_TOKEN="MY-TOKEN-HERE";constTWEET_ID="1766576440005333244";// Replace with the actual tweet ID// Define the endpoint URLconstendpointUrl=`https://api.twitter.com/2/tweets/${TWEET_ID}`;// Set up the request headersconstheaders={Authorization: `Bearer ${YOUR_BEARER_TOKEN}`,"Content-Type": "application/json",};// Specify the fields you want to retrieveconsttweetFields="attachments,author_id,context_annotations,conversation_id,created_at,entities,geo,id,in_reply_to_user_id,lang,non_public_metrics,public_metrics,organic_metrics,promoted_metrics,possibly_sensitive,referenced_tweets,reply_settings,source,text,withheld";// Set up the request parameters including the desired fieldsconstparams={"tweet.fields":
"attachments,author_id,context_annotations,conversation_id,created_at,entities,geo,id,in_reply_to_user_id,lang,public_metrics,referenced_tweets,reply_settings,source,text,withheld",expansions: "author_id","user.fields":
"created_at,description,entities,id,location,name,pinned_tweet_id,profile_image_url,protected,public_metrics,url,username,verified,verified_type,withheld","media.fields":
"duration_ms,height,media_key,preview_image_url,type,url,width,public_metrics,alt_text,variants","place.fields":
"contained_within,country,country_code,full_name,geo,id,name,place_type","poll.fields": "duration_minutes,end_datetime,id,options,voting_status",};asyncfunctionhelloWorld(){// Make the GET requestconstresponse=awaitneedle("get",endpointUrl,params,{ headers });console.log(response.body.data);}helloWorld();
The text was updated successfully, but these errors were encountered:
I'm following this twitter api documentation to get detailed information for a tweet, but I can't seem to get the full tweet details (retweet count, hearts, geotags etc etc) with this API. I'm only getting this response for a tweet from the API:
I've put the proper query parameters (like
expansions
,tweet.fields
), but nothing seems to be getting me a detailed report of the tweet. This is what my code looks like:The text was updated successfully, but these errors were encountered: