Twitter
Options for posting via the API to Twitter

Twitter API Endpoint

Overview

JSON for a basic post with a link and image to Twitter:
1
{
2
"post": "The best Tweet ever #best https://www.twitter.com",
3
"mediaUrls": ["https://img.ayrshare.com/012/gb.jpg"],
4
"platforms": ["twitter"]
5
}
Copied!
Twitter will automatically preview the link in the Tweet unless there is an image or video included. In the above example the image will show. Removing the image will cause the link preview to show.

Upload Long Videos

Business or Enterprise Plan required.
Twitter requires videos have a maximum video length of 2 minutes and 20 seconds. However, if you have a have been approved by Twitter to upload longer videos, such as in the Amplify Partner Program, you can post videos up to 10 minutes in length.
In addition to Twitter approving your account for long videos, your Aryshare account must be enabled for long Twitter videos. Please contact us to enable this feature.
After your Ayrshare account is enabled for long videos and Twitter has approved your access, use the longVideo twitterOptions parameter when posting:
1
{
2
"twitterOptions": {
3
"longVideo": true
4
}
5
}
Copied!

Post Twitter Thread (TweetStorm)

A Twitter Thread or TweetStorm can be posted via the API. A thread is a post broken up into a set of reply threads and link in Twitter with a line.
  • thread: true to automatically break apart the post text into threads.
  • threadNumber: true to automatically add numbers at the end of threads in the format of 1/n. For example the 2nd of 5 threads will have appended: 2/5
  • mediaUrls: [array of urls] to add each media object, an image or video, to a thread in order. Only one media object will be added to a thread in order.
1
{
2
"twitterOptions": {
3
"thread": true, // required for TweetStorm
4
"threadNumber": true, // optional to add numbers to each thread
5
"mediaUrls": ["https://site.com/image1.png", "https://site.com/image2.png", ...] // optional one media object is added to a thread in order
6
}
7
}
Copied!

Skip Images and Multiple Media URLs

Skip an image for the thread by using null in the array. For example:
["https://site.com/image1.png", null, "https://site.com/image2.png"]
This will place image1 on the first Tweet, no image on the second Tweet, and image2 on the third Tweet.
Multiple images can be added to a Tweet in a Thread by adding an object {} with the media URLs in the mediaUrls array. Any unique object keys can be used. For example:
1
{
2
"twitterOptions": {
3
"thread": true,
4
"threadNumber": true,
5
"mediaUrls": [
6
"https://site.com/image1.png",
7
{"1": "https://site.com/image2.png", "2": "https://site.com/image3.png"},
8
"https://site.com/image4.png",
9
...]
10
}
11
}
Copied!
In this example, the first Tweet will contain image1, the second Tweet image2 and image3, and the third Tweet image4.

Thread Output

Ayrshare automatically breaks up the post text into appropriate length tweet (> 280 characters). Add paragraphs to the post text to indicate a unique thread should be created. For example:
1
{
2
"post": `This is the first thread.
3
4
This is the second thread.
5
6
And this is the final thread.`
7
}
Copied!

Delete Twitter Thread

To delete a Tweet Storm, call the /post delete endpoint with the top level post ID returned in the response. All threads will be deleted.

Alternative Text for Images

Add alternative text, also known as alt text, to a Tweet's image. Alt text is an accessibility feature used for additional user info and screen readers.
Use the altText in the twitterOptions object.
1
"twitterOptions": {
2
"altText": ["This is my best pic", "๐Ÿ˜ƒ here is the next one"] // Array of Alt Texts
3
}
Copied!
Each alt text must correspond to an image in the mediaUrls array. The alt text will be applies to each image in order.
Notes:
  • Alt text can not be applied to videos. If a video is included in the mediaUrls with altText, the video will not be posted.
  • Alt text must be 1,000 characters or less.
Last modified 26d ago