Twitter API
twitter · Social
Twitter API API
Authentication
Sample Requests
Returns the 20 most recent direct messages sent to the authenticating user. Includes detailed information about the sender and recipient user. You can request up to 200 direct messages per call, up to a maximum of 800 incoming DMs. Important: This method requires an access token with RWD (read, wri
Hover any highlighted part to learn what it does
curl -X GET "https://api.apis.guru/v2/specs/twitter.com/legacy/1.1/direct_messages.json?page=1&count=10&max_id=example&since_id=example&skip_status=example&include_entities=example"
import requests
params = {
"page": "1",
"count": "10",
"max_id": "example",
"since_id": "example",
"skip_status": "example",
"include_entities": "example"
}
response = requests.get(
"https://api.apis.guru/v2/specs/twitter.com/legacy/1.1/direct_messages.json",
params=params,
)
print(response.json())const url = new URL('https://api.apis.guru/v2/specs/twitter.com/legacy/1.1/direct_messages.json');
url.searchParams.set('page', '1');
url.searchParams.set('count', '10');
url.searchParams.set('max_id', 'example');
url.searchParams.set('since_id', 'example');
url.searchParams.set('skip_status', 'example');
url.searchParams.set('include_entities', 'example');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.apis.guru/v2/specs/twitter.com/legacy/1.1/direct_messages.json")
q := baseURL.Query()
q.Set("page", "1")
q.Set("count", "10")
q.Set("max_id", "example")
q.Set("since_id", "example")
q.Set("skip_status", "example")
q.Set("include_entities", "example")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.apis.guru/v2/specs/twitter.com/legacy/1.1/direct_messages.json")
uri.query = URI.encode_www_form({
"page" => "1",
"count" => "10",
"max_id" => "example",
"since_id" => "example",
"skip_status" => "example",
"include_entities" => "example"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.apis.guru/v2/specs/twitter.com/legacy/1.1/direct_messages.json?" . http_build_query([
"page" => "1",
"count" => "10",
"max_id" => "example",
"since_id" => "example",
"skip_status" => "example",
"include_entities" => "example"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Returns settings (including current trend, geo and sleep time information) for the authenticating user.
Hover any highlighted part to learn what it does
curl -X GET "https://api.apis.guru/v2/specs/twitter.com/legacy/1.1/account/settings.json?lang=en&time_zone=example&end_sleep_time=example&start_sleep_time=example&sleep_time_enabled=example&trend_location_woeid=example"
import requests
params = {
"lang": "en",
"time_zone": "example",
"end_sleep_time": "example",
"start_sleep_time": "example",
"sleep_time_enabled": "example",
"trend_location_woeid": "example"
}
response = requests.get(
"https://api.apis.guru/v2/specs/twitter.com/legacy/1.1/account/settings.json",
params=params,
)
print(response.json())const url = new URL('https://api.apis.guru/v2/specs/twitter.com/legacy/1.1/account/settings.json');
url.searchParams.set('lang', 'en');
url.searchParams.set('time_zone', 'example');
url.searchParams.set('end_sleep_time', 'example');
url.searchParams.set('start_sleep_time', 'example');
url.searchParams.set('sleep_time_enabled', 'example');
url.searchParams.set('trend_location_woeid', 'example');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.apis.guru/v2/specs/twitter.com/legacy/1.1/account/settings.json")
q := baseURL.Query()
q.Set("lang", "en")
q.Set("time_zone", "example")
q.Set("end_sleep_time", "example")
q.Set("start_sleep_time", "example")
q.Set("sleep_time_enabled", "example")
q.Set("trend_location_woeid", "example")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.apis.guru/v2/specs/twitter.com/legacy/1.1/account/settings.json")
uri.query = URI.encode_www_form({
"lang" => "en",
"time_zone" => "example",
"end_sleep_time" => "example",
"start_sleep_time" => "example",
"sleep_time_enabled" => "example",
"trend_location_woeid" => "example"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.apis.guru/v2/specs/twitter.com/legacy/1.1/account/settings.json?" . http_build_query([
"lang" => "en",
"time_zone" => "example",
"end_sleep_time" => "example",
"start_sleep_time" => "example",
"sleep_time_enabled" => "example",
"trend_location_woeid" => "example"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Returns the current rate limits for methods belonging to the specified resource families. Each 1.1 API resource belongs to a "resource family" which is indicated in its method documentation. You can typically determine a method's resource family from the first component of the path after the resour
Hover any highlighted part to learn what it does
curl -X GET "https://api.apis.guru/v2/specs/twitter.com/legacy/1.1/application/rate_limit_status.json?resources=example"
import requests
params = {
"resources": "example"
}
response = requests.get(
"https://api.apis.guru/v2/specs/twitter.com/legacy/1.1/application/rate_limit_status.json",
params=params,
)
print(response.json())const url = new URL('https://api.apis.guru/v2/specs/twitter.com/legacy/1.1/application/rate_limit_status.json');
url.searchParams.set('resources', 'example');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.apis.guru/v2/specs/twitter.com/legacy/1.1/application/rate_limit_status.json")
q := baseURL.Query()
q.Set("resources", "example")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.apis.guru/v2/specs/twitter.com/legacy/1.1/application/rate_limit_status.json")
uri.query = URI.encode_www_form({
"resources" => "example"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.apis.guru/v2/specs/twitter.com/legacy/1.1/application/rate_limit_status.json?" . http_build_query([
"resources" => "example"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- See official documentation for authentication and setup.
What can you build with Twitter API?
Twitter API is a Social API. Developers commonly use social APIs for:
- adding social login (Sign in with Google/Twitter)
- fetching user-generated content for analysis
- scheduling and publishing social posts
- tracking mentions and engagement metrics
- building community dashboards
No authentication required. This API is open — no signup or key needed. Ideal for quick prototypes and public-facing features. Twitter API is free to use, making it a low-risk choice to experiment with.
New to APIs? Read our beginner's guide