Node.js / Twitter API v2 / Users a user ID is following
Back to Collection Items
var os = require('os');
if (os.platform() == 'win32') {
if (os.arch() == 'ia32') {
var chilkat = require('@chilkat/ck-node21-win-ia32');
} else {
var chilkat = require('@chilkat/ck-node21-win64');
}
} else if (os.platform() == 'linux') {
if (os.arch() == 'arm') {
var chilkat = require('@chilkat/ck-node21-arm');
} else if (os.arch() == 'x86') {
var chilkat = require('@chilkat/ck-node21-linux32');
} else {
var chilkat = require('@chilkat/ck-node21-linux64');
}
} else if (os.platform() == 'darwin') {
if (os.arch() == 'arm64') {
var chilkat = require('@chilkat/ck-node21-mac-m1');
} else {
var chilkat = require('@chilkat/ck-node21-macosx');
}
}
function chilkatExample() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
var http = new chilkat.Http();
var success;
// Adds the "Authorization: Bearer <access_token>" header.
http.AuthToken = "<access_token>";
var sbResponseBody = new chilkat.StringBuilder();
success = http.QuickGetSb("https://api.twitter.com/2/users/:id/following",sbResponseBody);
if (success == false) {
console.log(http.LastErrorText);
return;
}
console.log("Response status code = " + http.LastStatus);
console.log(sbResponseBody.GetAsString());
}
chilkatExample();
Curl Command
curl -X GET
-H "Authorization: Bearer <access_token>"
https://api.twitter.com/2/users/:id/following
Postman Collection Item JSON
{
"name": "Users a user ID is following",
"request": {
"method": "GET",
"header": [
],
"url": {
"raw": "https://api.twitter.com/2/users/:id/following",
"protocol": "https",
"host": [
"api",
"twitter",
"com"
],
"path": [
"2",
"users",
":id",
"following"
],
"query": [
{
"key": "user.fields",
"value": "",
"description": "Comma-separated fields for the user object.\nAllowed values:\ncreated_at,description,entities,id,location,name,pinned_tweet_id,profile_image_url,protected,public_metrics,url,username,verified,witheld\nDefault values:\nid,name,username",
"disabled": true
},
{
"key": "expansions",
"value": "",
"description": "Expansions enable requests to expand an ID into a full object in the includes response object.\nAllowed value:\npinned_tweet_id\nDefault value: none",
"disabled": true
},
{
"key": "tweet.fields",
"value": "",
"description": "Comma-separated list of fields for the Tweet object. Expansion required.\nAllowed values:\nattachments,author_id,context_annotations,conversation_id,created_at,entities,geo,id,in_reply_to_user_id,lang,non_public_metrics,organic_metrics,possibly_sensitive,promoted_metrics,public_metrics,referenced_tweets,source,text,withheld\nDefault values:\nid,text\nOAuth1.0a User Context authorization required if any of the following fields are included in the request:\nnon_public_metrics,organic_metrics,promoted_metrics",
"disabled": true
},
{
"key": "max_results",
"value": "",
"description": "The maximum number of results to be returned by a request.\nAllowed values: 10 through 1000.\nDefault value: 100",
"disabled": true
},
{
"key": "pagination_token",
"value": "",
"description": "This parameter is used to get the next 'page' of results. The value used with the parameter is pulled directly from the response provided by the API, and should not be modified.",
"disabled": true
}
],
"variable": [
{
"key": "id",
"value": "",
"type": "string",
"description": "Required. Enter a single user ID."
}
]
},
"description": "Returns a list of users the specified user ID is following.\n\nFor full details, see the [API reference](https://developer.twitter.com/en/docs/twitter-api/users/follows/api-reference/get-users-id-following) for this endpoint.\n\n[Sign up](https://t.co/signup) for the Twitter API"
},
"response": [
]
}