Docs
Getting Started

Getting Started

Complete guide to getting started with the Twitter API, from choosing a platform to making your first request.

Overview

Welcome to the Twitter API! This guide will help you get started quickly, whether you're a beginner or coming from another API provider. We'll cover everything from choosing a platform to making your first successful API request.


Step 1: Choose a Platform

The API is available on multiple platforms, each with its own benefits. Choose the one that best fits your needs:

Platform Options

RapidAPI

  • Large API marketplace with extensive documentation
  • Multiple payment options (credit card, PayPal, invoicing)
  • Instant setup and activation
  • Comprehensive analytics dashboard
  • Best for: Teams needing invoicing and enterprise features

JoJoAPI

  • Smaller marketplace with all RapidAPI benefits
  • 10% cheaper than RapidAPI (lower platform fees)
  • Same features and reliability
  • Best for: Cost-conscious developers and startups

Direct Gateway

  • Direct access without marketplace fees
  • 20% discount compared to marketplace prices
  • 300 requests/second on Enterprise plan (vs 50 on marketplaces)
  • PayPal, credit card and cryptocurrency payments accepted
  • B2B invoicing available
  • Best for: High-volume users and businesses
  • Contact: Telegram @benagain or Email

Note: All platforms offer free plans or free trials, so you can start testing immediately!


Step 2: Get Your API Key

On RapidAPI or JoJoAPI

  1. Sign Up: Create an account on your chosen platform
  2. Subscribe: Choose a plan (start with free tier to test)
  3. Get Key: Find your API key in the dashboard
  4. Copy Endpoint: Use the provided endpoint URL

Direct Gateway

Get 20% discount by using Direct Gateway! Contact us to get started:

  1. Contact Us: Reach out via Telegram or email (see above)
  2. Choose Plan: Get free credits to test the API and the gateway URL
  3. Receive Credentials: Top up your credits by yourself by using your credit card, PayPal or cryptocurrency
  4. Start Using: Begin making requests immediately

Response Time: We typically respond within 3 hours, often much faster via Telegram.


Step 3: Make Your First Request

Quick Start Examples

cURL:

curl --request GET \
  --url 'https://<direct.gateway>/user/by/username/elonmusk' \
  --header 'X-API-KEY: YOUR_API_KEY'

JavaScript (fetch):

const response = await fetch('https://<direct.gateway>/user/by/username/elonmusk', {
  headers: {
    'X-API-KEY': 'YOUR_API_KEY'
  }
});
 
const user = await response.json();
console.log(user);

Python (requests):

import requests
 
url = "https://<direct.gateway>/user/by/username/elonmusk"
headers = {"X-API-KEY": "YOUR_API_KEY"}
 
response = requests.get(url, headers=headers)
user = response.json()
print(user)

Node.js (axios):

const axios = require('axios');
 
const response = await axios.get(
  'https://<direct.gateway>/user/by/username/elonmusk',
  {
    headers: {
      'X-API-KEY': 'YOUR_API_KEY'
    }
  }
);
 
console.log(response.data);

Testing Your Setup

Try this simple test to verify everything works:

# Test with a well-known user
curl --request GET \
  --url 'https://<direct.gateway>/user/by/username/elonmusk' \
  --header 'X-API-KEY: YOUR_API_KEY'

If you get user data back, you're all set! 🎉


Step 4: Explore the API

Now that you're set up, explore the different endpoints:

Core Endpoints

  • Tweets & Posts - Access tweets, replies, threads, and quotes

    • Get tweet by ID
    • Get tweet retweets
    • Access conversation threads
  • Users & Profiles - User profiles, follower and following lists

    • Get user by username or ID
    • Get user tweets and media
    • Access followers and following lists
  • Search - Advanced search with filters and operators

    • Search tweets by keywords
    • Advanced search with complex filters
    • Location-based search
  • Trends & Analytics - Trending topics, hashtags, and engagement metrics

    • Get trending topics
    • Hashtag analytics
    • Tweet and user analytics
  • Lists & Communities - Twitter Lists and Communities

    • Get list members and tweets
    • Community information
    • Member management
  • Jobs - Job listings and company information

    • Search jobs
    • Get job details
    • Company information

Helpful Guides


Common Getting Started Issues

Issue 1: "Unauthorized" or 401 Error

Symptoms:

{
  "error": {
    "code": 401,
    "message": "Unauthorized"
  }
}

Causes:

  • API key not included in request
  • API key is incorrect
  • API key format is wrong

Solutions:

  1. Check Header Name: Must be exactly X-API-KEY (case-sensitive)
  2. Verify Key: Copy API key again from dashboard
  3. Check Format: Ensure no extra spaces or characters
  4. Test Key: Try the key in a simple request first

Example Fix:

// ❌ Wrong
headers: { 'X-Api-Key': API_KEY }  // Wrong case
headers: { 'API-KEY': API_KEY }    // Wrong name
 
// ✅ Correct
headers: { 'X-API-KEY': API_KEY }   // Correct!

Issue 2: "Not Found" or 404 Error

Symptoms:

{
  "error": {
    "code": 404,
    "message": "Not found"
  }
}

Causes:

  • Resource doesn't exist
  • Incorrect ID format
  • Resource was deleted

Solutions:

  1. Verify ID Format: Tweet IDs and User IDs are numeric strings
  2. Check Resource Exists: Verify on Twitter directly
  3. Handle Gracefully: Implement error handling for missing resources

Example:

// ❌ Wrong: Invalid ID format
GET /tweet/abc123
 
// ✅ Correct: Valid numeric ID
GET /tweet/1668868113725550592

Issue 3: Rate Limit Errors

Symptoms:

{
  "error": {
    "code": 429,
    "message": "Rate limit exceeded"
  }
}

Causes:

  • Making too many requests too quickly
  • Exceeding plan's rate limits

Solutions:

  1. Check Your Plan: Verify your rate limits
  2. Implement Backoff: Add delays between requests
  3. Cache Responses: Cache data to reduce API calls
  4. Monitor Headers: Check rate limit headers in responses

Quick Fix:

// Add delay between requests
await new Promise(resolve => setTimeout(resolve, 200)); // 200ms delay

Issue 4: Gateway URL Issues

Symptoms:

  • Connection errors
  • "Host not found" errors
  • Timeout errors

Solutions:

  1. Verify URL: Check gateway URL is correct
  2. Check Platform: Ensure using correct endpoint for your platform
  3. Test Connection: Try simple request first
  4. Contact Support: If issues persist

Next Steps

1. Read the Documentation

  • Start with endpoint-specific guides
  • Review error handling best practices
  • Understand rate limits

2. Build a Simple Project

Try building a simple application:

  • User profile viewer
  • Tweet search tool
  • Trending topics tracker

3. Join the Community

  • Check platform forums for help
  • Contact support for issues
  • Share your projects

4. Optimize Your Usage

  • Implement caching
  • Use bulk endpoints
  • Monitor rate limits
  • Follow best practices

Quick Reference

Authentication Header

X-API-KEY: YOUR_API_KEY

Base URL Format

https://<direct.gateway>/

Common Endpoints

GET /tweet/{tweetId}
GET /user/by/username/{username}
GET /user/{userId}
GET /search/tweets?q={query}
GET /trends/topics?woeid={woeid}

Response Format

{
  "data": { ... },
  "meta": { ... }
}

Need Help?

Contact & Support

Direct Gateway Support: For Direct Gateway users, contact us directly:

Marketplace Support: For RapidAPI or JoJoAPI users, contact support through your platform's support channels.

  • Documentation: Browse our comprehensive guides

You're now ready to start using the API! Happy coding! 🚀