Binapi – Secure REST API for Automated Content & Image Creation

Hi Grav Community,

I’m excited to share a new plugin I’ve developed: binapi – a secure, configurable REST API for Grav CMS that makes it easy to automate content and image creation.

What is binapi?

binapi lets you create articles and upload images to your Grav site through authenticated API endpoints. It’s perfect for integrating with automation tools like n8n, Zapier, or your own scripts. You can control permissions, require authentication (via Grav Login or a Bearer token), and configure which folders are used—all from the Grav Admin Panel.

Key Features

  • Create articles via REST API
  • Upload images via REST API
  • Dual authentication: Grav session or Bearer token
  • Configurable permissions: Enable/disable folder, article, and image creation
  • Designed for automation: Works great with n8n, Zapier, and more

Example Use Cases

  • Connect n8n or Zapier to auto-post content from other sources
  • Build your own mobile or desktop publishing tools
  • Automate image uploads for media-heavy sites

Get Started

Feedback & Contributions

I’d love your feedback, suggestions, and contributions!
If you have questions or run into issues, feel free to open an issue on GitHub or reply here.

Thanks, and happy automating!
—Johnny

Nice one, Thanks for sharing.

Docs on Github are pretty good. What stops me trying this is that you don’t provide much detail on use cases. What can you build with this and how does that benefit users or editors? Can you describe what you’ve built on this as example(s)? Which problem were you trying to overcome when you decided to build this plugin?

Hi there!

Here’s how I use binapi in my own project:

  • I have an n8n workflow that leverages AI nodes to research trending topics, generate articles, and create image generation prompts.
  • The workflow formats the AI-generated article for Grav, downloads the AI-generated image, converts it to base64, and then pushes both the article and image to my Grav site using binapi.
  • This results in perfectly structured articles being automatically published to my Grav site—no manual intervention required.

Some practical use cases for binapi include:

  • Automated content curation: Pipe in multiple RSS feeds, have an AI node analyze trending topics, generate fresh articles and images, and publish them automatically to Grav.
  • Personal news aggregator: Like me, you can have your workflow collect news articles, filter out ads and paywalls, rewrite the content, and publish it to a private Grav site for distraction-free reading.
  • Bulk publishing: Use arrays in n8n to generate and publish as many articles as you want, on any schedule.
  • Integration with other platforms: Connect Zapier, Make, or custom scripts to push content from Google Docs, Notion, other sources directly into Grav.
  • Editorial automation: Automatically generate drafts for editors to review or set up scheduled publishing pipelines.
  • Media management: Automate image and asset uploads for galleries, portfolios, or news sites.
2 Likes

Here is one I am playing with this weekend. My wife has hundreds of recipes on notecards from her grandmother. I scanned all of the notecards and will create a workflow to push the recipe card images through AI. The AI node pulls the recipes off of the note card images, formats it, generates a cute sketch image of the meal and pushes the recipes and images to a grav site. Now she has a perfectly formatted website with all of her recipes that is easily sortable and searchable.

I will create a front end with input fields so she can paste future recipes and publish them to her recipe site. Also a search function if she finds a recipe she likes, she can click it and have the workflow/grav format it and publish to her site.

2 Likes

Hello @Johnny, very interesting, thanks for sharing your plugin.

I am not a programmer, so I wonder if you can advise on how to take the content of a newly created web page in Grav CMS and then publish it to Instagram (text, images), Facebook, and other social media platforms in the most automatic way.

Thank you in advance for any information.
Best regards
joejac

binapi can do the opposite and pull from social and post to grav. I would use an automation platform like N8N or zapier and send a webhook to start the publish. The automation to the social sites will require signing up for developer accounts and setting up api keys, etc.

1 Like

One way to improve this would be to enable the creation of flex objects

For example the recipes you scanned could easily be a flexible object in a plugin.

From what I can tell a flex object is a template and custom object/fields you can change on the fly. Essentially creating a database on a flat file platform. The flat file nature of grav is why I like it for these projects and makes it easy to accomplish this type of structure and changes but from outside the platform.

Binapi is responsible for the file transfer, it doesn’t really care what type of file it is. The “blueprint” is controlled by my automation platform. Example I use an AI node to generate the content and define the structure of my content in the prompt. If I wanted to add or change an object/variable on a bulk scale I could just adjust my prompt or create a new automation to update all of the existing articles.

Here is a prompt for the recipe project that takes a step further and formats for SEO and mass readability. I just pasted a random recipe but ideally would pass a variable or data from a scrape.

I pasted the final item.md after it is processed and formatted in the workflow.

Prompt:

Recipe:

Crispy Roasted Sweet Potatoes
PREP TIME
15 mins
COOK TIME
45 mins
TOTAL TIME
60 mins
SERVINGS
4 servings
Ingredients
• 1 tablespoon cornstarch
• 1 1/2 teaspoons kosher salt
• 1/2 teaspoon smoked paprika
• 3 1/2 tablespoons olive oil, divided
• 2 large sweet potatoes (about 14 ounces each), peeled and cut into 3/4-inch pieces
Method
1 Preheat the oven to 450°F.
.
Preheat the pan:
Place a light-colored baking sheet on the center rack of the preheated oven and let heat for 5 minutes.
2.
Coat the potatoes:
Meanwhile, in a large bowl, whisk together the cornstarch, salt, paprika, and 2 1/2 tablespoons of the oil. Add the sweet potatoes
and toss to coat fully.
3.
Arrange the potatoes on the hot pan:
Carefully remove the baking sheet from the oven. Working quickly, drizzle the pan with the remaining 1 tablespoon of oil and tilt
the baking sheet to coat evenly. Pour the sweet potato mixture onto the preheated baking sheet and spread it into an even layer.
4.
Roast:
Roast until golden brown and crispy, turning with a spatula every 10 to 15 minutes, 30 to 40 minutes total. Remove from the oven
and let cool on the baking sheet for 5 minutes, then serve immediately.
For maximum crispness, these potatoes are best eaten right away. They start to soften the longer they sit after roasting. You can
refrigerate leftovers in an airtight container for up to 2 days and reheat in an air fryer at 350°F to get some of the crispiness back.
Love the recipe? Leave us stars and a comment below!
5.
FILED UNDER:
DINNERS MOST RECENT SIDE DISHES POTATOES
Nutrition Facts (per serving)
277
CALORIES
10g
FAT
43g
CARBS
4g
PROTEIN

Instructions:

Rewrite the provided recipe using the following:

Humanize the content: Use a natural, conversational tone. Vary sentence structure, include relevant anecdotes, and avoid repetitive phrasing.

SEO:

Perform thorough keyword research. Identify a primary keyword and 2–3 secondary keywords relevant to the article’s topic and audience.

Naturally integrate the primary keyword in the title (H1), first paragraph, and at least one H2.

Use secondary keywords in subheadings and body text, but avoid keyword stuffing.
    - Write a strong, click-enticing meta description with secondary keywords.
    - Use concise, descriptive, and engaging headings (H2/H3) with keyword variations.
    - Add internal links using descriptive anchor text where relevant.
- Structure:
    - Follow the provided outline and metadata template.
    - Use bullet points and numbered lists where appropriate for clarity and featured snippet optimization.
    - Limit paragraphs to 2–4 sentences for readability.
    - Bold key names and figures for emphasis.
    - Include impactful, properly formatted quotes (real or attributed to reputable sources).
    - Avoid generic AI phrases and ensure the article reads as if written by a seasoned journalist.
- Recency \& Relevance:
    - Only use facts, quotes, and data from sources published in the last 30 days unless essential historical context is required for clarity.
    - For each referenced source, include the publication date in the citation section.
    - Do not include outdated or unrelated historical events unless they directly explain or impact the current news event.
    - Focus the article on the specific news event or topic from the provided URL and avoid generalizations or summaries of past events.
- Image Prompts for Leonardo.ai:
    - For the same article, generate:
        - A detailed prompt for a visually striking header image that captures the article’s main theme, using the Leonardo.ai prompt structure (subject, style, composition, background, lighting, mood). Suggest an SEO-friendly filename for this image based on the primary keyword.
        - One or two supporting image prompts, each with a unique, SEO-friendly filename relevant to key article points or sections.
    - Output all image prompts and filenames in the JSON structure below.

Article: {{ $json.url }}

1. Article Metadata Template:

---
title: "[Concise, <50 chars] Primary Keyword Phrase"
description: "[1-sentence summary with secondary keywords]"
author: "Johnny Larson"
date: "YYYY-MM-DD"
taxonomy:
    tags: [3-5 keywords]
    category: [1-2 broad topics]
og_title: "[Social-Media-Optimized Title]"
og_image: "[header_image_filename]"
---

2. Article Structure
Header (H1):

Lead with a breaking news hook or provocative question using the primary keyword.

Intro Paragraph:

Who/What/When/Where/Why (context and significance).

Thesis (core conflict or takeaway).

Section 1 (H2): Key Developments

3–5 critical facts (convert to paragraphs).

Embed quotes and data.

Section 2 (H2): Deeper Analysis

Expert commentary (real or synthesized).

Historical parallels or data trends.

Section 3 (H2): Stakeholder Reactions

Supportive and opposing POVs.

Public sentiment (social media trends/polls).

Section 4 (H2): What’s Next

Timeline of expected events.

Potential scenarios.

Closing (H3):

Forward-looking statement and call-to-action.

Citation Section linking back to referenced sources

*Note: Do not list each section (eg, Deeper Analysis). This is for your reference, use your own section descriptions.

3. Style Guidelines
✅ Use bold for key names/figures
✅ Short paragraphs (2–5 sentences)
✅ Bullet/numbered lists for clarity
✅ Insert 1–2 images (see prompts below)
✅ Minimum of 1500 words
❌ No nested bullets, fake quotes, or generic filler
❌ Do not make up or reference fake articles or links

4. Leonardo.ai Image Prompts
Output in this JSON format:

json
{
  "header_image_prompt": "A dynamic action shot of [subject], [artistic style], [composition], [background], [lighting], [mood].",
  "header_image_filename": "[primary-keyword-header].jpg",
  "supporting_images": [
    {
      "prompt": "A [description of supporting visual], [style], [composition], [background], [lighting], [mood].",
      "filename": "[seo-supporting-keyword-1].jpg"
    },
    {
      "prompt": "A [description of second supporting visual], [style], [composition], [background], [lighting], [mood].",
      "filename": "[seo-supporting-keyword-2].jpg"
    }
  ]
}
Each prompt should be pencil sketch/art style. Avoid depictions of children or graphic suffering.

Filenames must be unique, concise, and SEO-optimized for the article’s topic.

Key Restrictions:


❌ No children
❌ No graphic violence or suffering
✅ Use pencil sketch/art styles like in a courtroom

5. SEO Optimization
Primary keyword in H1, intro, and at least one H2

Secondary keywords in subheadings and body

Internal links with descriptive anchor text

Strong, keyword-rich meta title and description

Alt text for images (use filenames and descriptions)

Do not output any explanations or extra text. Only return the formatted article and the JSON image prompt block as specified.

**Output Format Rules:**
- Wrap the image prompt JSON in `###IMAGE_PROMPTS###` delimiters.
- Place the article Markdown after `###ARTICLE_CONTENT###`.
- Validate JSON syntax before outputting.
- No other text outside these blocks.

**Example Output:**
###IMAGE_PROMPTS###
{
  "header_image_prompt": "...",
  "header_image_filename": "seo-name.jpg",
  "supporting_images": [
    {"prompt": "...", "filename": "..."}
  ]
}
###IMAGE_PROMPTS###

###ARTICLE_CONTENT###
---
title: "Your Article Title"
---

Article body...

item.md sent through binapi:

---
title: "Crispy Roasted Sweet Potatoes: The Ultimate Side Dish"
show_title: false
description: "Learn how to make perfectly crispy roasted sweet potatoes with this easy, flavorful recipe—ideal for weeknight dinners or holiday feasts."
author: "Johnny Larson"
date: "2025-05-31"
taxonomy:
  tags: ["sweet potatoes", "roasted vegetables", "side dishes", "healthy recipes", "easy dinners"]
  category: ["Recipes", "Vegetarian"]
og_title: "Crispy Roasted Sweet Potatoes: A Foolproof Recipe for Perfect Texture"
og_image: "crispy-roasted-sweet-potatoes.jpg"
---

# Crispy Roasted Sweet Potatoes: The Ultimate Side Dish  

Ever pulled a tray of roasted sweet potatoes from the oven, only to find them soggy instead of crispy? You’re not alone. Achieving that golden, crunchy exterior while keeping the inside tender is a culinary balancing act—but this recipe nails it. With a clever cornstarch trick and a preheated pan, these **crispy roasted sweet potatoes** will steal the show at any meal.  

## Why This Recipe Works  

Sweet potatoes are a nutritional powerhouse, packed with fiber and vitamin A, but their natural sugars can make them prone to steaming rather than crisping. Here’s the secret:  

- **Cornstarch coating**: Absorbs moisture for maximum crunch.  
- **Preheated baking sheet**: Jumpstarts caramelization.  
- **Smoked paprika**: Adds depth without overpowering.  

“The key is letting the potatoes sit in a single layer—no crowding!” says chef Marcus Wareing (*The Guardian*, 2023).  

## Step-by-Step Instructions  

### 1. Prep Like a Pro  
Peel and cut **2 large sweet potatoes** into even ¾-inch cubes. Uniform size ensures even cooking. Toss them in a mixture of **1 tbsp cornstarch**, **1½ tsp kosher salt**, **½ tsp smoked paprika**, and **2½ tbsp olive oil** until fully coated.  

### 2. The Hot Pan Trick  
While the oven preheats to **450°F**, place a light-colored baking sheet inside for 5 minutes. A hot pan = instant sizzle. Drizzle the remaining **1 tbsp oil** onto the sheet, then spread the potatoes in a single layer.  

### 3. Roast to Perfection  
Roast for **30–40 minutes**, flipping every 10–15 minutes, until the edges are caramelized. Let them rest for 5 minutes—this crisps them further.  

## Serving & Storage Tips  
- **Best served immediately**: Crispiness fades fast.  
- **Reheat in an air fryer**: 5 minutes at **350°F** revives leftovers.  
- **Pairing ideas**: Try with [garlicky yogurt sauce](internal-link) or as a topping for grain bowls.  

## The Verdict  
These **crispy roasted sweet potatoes** are a game-changer—easy enough for weeknights but impressive for guests. For more veggie-centric recipes, explore our [guide to roasting vegetables](internal-link).  

*Citations:*  
- *The Guardian*, "How to Roast Vegetables Perfectly" (November 2023)  
- USDA National Nutrient Database (2023)

Now take this concept further. I am big into home automation and have my own voice control like Alexa through Home Assistant. I am able to stand in the kitchen, ask my home assistant voice to find a popular recipe on “home made pizza” and send it to my phone. Home assistant starts the workflow in n8n and then send me a link to my generated recipe on grav ready to be viewed. I can require certain taste requirements, example I don’t like raw tomatoes so the system can adjust the recipe before it publishes to grav. This avoids advertisements, popups, tracking and keeps my entire system and workflow in house.