DEV Community

Cover image for Stop Feeding Your AI Agents Fluff: Introducing API to MOJ Converter
toykam
toykam

Posted on

Stop Feeding Your AI Agents Fluff: Introducing API to MOJ Converter

🤖 The "Unstructured" Problem

We are living in the golden age of AI Agents. We want them to book flights, manage infrastructure, and interact with third-party services. But there's a major bottleneck: Context.

AI Agents (powered by LLMs) are incredibly smart, but they struggle with the same thing humans do—information overload.

When you point an agent to a standard API documentation page (like Swagger UI or Postman Documenter), you're asking it to:

  1. Parse HTML layout.
  2. Ignore navigation bars, footers, and CSS.
  3. Understand which endpoints are relevant.
  4. Piece together scattered parameters and schemas.

It's inefficient. It burns tokens. And often, the agent gets lost.

💡 Agents Crave Structure

Unlike a blog post or an e-commerce site where the content is the value, API documentation is about data structure. Agents don't need the marketing fluff about "how easy our API is." They need:

  • Path: /v1/users
  • Method: POST
  • Params: { "name": "string" }

They understand structured data (JSON) natively. So why are we feeding them HTML?

🛠 Solving It: API Doc to JSON

I realized that if I wanted my agents to be reliable, I needed a translation layer. Something that sits between the human-readable documentation and the machine brain.

So, I teamed up with @antigravity to build API to MOJ Converter.

What is MOJ?

Machine-Optimized JSON. It's a stripped-down, token-efficient format that prioritizes structural predictability over human readability.

Key Features

  • ⚡️ Universal Ingestion: It supports Swagger/OpenAPI (v2, v3) and public Postman Collections.
  • 🔍 Deep Scraping: It doesn't just read the page; it finds the underlying configuration. Hidden swagger-config.json? Nested Postman API calls? We handle that complexity for you.
  • 🛡 Type Safety: It simplifies complex nested schemas into flat, predictable type definitions that LLMs can easily generate.
  • 🎨 Developer Experience: Built with a sleek dark-mode UI, using Monaco Editor (the engine behind VS Code) for real-time verification.

🏗 The Stack

We built this using Next.js 14, TailwindCSS, and TypeScript.

One of the coolest technical challenges was the Ingestion Engine. Swagger UIs are often dynamically rendered single-page apps (SPAs). We had to build a robust scraper that:

  1. Fetches the HTML.
  2. Parses identifying scripts (like swagger-initializer.js).
  3. Recursively resolves configuration URLs until it finds the actual Open API Spec.

For Postman, we reverse-engineered the structure of their public documentation pages to fetch the raw collection JSON directly from their gateway API, bypassing the heavy client-side rendering.

🚀 What's Next?

Right now, it's a web tool. But the vision is bigger.

We are currently building an API for the Converter. Imagine sending a POST request with a documentation URL and getting back the clean MOJ JSON instantly. You could plug this directly into your LangChain or AutoGPT pipelines to let your agents "learn" APIs on the fly.

👋 Try It Out

The tool is live and free to use:
👉 https://apidoctojson.vercel.app

Give it a spin with your favorite documentation link and let me know if it helps your agents work smarter, not harder!

Top comments (0)