Using AI agents to reverse engineer web APIs
I’ve been experimenting with local large language models (LLMs) and AI coding agents to handle increasingly complex automation tasks. In this post, I walk through a real-world example: using my locally run Zed Agent connected to Ollama to research the Bluesky AT Protocol, build a reusable skill, and automate following people based on specific criteria — all without writing any code myself.
Task definition
I want to find 10 people on the Bluesky platform that fit certain criteria:
- text profile description relevant to software development, open source, Linux, JavaScript, AI, technologies, etc;
- fewer than 500 followers;
- number of followings similar to or greater than the number of followers;
- more than five posts;
- last activity not older than six months ago.
Then, I want to subscribe to them.
Preparation
To do that, I involved my local LLM and AI agent setup. I use Zed Editor with its Zed Agent that is connected to Ollama with several local LLM models. I wrote about it in my previous post.
First, I gave the agent access to Chrome via chrome-devtools-mcp. I also tried @playwright/mcp with a browser extension — both work well.
My context window length is 128k, which isn’t very large. I noticed that these MCP tools provide snapshot features that return enormous amounts of data and flood the context quickly. To address this, I added instructions like:
Avoid using browser snapshots because they return too much data and overwhelm the context. Instead, filter their output or use code evaluation and DOM queries. Delegate the task of fetching, browser interactions, and filtering data to sub-agents who will return summarized results. Launch sub-agents sequentially with tasks up to 64k context length.
Using sub-agents is the best way to overcome the limitation of context length without compacting the previous context. This rule can be added to the AGENTS.md file to apply to each AI agent run.
I know Bluesky uses the open AT Protocol, which could power this automation. But I wanted the AI agent to try figuring out how to accomplish the task without my direct guidance or reading documentation.
So, I split this task into three steps:
- Figure out how to use the Bluesky API and what exact APIs we need for this job.
- Create a skill that the AI agent can use to find the requested information.
- Navigate through the Bluesky web app and follow the found people.
Well, that looks doable now. Let’s go!
Reverse engineering
This is the most interesting part because the AI agent should figure out the API itself. Let’s ask the AI agent to do the first step with that prompt:
Using the Chrome DevTools MCP, navigate to https://bsky.app and figure out how to find people and information about them via the API. Try doing this through UI interactions and analyze the browser’s network requests. What you must figure out:
- How to find people using a specific query or tags such as “developer”, “open source”, “javascript” or “linux”.
- How to paginate search results.
- How to get a text description of each user profile.
- How to find the number of followers and followings, the number of posts, and the last activity date.
Writing a skill
To effectively reuse the results, I created a new skill that explains exactly how to accomplish each part of the task.
I used this prompt in the next session:
Summarize the results and then create a skill for AI agents that explains how to use this API with a fetch tool or browser MCP. Write it to the “.agents/skills/bluesky-search/SKILL.md” file and add the correct header so AI agents can use the skill.
Now we have the skill. Let’s double-check it to make sure it works properly:
Use the “bluesky-search” skill and the “fetch” tool to double-check each API that it describes. At the end, a checklist and result are displayed for each item.
Preparing the script
Now I was ready to move on. Since this task is meant to be repeatable, I asked the AI agent to create a script instead of doing everything step by step:
Use the “bluesky-search” skill to create a JavaScript script that finds people on the Bluesky platform at the bsky.app domain in a Chrome browser using the Chrome DevTools MCP with the current user’s credentials. The script must apply the following input parameters:
- The number of people to find (the “numberOfPeople” parameter).
- Have a text profile description relevant to a specific search string (the “query” parameter).
- Have fewer than N followers (the “maxFollowers” parameter).
- Have more followings than followers multiplied by N (the “followingFactor” parameter).
- Post more than N times (the “minNumberOfPosts” parameter).
- Last activity within the last N months (the “maxLastActivity” parameter).
The script must return the following information about a user: DID, handle, display name, description, followers, following, number of posts, and last activity.
The agent could retrieve all this information using only the fetch tool — but that would be slow. Using a script significantly improves both speed and reproducibility.
Doing the job
With the script ready, I commanded the AI agent to start the search:
Using the script and a Chrome DevTools MCP run it directly in a browser with the current user’s credentials. Use the following input parameters:
- numberOfPeople=10;
- query=developer;
- maxFollowers=500;
- followingFactor=2;
- minNumberOfPosts=1;
- maxLastActivity=6.
Write the outcomes to RESULTS.md.
After a manual review of the results, I gave one final command — to follow all the matching profiles:
Use the list of profiles from RESULTS.md and the Chrome DevTools MCP to navigate to each profile. Then, click the “Follow” button on the page. Skip people you are already following.
Conclusion
It worked. I completed the entire task — research, skill creation, scripting, and execution — without writing a single line of code myself. This demonstrates that local LLMs and open-source AI agents are capable of handling surprisingly sophisticated automation workflows when guided effectively.
Honestly, I spent almost all day on that experiment, and it didn’t work the first time. It also didn’t work very quickly. But it worked in the end. It wasn’t very effective, but good enough. The first research step especially can save a lot of time compared to the manual method.
Comments