Auto Create Real Estate Social Media Images Via a Template API
There were over 6 million homes sold in the US in 2021, and just about all of them were advertised on a real estate listing site. But in the last few years, real estate agents have increasingly focused on adding social media destinations for their listings to get the widest exposure.
With Ayrshare, you can save time by automatically creating great images and post the image to your social media accounts. Let’s take a look at how to auto generate images for your brand or company via a social media template API.
First we need to find a social template that we want to use. We have created numerous professionally designed templates that can be used to generate images. The full list of social media templates can be found in our docs, and don’t forget to check back for new ones.
We will use the template for a real estate property.
The components of the template are the various text fields, the background image of the property, the image of the real estate broker, and the color of the rectangle.
We made this call via Postman, which is a great tool for testing real API calls.
Here is the full text of the request and the response:
JSON Request:
{
"templateId": "template-realestate1",
"mods": [
{
"name": "image-property",
"imageUrl": "https://unsplash.com/photos/4ojhpgKpS68/download?ixid=MnwxMjA3fDB8MXxzZWFyY2h8Mnx8aG91c2V8ZW58MHwyfHx8MTY2NTU5MDc4Mw&force=true&w=640"
},
{
"name": "image-profile",
"imageUrl": "https://unsplash.com/photos/dNNfMegXUi4/download?ixid=MnwxMjA3fDB8MXxhbGx8fHx8fHx8fHwxNjY1NTkwNzY4&force=true&w=640"
},
{
"name": "text-top",
"text": "Samantha Williams<br>Williams Real Estate Properties"
},
{
"name": "text-bottom",
"text": "1000 First Ave, Springwater, NY, 07807<br>(201) 345-6789"
},
{
"name": "rectangle",
"backgroundColor": "#B8E4FF"
}
]
}
JSON Response:
{
"status": "success",
"url": "https://media.ayrshare.com/3b9f27d69457abce2100b36e8e07a58006b1bbee/8911a8721d.jpeg",
"thumbnailUrl": "https://media.ayrshare.com/3b9f27d69457abce2100b36e8e07a58006b1bbee/8911a8721d-thumb.jpeg",
"width": 1200,
"height": 1200,
"imageType": "jpeg"
}
The response includes a link to the image on the Ayrshare server, so you can easily use the /post API endpoint to now send this to your social media accounts.
Open the URL in the response to see that we have generated an image dynamically via the API. It shows the house, profile photo, and text that we have selected in the API call parameters.
Business and Enterprise clients have the option to create their own customizable templates in addition to the ones that Ayrshare offers. Contact your Ayrshare representative to learn more.
It’s that easy to create your own images automatically via an API. And after you create the images, you can schedule social media posts to your networks of choice, such as Instagram, Facebook, and Twitter. The following example is in JavaScript – see our docs for examples in Python, PHP, C#, and more.
const fetch = require("node-fetch");
const API_KEY = "API_KEY";
fetch("https://app.ayrshare.com/api/post", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
post: "Today is a great day!", // required
platforms: ["twitter", "facebook", "fbg", "instagram", "linkedin"], // required
mediaUrls: ["https://img.ayrshare.com/012/gb.jpg"], //optional
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
There are many other Ayrshare social media templates to choose from, and are customizable with your own graphics, text, and colors, so you can find the right style for your customers.