Generate new social post and rewrite post using ChatGPT
Creating the text for social media post can be difficult: writing the copy, hashtag, correct length, and emojis. Or if you have an existing social post and need variations — the social networks do not like duplicate posts.
The subdomain used for these calls is api.ayrshare.com instead of the standard app.ayrshare.com.
Max Pack Required.
❗Click the › in the endpoint to view details.
POST Generate a Post Text
POSThttps://api.ayrshare.com/api/generate/post
Generate a new social post using ChatGPT. Token limits applicable.
Headers
Name
Type
Description
Authorization*
string
Format: Authorization: Bearer API_KEY. See Overview for more information.
Request Body
Name
Type
Description
text*
string
Description of what the post should be about. For example: "A shoe sale happening Monday with specials on red, blue, and yellow shoes".
hashtags
boolean
Default true. Add hashtags to the post.
emojis
boolean
Default false. Add emojis to the post.
twitter
boolean
Default false. Construct a post 280 or few characters.
{"status":"success", "post": "🎉🛍️ Introducing the stunning new shoes that's now on sale! You can choose from three different colors – red, blue, or purple – and trust us, they're all amazing! Don't miss out on this beauty and grab yours today! 🙌 #newshow #onSale #fashionable #colormebeautiful 🌈",
"usage":98,// Tokens used for this call"totalMonthlyUsage":733// Total tokens used for the month}
{"action":"request","status":"error","code":101, "message": "Missing or incorrect parameters. Please verify with the docs. https://docs.ayrshare.com/rest-api/endpoints"
}
Request Examples
curl \-H "Authorization: Bearer API_KEY" \-H 'Content-Type: application/json' \-d '{"text": "This beautiful new shoe is on sale now. It comes in red, blue, or purple. Check it out today."}' \-X POSThttps://api.ayrshare.com/api/generate/post
constAPI_KEY="API_KEY";fetch("https://api.ayrshare.com/api/generate/post", { method:"POST", headers: {"Content-Type":"application/json","Authorization":`Bearer ${API_KEY}` }, body:JSON.stringify({ post: "This beautiful new shoe is on sale now. It comes in red, blue, or purple. Check it out today.", // required
}), }).then((res) =>res.json()).then((json) =>console.log(json)).catch(console.error);
import requestspayload ={'post':'This beautiful new shoe is on sale now. It comes in red, blue, or purple. Check it out today.'}headers ={'Content-Type':'application/json','Authorization':'Bearer API_KEY'}r = requests.post('https://api.ayrshare.com/api/generate/post', json=payload, headers=headers)print(r.json())
<?php$curl =curl_init();$data =array ("post"=>"This beautiful new shoe is on sale now. It comes in red, blue, or purple. Check it out today.");curl_setopt_array($curl, array( CURLOPT_URL =>'https://api.ayrshare.com/api/generate/post', CURLOPT_RETURNTRANSFER =>true, CURLOPT_ENCODING =>'', CURLOPT_MAXREDIRS =>10, CURLOPT_TIMEOUT =>0, CURLOPT_FOLLOWLOCATION =>true, CURLOPT_HTTP_VERSION =>CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST =>'POST', CURLOPT_POSTFIELDS => http_build_query($data), CURLOPT_HTTPHEADER => array('Authorization: Bearer API_KEY','Accept-Encoding: gzip' ),));$response =curl_exec($curl);curl_close($curl);echo $response;
POST Rewrite a Post
POSThttps://api.ayrshare.com/api/generate/rewrite
Generate variations of a social media posts using ChatGPT. Token limits applicable.
Headers
Name
Type
Description
Authorization*
string
Format: Authorization: Bearer API_KEY. See Overview for more information.
Request Body
Name
Type
Description
post*
string
The post text to be rewritten.
emojis
boolean
Default false. Add emojis to the post.
hashtags
boolean
Default false. Add hashtags to the post.
twitter
boolean
Default false. Construct a post 280 or few characters.
rewrites
int
Default 5. Number of rewrites. Min: 1 and Max: 5.
String
{"status":"success", "post": "Kali melts the heart, even when the rest of the day is freezing. Happy International Polar Bear Day to the largest land carnivore and the biggest, furriest part of the Zoo’s bear community! \nOur resident polar bear Kali (pronounced “Cully”) is a wild-born bear that was born off of the northwest coast of Alaska. He was named by the people of the Native Village of Point Lay, who rescued him. \"Kali\" is the Inupiaq name for Point Lay. Eventually, the U.S. Fish and Wildlife",
"rewrites": [ "❄️🐻 Kali, the lovable polar bear, warms our hearts on this #InternationalPolarBearDay. Fun fact: he was named after Inupiaq village, Point Lay! #FurryZooCommunity 🐾",
"Happy #InternationalPolarBearDay to Kali, the largest land carnivore of the Zoo community! Even on freezing days, Kali steals our hearts with his adorable antics. 🐻❤️",
"Meet Kali, the wild-born polar bear with a heart-melting charm. 🐾❄️ Sending love on this #InternationalPolarBearDay to the Zoo's fluffiest resident. 🐻❤️",
"On #InternationalPolarBearDay, we celebrate Kali, the furry wonder from the largest land carnivore family of the Zoo. 🐾🐻 He was named after an Inupiaq village, Point Lay!🌟",
"Kali, the Zoo's beloved polar bear, steals our hearts with his playful spirit, as we celebrate #InternationalPolarBearDay. 🐻❤️ Born off the Alaskan coast, he's a true warrior! 💪🌟"
],"usage":98,// Tokens used for this call"totalMonthlyUsage":733// Total tokens used for the month}
{"action":"request","status":"error","code":101, "message": "Missing or incorrect parameters. Please verify with the docs. https://docs.ayrshare.com/rest-api/endpoints"
}
Request Examples
curl \-H "Authorization: Bearer API_KEY" \-H 'Content-Type: application/json' \-d '{"post": "Kali melts the heart, even when the rest of the day is freezing. Happy International Polar Bear Day to the largest land carnivore and the biggest, furriest part of the Zoo’s bear community! \nOur resident polar bear Kali (pronounced “Cully”) is a wild-born bear that was born off of the northwest coast of Alaska. He was named by the people of the Native Village of Point Lay, who rescued him. \"Kali\" is the Inupiaq name for Point Lay. Eventually, the U.S. Fish and Wildlife"}' \
-X POSThttps://api.ayrshare.com/api/generate/rewrite
constAPI_KEY="API_KEY";fetch("https://api.ayrshare.com/api/generate/rewrite", { method:"POST", headers: {"Content-Type":"application/json","Authorization":`Bearer ${API_KEY}` }, body:JSON.stringify({ post: "Kali melts the heart, even when the rest of the day is freezing. Happy International Polar Bear Day to the largest land carnivore and the biggest, furriest part of the Zoo’s bear community! \nOur resident polar bear Kali (pronounced “Cully”) is a wild-born bear that was born off of the northwest coast of Alaska. He was named by the people of the Native Village of Point Lay, who rescued him. \"Kali\" is the Inupiaq name for Point Lay. Eventually, the U.S. Fish and Wildlife", // required
}), }).then((res) =>res.json()).then((json) =>console.log(json)).catch(console.error);
import requestspayload = {'post': 'Kali melts the heart, even when the rest of the day is freezing. Happy International Polar Bear Day to the largest land carnivore and the biggest, furriest part of the Zoo’s bear community! \nOur resident polar bear Kali (pronounced “Cully”) is a wild-born bear that was born off of the northwest coast of Alaska. He was named by the people of the Native Village of Point Lay, who rescued him. \"Kali\" is the Inupiaq name for Point Lay. Eventually, the U.S. Fish and Wildlife'}
headers ={'Content-Type':'application/json','Authorization':'Bearer API_KEY'}r = requests.post('https://api.ayrshare.com/api/generate/rewrite', json=payload, headers=headers)print(r.json())
<?php$curl =curl_init();$data =array ( "post" => "Kali melts the heart, even when the rest of the day is freezing. Happy International Polar Bear Day to the largest land carnivore and the biggest, furriest part of the Zoo’s bear community! \nOur resident polar bear Kali (pronounced “Cully”) is a wild-born bear that was born off of the northwest coast of Alaska. He was named by the people of the Native Village of Point Lay, who rescued him. \"Kali\" is the Inupiaq name for Point Lay. Eventually, the U.S. Fish and Wildlife"
);curl_setopt_array($curl, array( CURLOPT_URL =>'https://api.ayrshare.com/api/generate/rewrite', CURLOPT_RETURNTRANSFER =>true, CURLOPT_ENCODING =>'', CURLOPT_MAXREDIRS =>10, CURLOPT_TIMEOUT =>0, CURLOPT_FOLLOWLOCATION =>true, CURLOPT_HTTP_VERSION =>CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST =>'POST', CURLOPT_POSTFIELDS => http_build_query($data), CURLOPT_HTTPHEADER => array('Authorization: Bearer API_KEY','Accept-Encoding: gzip' ),));$response =curl_exec($curl);curl_close($curl);echo $response;
Provide a transcription of a video file. This transcription can then be used in the /generate/post to create a social media summary of the video.
⮕ The video must have been previously upload to Ayrshare with /media. Videos not hosted by Ayrshare will be rejected.
⮕ Video max size 500GB and 10 minute duration.
Headers
Name
Type
Description
Authorization*
string
Format: Authorization: Bearer API_KEY. See Overview for more information.
Request Body
Name
Type
Description
videoUrl*
string
URL encoded video URL. The video must be hosted by Ayrshare.
{"status":"success", "transcript": "This is your last chance. After this, there is no turning back. You take the blue pill, the story ends you wake up in your bed and believe whatever you want to be you take the red pill. You stay in Wonderland. And I show you how deep the rabbit hole goes.",
"transcriptArray": ["","This is your last chance.","After this, there is no turning back.", "You take the blue pill, the story ends you wake up in your bed and believe whatever you want to be you take the red pill. You stay in Wonderland.",
"And I show you how deep the rabbit hole goes." ],"wordCount":52}
{"status":"success","translatedText":"Nos vamos a las carreras","originalText":"Off we go to the races","language":"es"}
{"action":"request","status":"error","code":101, "message": "Missing or incorrect parameters. Please verify with the docs. https://docs.ayrshare.com/rest-api/endpoints"
}
POST Generate alt text for an image
POSThttps://api.ayrshare.com/api/generate/altText
Create AI-generated alt text for your images. Choose the language to write the alt text and keywords to include in the alt text.
Headers
Name
Type
Description
Authorization*
string
Format: Authorization: Bearer API_KEY. See Overview for more information.
Request Body
Name
Type
Description
url*
string
Image URL of the image to create the alt text. Must start with https://. Supports JPEG, PNG, GIF, WEBP, and BMP.
keywords
array
String array of keywords or phrases to be considered when generating the alt text. Typically only one or two of the keywords from the array will be used in the alt text.
lang
string
Language to output the alt text. Use one of the available language codes.
{"status":"success","altText":"A ghostbusters vehicle driving through a field.","url":"https://img.ayrshare.com/012/gb.jpg"}
{"action":"upload","status":"error","code":115, "message": "An error occurred uploading your file, such as a timeout at the social network. Please try your post again with the /retryPost endpoint.",
}
For every API call made to ChatGPT endpoints, a certain number of "tokens" are used. These tokens are calculated based on the data you send and receive. Every month, your Max Pack and overall Ayrshare account are allocated a total of 300,000 tokens for Business plans, 100,000 for Premium Plus plans, and 50,000 for Premium plans. This allocation refreshes on the first day of each month. To see how many tokens a specific API call used, as well as your total usage for the month, please check the HTTP response.