Social Media Marketing

Automatically Create Social Media Images with the Template API

[ad_1]

There were more than 6 million homes sold in the US in 2021, and almost all of them were advertised on a real estate listing site. But in the past few years, real estate agents have focused more on adding social media sites to gain even wider exposure.

Real Estate Post on Instagram

With Ayrshare, you can save time by automatically creating beautiful photos and sending the photo to your social media accounts. Let’s take a look at how to automate your product or company images with the social media template API.

First we need to find the community template we want to use. We have created many well-designed templates that can be used to create images. A full list of social media templates can be found in our documentation, and don’t forget to check back for new ones.

We will use the real estate template.

Community Template for Sale Example
Architecture Template

The template components are various text fields, a background image of the building, a real estate agent image, and a rectangle color.

Postman Social Template API call
Postman API call to automatically generate an image via API

We made this call with Postman, which is a great tool for testing actual API calls.

Here is the full text of the request and response:

Request JSON:

{
    "templateId": "template-realestate1",
    "mods": [
        {
            "name": "image-property",
            "imageUrl": "
        },
        {
            "name": "image-profile",
            "imageUrl": "
        },
        {
            "name": "text-top",
            "text": "Samantha Williams
Williams Real Estate Properties" }, { "name": "text-bottom", "text": "1000 First Ave, Springwater, NY, 07807
(201) 345-6789" }, { "name": "rectangle", "backgroundColor": "#B8E4FF" } ] }

The response appears in JSON:

{
    "status": "success",
    "url": "
    "thumbnailUrl": "
    "width": 1200,
    "height": 1200,
    "imageType": "jpeg"
}

The response includes a link to the image on the Ayrshare server, so you can easily use the storage / posting API to now post this to your social media accounts.

Open the URL in the response to see if we have generated the image dynamically via the API. It displays the house, profile picture, and text we selected in the API call parameters.

Example of a Social Media Template
The image is generated automatically with the Ayrshare Social Template API

Business and Enterprise customers have the option to create their own customizable templates in addition to those offered by Ayrshare. Contact your Ayrshare representative to learn more.

It’s that easy to create your own images automatically using the API. And after creating images, you can edit social media posts on your favorite networks, such as Instagram, Facebook, and Twitter. The following example is in JavaScript – see our documentation for examples in Python, PHP, C#, and more.

const fetch = require("node-fetch");
const API_KEY = "API_KEY";

fetch(" {
      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: [" //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 they can be customized with your own images, text, and colors, to find the right style for your customers.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button