Developer guide
How do I call a social video analysis API from a Python agent?
Call mamitsu from Python with requests, then wrap it as a tool your agent can call. Send a public post link and a prompt, with an optional JSON Schema, and get the answer as JSON.
One request
Call mamitsu with requests
mamitsu is one HTTP endpoint. In Python, a small function with requests (or httpx, with the same arguments) sends the post URL, your prompt and, when you want fixed fields, a JSON Schema.
mamitsu watches the video, listens to the audio and reads the caption, then answers on the same request. Read the answer from data; the response also carries the extraction_id and the source.
Create a key in the app and set it as MAMITSU_API_KEY where your agent runs.
import os
import requests
# Keep your key in the environment, never in code.
MAMITSU_API_KEY = os.environ["MAMITSU_API_KEY"]
def extract(url: str, prompt: str, schema: dict | None = None) -> dict:
payload = {"url": url, "prompt": prompt}
if schema is not None:
payload["schema"] = schema
response = requests.post(
"https://usemamitsu.com/api/v1/extract",
headers={"Authorization": f"Bearer {MAMITSU_API_KEY}"},
json=payload,
# mamitsu answers on the same request once it has watched the post.
timeout=300,
)
response.raise_for_status()
return response.json()A real example
A workout routine from a YouTube video
This call sends a five-minute ab workout with a schema for the routine: its name, the rounds, the rest between them and each exercise with its reps, hold time and form cues.
The response on the right is the one mamitsu returned: two rounds, 20 seconds of rest and four exercises in order, with the cues the coach says out loud.
ROUTINE_SCHEMA = {
"type": "object",
"properties": {
"workout_name": {
"type": "string",
},
"rounds": {
"type": [
"integer",
"null",
],
},
"rest_between_rounds_seconds": {
"type": [
"integer",
"null",
],
},
"exercises": {
"type": "array",
"items": {
"type": "object",
"properties": {
"order": {
"type": "integer",
},
"name": {
"type": "string",
},
"reps": {
"type": [
"integer",
"null",
],
},
"hold_seconds": {
"type": [
"integer",
"null",
],
},
"form_cues": {
"type": "array",
"items": {
"type": "string",
},
},
},
"required": [
"order",
"name",
"reps",
"hold_seconds",
"form_cues",
],
},
},
},
"required": [
"workout_name",
"rounds",
"rest_between_rounds_seconds",
"exercises",
],
}
routine = extract(
"https://www.youtube.com/watch?v=umhVkAIV46A",
"Turn this workout into a routine my app can show step by step. List every exercise in the order the creator does it, with the reps or hold time they give, how many rounds, the rest they mention, and the form cues they say out loud.",
ROUTINE_SCHEMA,
)
print(routine["data"]["workout_name"]){
"extraction_id": "ext_34f9cf92-312b-4bef-bd17-6ec17e1c5b9c",
"data": {
"workout_name": "Beginner Friendly Core Workout",
"rounds": 2,
"rest_between_rounds_seconds": 20,
"exercises": [
{
"order": 1,
"name": "Deadbugs",
"reps": 12,
"hold_seconds": null,
"form_cues": [
"make sure your back is pressed against the mat the entire time",
"it's all about control, not speed",
"raise your legs, raise your arms",
"opposite arm and leg extend",
"make sure that back stays against the floor"
]
},
{
"order": 2,
"name": "Bicycle Crunches",
"reps": 12,
"hold_seconds": null,
"form_cues": [
"opposite elbow touches opposite knee",
"do this slow and controlled",
"back pressed against the mat",
"legs up",
"slight pause when you get to the top"
]
},
{
"order": 3,
"name": "Plank Taps",
"reps": 12,
"hold_seconds": null,
"form_cues": [
"get up on your hands and toes",
"try to stack your shoulders over your hands",
"try to keep your hips as still as possible",
"make sure you're engaging your core"
]
},
{
"order": 4,
"name": "Hollow Hold",
"reps": null,
"hold_seconds": 20,
"form_cues": [
"back pressed into mat",
"legs up",
"arms up",
"if this feels too difficult, feel free to bend your legs"
]
}
]
},
"source": {
"provider": "youtube",
"url": "https://www.youtube.com/watch?v=umhVkAIV46A"
}
}Agent tool
Give your agent a tool that watches posts
Wrap the helper in a function with a clear name and docstring and register it with your agent. When a user shares a link, the agent calls the tool with the link and its own question, and gets back a few lines of JSON for the whole video.
For questions in a conversation, the prompt alone works well: mamitsu names the fields from the question. Pass a schema when the agent stores the result or hands it to other code.
def watch_social_post(url: str, question: str) -> dict:
"""Answer a question about a public Instagram, TikTok, YouTube or X post.
Use this whenever the user shares a post link and asks about it.
mamitsu watches the video, listens to the audio and reads the caption,
then returns the answer as JSON.
"""
return extract(url, question)["data"]
# Register watch_social_post as a tool in your agent framework. Most read the
# name, the type hints and the docstring to describe the tool to the model.MCP
Or connect an MCP client
When your agent runs in an MCP client such as Claude Code, Codex or Hermes, connect the mamitsu MCP server instead. Its extract tool takes the same inputs and returns the same JSON, and the client signs in with OAuth.
Related guides