API Documentation

for the geeks!

X Clone provides a set of powerful APIs to interact with Twitter, manage personas, schedule tweets, and more. Below is a detailed guide to all available endpoints.


Authentication

Authenticate your API keys to enable X Clone functionalities.

  • Endpoint: /auth

  • Method: POST

  • Headers:

    • Content-Type: application/json

  • Request Body:

    jsonCopy code{
      "twitterApiKey": "string",
      "twitterApiSecret": "string",
      "twitterAccessToken": "string",
      "twitterAccessSecret": "string"
    }
  • Response:

    • 200 OK:

      jsonCopy code{
        "message": "Authentication successful",
        "status": "authorized"
      }
    • 400 Bad Request:

      jsonCopy code{
        "error": "Invalid credentials provided"
      }

Post a Tweet

Post a tweet directly from X Clone.

  • Endpoint: /post_tweet

  • Method: POST

  • Headers:

    • Content-Type: application/json

  • Request Body:

    jsonCopy code{
      "content": "Your tweet content here"
    }
  • Response:

    • 200 OK:

      jsonCopy code{
        "message": "Tweet posted successfully",
        "tweet_id": "1234567890"
      }
    • 400 Bad Request:

      jsonCopy code{
        "error": "Tweet content cannot be empty"
      }

Get Scheduled Tweets

Retrieve all scheduled tweets.

  • Endpoint: /scheduled_tweets

  • Method: GET

  • Response:

    • 200 OK:

      jsonCopy code{
        "scheduled_tweets": [
          {
            "id": "1",
            "content": "Good morning, Twitter!",
            "scheduled_time": "2025-01-15T08:00:00Z"
          },
          {
            "id": "2",
            "content": "Don't forget to hydrate!",
            "scheduled_time": "2025-01-15T12:00:00Z"
          }
        ]
      }

Schedule a Tweet

Schedule a tweet to be posted at a specific time.

  • Endpoint: /schedule_tweet

  • Method: POST

  • Headers:

    • Content-Type: application/json

  • Request Body:

    jsonCopy code{
      "content": "Your tweet content here",
      "scheduled_time": "2025-01-15T12:00:00Z"
    }
  • Response:

    • 200 OK:

      jsonCopy code{
        "message": "Tweet scheduled successfully",
        "schedule_id": "12345"
      }
    • 400 Bad Request:

      jsonCopy code{
        "error": "Invalid scheduled time format"
      }

Delete a Scheduled Tweet

Remove a tweet from the schedule.

  • Endpoint: /delete_scheduled_tweet/{id}

  • Method: DELETE

  • Path Parameter:

    • id: The ID of the scheduled tweet to delete.

  • Response:

    • 200 OK:

      jsonCopy code{
        "message": "Scheduled tweet deleted successfully"
      }
    • 404 Not Found:

      jsonCopy code{
        "error": "Scheduled tweet not found"
      }

Generate Text for Tweets

Use OpenAI to generate tweet content based on a prompt.

  • Endpoint: /generate_text

  • Method: POST

  • Headers:

    • Content-Type: application/json

  • Request Body:

    jsonCopy code{
      "prompt": "Write a funny tweet about cats"
    }
  • Response:

    • 200 OK:

      jsonCopy code{
        "generated_text": "Cats don't chase lasers—they chase their dreams. 🐾"
      }
    • 400 Bad Request:

      jsonCopy code{
        "error": "Prompt cannot be empty"
      }

Create a Persona

Define a new persona for X Clone.

  • Endpoint: /create_persona

  • Method: POST

  • Headers:

    • Content-Type: application/json

  • Request Body:

    jsonCopy code{
      "name": "Tech Guru",
      "description": "Shares insights on technology and innovation",
      "tone": "professional",
      "keywords": ["AI", "startups", "programming"]
    }
  • Response:

    • 200 OK:

      jsonCopy code{
        "message": "Persona created successfully",
        "persona_id": "67890"
      }

Get All Personas

Retrieve all existing personas.

  • Endpoint: /personas

  • Method: GET

  • Response:

    • 200 OK:

      jsonCopy code{
        "personas": [
          {
            "id": "1",
            "name": "Tech Guru",
            "description": "Shares insights on technology and innovation",
            "tone": "professional"
          },
          {
            "id": "2",
            "name": "Meme Lord",
            "description": "Posts the funniest memes on the internet",
            "tone": "humorous"
          }
        ]
      }

Delete a Persona

Remove a persona from X Clone.

  • Endpoint: /delete_persona/{id}

  • Method: DELETE

  • Path Parameter:

    • id: The ID of the persona to delete.

  • Response:

    • 200 OK:

      jsonCopy code{
        "message": "Persona deleted successfully"
      }
    • 404 Not Found:

      jsonCopy code{
        "error": "Persona not found"
      }

Last updated