Most modern websites load their data from a JSON API that runs in the background. If you find that API, you can call it directly instead of parsing HTML or using a headless browser. This guide shows how to find hidden API endpoints with browser DevTools and mitmproxy, check them with cURL, and turn them into a Python script.
Websites like Bing Image Search and Walmart render pages with JavaScript and deliver page content via JSON APIs. While it's possible to scrape dynamic web pages using browser automation, I prefer fetching data from the API endpoints directly. It usually (not always) works faster and is more reliable.
I was debugging the Bing Image Search to help implement our Bing Reverse Image Search API. Initially, I used mitmproxy because Ctrl+Shift+F in the browser dev tools, I couldn't find the request. Then I figured out how to filter network requests in the browser dev tools, examined the response, and made a draft data adapter.
How to find API endpoints of a website
Two ways I've used to reverse engineer a JSON API used on the Bing Image Search: mitmproxy and browser developer tools. I explain the devtools process because it's used more often.
Browser devtools
- Open the Network tab and click the "Fetch/XHR" filter so only API calls are listed. Reload the page or scroll if the list is empty.

Ctrl+F(Cmd+Fon Mac) in the Network tab of browser dev tools.

- Go to the
Previewtab of the JSON response.
4. Expand the JS object recursively (my Brave Browser doesn't search in the collapsed JSON 😕)

Ctrl+F(Cmd+Fon Mac) the target string

- Copy property path

- Navigate up and down in the JS object (with arrow keys) to learn its structure and create an adapter.
- Copy as cURL and transform response with
jqto check my assumption.
Copy as cURL
Right-click the request in the Network tab and choose Copy > Copy as cURL (bash). The command includes the URL, headers, and cookies your browser sent, so it usually works as is in a terminal.

Pipe the output into jq to confirm the fields you need are there. This example uses the API behind the infinite scroll page on quotes.toscrape.com, a practice site for scraping:
curl -s 'https://quotes.toscrape.com/api/quotes?page=1' \
| jq '{page, has_next, quotes: [.quotes[] | {text, author: .author.name}]}'If the trimmed command still returns the data, you have found an endpoint you can call from code. If it fails, add the copied headers back one at a time until it works. That tells you which header or cookie the API checks.
mitmproxy
https://www.bing.com/search?q=Serpapi&bcid=...&FORM=SBICAM, and the visual matches come back inside that HTML page instead of a separate JSON response. The method still applies to Bing and to any other site, because ~bs matches HTML responses too. Filter for a title you can see in your own results instead of "Freshsales". To follow along step by step, use the practice site example at the end of this section.Ctrl+Shift+F in the browser dev tools no longer searches across all responses.

I've proxied the browser network connections via mitmproxy. Then filtered response bodies with ~bs "TEXT_FROM_THE_HTML_ELEMENT_I_"LOOKING_FOR".
- Start
mitmproxywith view filter
$ mitmproxy --view-filter '~bs "Freshsales"'
- Start a Chromium-based browser with the target URL and the following flags and parameters
- Proxy requests via
mitmproxy:--proxy-server='http://127.0.0.1:8080'. - Use incognito mode (1) with a temporary user profile (2) ignoring insecure connections (3) and certificate errors (4):
--temp-profile -incognito --user-data-dir="mktemp -d" --no-first-run --ignore-certificate-errors --allow-insecure-localhost. (I ignore certificate errors in a temporary browser profile to not installmitmproxy's certificates system-wide.)
$ brave-browser 'https://www.bing.com/images/search?view=detailV2&insightstoken=bcid_RLKVsIV2BwkFXg*ccid_spWwhXYH&form=SBIHMP&iss=SBIUPLOADGET&sbisrc=ImgPicker&idpbck=1&sbifsz=927+x+524+%c2%b7+25.15+kB+%c2%b7+png&sbifnm=serpapi-serpbear.png&thw=927&thh=524&ptime=223&dlen=34344&expw=798&exph=451&selectedindex=0&id=-1051855017&ccid=spWwhXYH&vt=2&sim=11' --proxy-server='http://127.0.0.1:8080' --temp-profile -incognito --user-data-dir="`mktemp -d`" --no-first-run --ignore-certificate-errors --allow-insecure-localhost

mitmproxywill display the matched requests

Try it on a practice site
Hidden APIs change, as the Bing example shows, so here are the same steps on a site built for scraping practice. The quotes on quotes.toscrape.com/scroll are not in the page's HTML. The browser loads them from a JSON API after the page opens, so a body filter for an author's name only matches the API response.
- Start
mitmproxywith a filter for an author from the first page
$ mitmproxy --view-filter '~bs "Albert Einstein"'- Open the scroll page through the proxy with the same browser flags as above
$ brave-browser 'https://quotes.toscrape.com/scroll' --proxy-server='http://127.0.0.1:8080' --temp-profile -incognito --user-data-dir="`mktemp -d`" --no-first-run --ignore-certificate-errors --allow-insecure-localhostOn macOS, replace brave-browser with "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser". Any Chromium-based browser works, for example google-chrome or chromium on Linux.
mitmproxyshows one matching request,GET https://quotes.toscrape.com/api/quotes?page=1. That is the endpoint you will call from Python in the next section.
Replay the request in Python
Once you know the endpoint, you can call it from any language. The infinite scroll page at quotes.toscrape.com/scroll loads its quotes from /api/quotes?page=N. Each response has a quotes list, the current page, and a has_next flag that tells you when to stop.
{
"has_next": true,
"page": 1,
"quotes": [
{
"author": {"name": "Albert Einstein", "slug": "Albert-Einstein"},
"tags": ["change", "deep-thoughts", "thinking", "world"],
"text": "“The world as we have created it is a process of our thinking. ...”"
}
]
}This script calls the endpoint page by page, stops when has_next is false or after max_pages, and saves the results to a JSON file:
import json
import requests
BASE_URL = "https://quotes.toscrape.com/api/quotes"
HEADERS = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
"(KHTML, like Gecko) Chrome/131.0 Safari/537.36",
"Accept": "application/json",
}
max_pages = 5
quotes = []
page = 1
while page <= max_pages:
response = requests.get(BASE_URL, params={"page": page}, headers=HEADERS, timeout=30)
response.raise_for_status()
data = response.json()
for quote in data["quotes"]:
quotes.append(
{
"text": quote["text"],
"author": quote["author"]["name"],
"tags": quote["tags"],
}
)
print(f"Page {data['page']}: {len(data['quotes'])} quotes")
if not data["has_next"]:
break
page += 1
with open("quotes.json", "w", encoding="utf-8") as f:
json.dump(quotes, f, ensure_ascii=False, indent=2)
print(f"Saved {len(quotes)} quotes to quotes.json")Output:
Page 1: 10 quotes
Page 2: 10 quotes
Page 3: 10 quotes
Page 4: 10 quotes
Page 5: 10 quotes
Saved 50 quotes to quotes.jsonThe params dictionary maps to the query string you saw in DevTools, and HEADERS comes from the copied cURL command. For other sites, start with the full set of copied headers and remove the ones the API doesn't need.
Common problems with hidden APIs
The quotes API is open on purpose. Real sites often add a few extra checks.
The request needs cookies or a token
If the API returns 401 or 403 outside the browser, look at the Cookie and Authorization headers in the copied cURL command. Tokens often expire, so your script may need to load the HTML page first, read the token from it, and then call the API with a requests.Session() that keeps cookies between calls.
Some parameters are signed
Some sites add a hash or signature parameter that JavaScript computes for each request. Copy the parameter name, open global search with Ctrl+Shift+F (Cmd+Option+F on Mac), and search the loaded scripts for it. That shows you the code that builds the value.
You get blocked or rate limited
Send requests at a human pace, reuse the browser's headers, and back off when you get 429 responses. Our guide on reducing the chance of being blocked while web scraping covers more options.
The site uses GraphQL
Many sites send every request to a single /graphql endpoint with a POST body. Filter Fetch/XHR by graphql, open the Payload tab, and copy the query and variables. Your script sends the same JSON body.
The data is inside the HTML
Search the page source for a value you can see on the page. If you only need the page content, the SerpApi Extract API fetches any public page and returns its text as Markdown, along with its links and metadata. For more techniques, see 13 ways to scrape any data from any website.
When the hidden API belongs to a search engine
Search engines are the hardest case. Their internal endpoints change often, use signed parameters, and block automated traffic quickly. This is the work we do at SerpApi, and the research above went into the Bing Reverse Image API. For another example, read how we reverse engineered Google Finance charts.
Instead of maintaining your own adapter, you can call the Bing Reverse Image API and get the visual matches, pages with the same image, and related searches as structured JSON. Our tutorial on how to scrape Bing reverse image search results walks through it in Python, Ruby, JavaScript, and cURL. See the Bing Reverse Image API docs for all parameters and the playground.
FAQ
Is it legal to reverse engineer an API?
It depends on where you are, the site's terms of service, and the data you collect. Calling an endpoint that your browser already calls on a public page is different from bypassing a login or collecting personal data. Read the terms, keep your request rate low, and ask a lawyer before you build a commercial product on someone else's private API.
How do I find the API of a website?
Open DevTools, go to the Network tab, filter by Fetch/XHR, and reload the page. Click each request and check the Preview tab for the data you see on the page. If nothing shows up, try mitmproxy with a response body filter as shown above.
Is an API endpoint the same as a URL?
An endpoint is a URL plus the HTTP method and parameters that return a specific resource. https://quotes.toscrape.com/api/quotes?page=2 with a GET request is one endpoint call. The same URL with POST could do something else.
Conclusion
mitmproxy can be used to find the HTTP request with the needed data in addition browser dev tools. At some point, I'll explore tcpdump and wireshark to reverse engineer websites for web scraping and share the findings with you.
If you have anything to share, any questions, suggestions, or something that isn't working correctly, feel free to reach out to us at contact@serpapi.com.