Generate Twitter-like Images With Our Simple API

Create stunning, realistic tweet images programmatically using our simple REST API. Perfect for marketing, documentation, or creative projects.

Endpoint

POST https://tweetgen.my.id/api/generate-tweet

Parameters

To generate a tweet image, include these parameters in your API request

Parameter Type Required Description
username string Required The username of the tweet creator (e.g., @elonmusk)
content string Required The content of the tweet (max 280 characters)
avatar string (URL) Optional URL of the user's avatar image
timestamp string Optional Timestamp of the tweet (format: YYYY-MM-DD HH:mm:ss)
likes integer Optional Number of likes for the tweet
retweets integer Optional Number of retweets for the tweet
comments integer Optional Number of comments for the tweet

Code Examples

Click code to copy
const axios = require("axios");
const fs = require("fs");

const config = {
"name": "John Doe",
"username": "@johndoe",
"tweetText": "This is a generated tweet!",
"profile": "https://cdn.arifzyn.tech/f/886z70cc.jpg",
"image": "https://cdn.arifzyn.tech/f/886z70cc.jpg",
"theme": "dark",
"retweets": 100,
"quotes": 10,
"likes": 500,
"client": "Twitter for iPhone"
}

async function generateTweet() {
  try {
    const response = await axios.post(
      "https://tweetgen.my.id/api/generate-tweet",
      config,
      {
        headers: {
          "Content-Type": "application/json"
        },
        responseType: 'arraybuffer'
      }
    );

    fs.writeFileSync(
      "generated_tweet.png", 
      Buffer.from(response.data)
    );
    
    console.log("✨ Tweet image generated successfully!");
  } catch (error) {
    console.error("Error generating tweet:", error.message);
  }
}

generateTweet();

Response

A successful API call will return a response with the generated tweet image as follows:

{
 "status": "success",
 "message": "Tweet image generated successfully"
 "image_url": "https://api.example.com/tweets/12345.png",
}

In case of an error, the response will include a status message and error details:

{
 "status": "error",
 "message": "Invalid request parameters",
 "error_code": 400
}