All guides

Developer guide

How do I call a social video analysis API from a JavaScript app?

Call mamitsu with fetch from Node 18 or any server runtime. Send a public Instagram, TikTok, YouTube or X link with a prompt and an optional JSON Schema, and read the answer as JSON.

One request

Send the post and your question with fetch

mamitsu is one HTTP endpoint, so the fetch built into Node 18 and later is all your JavaScript app needs. Send the post URL and a prompt that says what you want from it. Add a JSON Schema when your code expects fixed fields.

mamitsu watches the video, listens to the audio and reads the caption, then answers on the same request. The answer is in data, next to the extraction_id and the source it read.

Create a key in the app and keep it in MAMITSU_API_KEY on your server.

mamitsu.js
// Node 18+ or any server runtime with fetch.
// Keep MAMITSU_API_KEY on the server, in an environment variable.
const MAMITSU_API_KEY = process.env.MAMITSU_API_KEY;

export async function extract(url, prompt, schema) {
  const response = await fetch('https://usemamitsu.com/api/v1/extract', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${MAMITSU_API_KEY}`,
      'Content-Type': 'application/json',
    },
    // schema is optional: JSON.stringify leaves it out when undefined.
    body: JSON.stringify({ url, prompt, schema }),
    // mamitsu answers on the same request once it has watched the post.
    signal: AbortSignal.timeout(300_000),
  });
  const body = await response.json();
  if (!response.ok) throw new Error(body.error.code);
  return body;
}

A real example

A recipe from an Instagram reel, in your own shape

This call sends a miso udon reel with a schema for the dish, the total time, each ingredient with its amount and the steps in order.

The response on the right is the one mamitsu returned. The reel gives amounts for the egg and the spinach, so those come back as text, and the other amounts are null, ready for your interface to skip.

Call it
const recipe = await extract(
  "https://www.instagram.com/p/DN4qQLfgSR1/",
  "Get the recipe from this post: the dish, how long it takes, every ingredient with its amount when it is given, and the steps in order.",
  {
    "type": "object",
    "properties": {
      "dish": {
        "type": "string"
      },
      "total_minutes": {
        "type": [
          "integer",
          "null"
        ]
      },
      "ingredients": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string"
            },
            "amount": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "name",
            "amount"
          ],
          "additionalProperties": false
        }
      },
      "steps": {
        "type": "array",
        "items": {
          "type": "string"
        }
      }
    },
    "required": [
      "dish",
      "total_minutes",
      "ingredients",
      "steps"
    ],
    "additionalProperties": false
  },
);
Response
{
  "extraction_id": "ext_c2a7bbdc-cea3-417c-ba4c-3257bb12d2b5",
  "data": {
    "dish": "15-Minute One-Pot Creamy Miso Udon",
    "total_minutes": 15,
    "ingredients": [
      {
        "name": "miso",
        "amount": null
      },
      {
        "name": "peanut butter",
        "amount": null
      },
      {
        "name": "udon noodles",
        "amount": null
      },
      {
        "name": "egg",
        "amount": "1"
      },
      {
        "name": "spinach",
        "amount": "a handful"
      },
      {
        "name": "green onions",
        "amount": null
      },
      {
        "name": "chili oil",
        "amount": null
      },
      {
        "name": "sesame seeds",
        "amount": null
      }
    ],
    "steps": [
      "Whisk miso and peanut butter together in a pot.",
      "Add udon noodles to the pot.",
      "Poach an egg in the broth.",
      "Add a handful of spinach to the pot.",
      "Transfer the noodles and spinach to a bowl.",
      "Pour the broth over the noodles.",
      "Top with the poached egg, green onions, sesame seeds, and chili oil."
    ]
  },
  "source": {
    "provider": "instagram",
    "url": "https://www.instagram.com/p/DN4qQLfgSR1/"
  }
}

Use the result

Read the fields your schema asked for

With a schema, data always has the fields you defined, so your code can read them straight away. Save the extraction_id with the result to find the call again in your usage history.

Without a schema, mamitsu names the fields from your prompt. That suits a first look at what a post holds; the JSON Schema guide shows the same post both ways.

Use the recipe
const { dish, total_minutes, ingredients, steps } = recipe.data;

console.log(`${dish}, ready in ${total_minutes} minutes`);
for (const { name, amount } of ingredients) {
  console.log(amount ? `- ${amount} ${name}` : `- ${name}`);
}
steps.forEach((step, i) => console.log(`${i + 1}. ${step}`));

From an AI client

Give your agent the same tool

The mamitsu MCP server has an extract tool with the same inputs and the same JSON. Connect your AI client once with OAuth and ask it about a post in the conversation.

Connect an MCP client · Set up your agent

How do I call a social video analysis API from a JavaScript app? · mamitsu