Skip to content
Mboum
Optimizing API Request Weight When Building High-Frequency Stock Dashboards

A dashboard asks for the same data again and again, so the cost of each request adds up fast. On Mboum every request has a weight, and the weight decides how much of your monthly allowance a refresh uses. This guide shows which endpoints weigh what, how to batch quotes, and how a small client keeps a dashboard inside its budget.

How requests are counted

The pricing FAQ says: "Each successful response (HTTP 200) counts against your allowance by the endpoint's weight. Failed requests don't count." Most endpoint entries in the docs show their weight. In our checks the responses carried no usage or quota header, so count weight in your own code. The rate limit is 10 requests per second, and going over it can return HTTP 429.

One catch: several failures come back as HTTP 200 with "success": false, such as too many tickers in one call. Because the rule is written around HTTP 200, assume those can count and stop them before you send.

Weights at a glance

WeightEndpoints
1Search, the single-symbol quote, history (v1 and v2), analyst ratings, news, movers, insider trades, dividends, IPO and stock-split calendars, v2 ticker summary, price targets, revenue and short interest, crypto profile, holders and quotes
2Multi-symbol quotes, stock modules, the stock screeners, options chains and scanners, the earnings calendar, technical indicators, v2 financials, institutional holdings, SEC filings and historical, crypto modules
5Crypto coin list

Check the docs page for any endpoint you depend on before you plan a budget.

Batch the quotes

/v1/markets/stock/quotes takes up to 200 comma-separated tickers in one call at weight 2. /v1/markets/stock/analyst-ratings takes up to 10 at weight 1. History, modules and most v2 endpoints take one symbol per request. Over the limit, the answer is HTTP 200 with "success": false and a message such as "Please limit tickers to 200".

What a batch does well is price. Take 25 symbols, a 6.5-hour session and 21 trading days a month. Here is the monthly cost of refreshing them:

Refresh everyOne quotes call (weight 2)25 single-symbol calls (weight 1 each)
60 seconds16,380204,750
5 minutes3,27640,950
15 minutes1,09213,650

For comparison, the monthly allowance is 10,000 on Investor, 50,000 on Business and 250,000 on Developer. The single-symbol quote also returns different, Nasdaq-style string fields, so it is not a drop-in replacement for a quotes row.

A client that counts and caches

The client below keeps a weight table, caches each response for a time you choose, splits large lists into chunks of 200, removes duplicates, spaces calls to stay under the rate limit, and stops when a budget is spent. Save it as mboum_client.py:

import time

import requests

API_KEY = "YOUR_MBOUM_API_KEY"
BASE = "https://api.mboum.com"
HEADERS = {"Authorization": f"Bearer {API_KEY}", "Accept": "application/json"}

# Weight of each endpoint you call. Read it from the docs page of the endpoint.
WEIGHTS = {
    "/v1/markets/stock/quotes": 2,
    "/v1/markets/stock/history": 1,
    "/v1/markets/stock/analyst-ratings": 1,
}
# Seconds to reuse a response, by how fast the data changes. Tune these.
TTL = {
    "/v1/markets/stock/quotes": 60,
    "/v1/markets/stock/history": 3600,
    "/v1/markets/stock/analyst-ratings": 3600,
}
MAX_QUOTES = 200  # more than this in one call returns success: false


class MboumClient:
    def __init__(self, budget):
        self.budget = budget  # most weight this process may spend
        self.used = 0
        self.cache = {}
        self.last_call = 0.0

    def get(self, path, **params):
        key = (path, tuple(sorted(params.items())))
        hit = self.cache.get(key)
        if hit and hit[0] > time.time():
            return hit[1]  # served from cache: costs nothing

        weight = WEIGHTS[path]
        if self.used + weight > self.budget:
            raise RuntimeError(f"Budget of {self.budget} would be exceeded")

        time.sleep(max(0, 0.11 - (time.time() - self.last_call)))  # stay under 10 requests/second
        self.last_call = time.time()
        r = requests.get(BASE + path, headers=HEADERS, params=params, timeout=30)
        r.raise_for_status()
        data = r.json()
        if data.get("success") is False:  # HTTP 200 can still be a failure
            raise RuntimeError(f"{path}: {data.get('message')}")

        self.used += weight  # counted by weight, per response
        self.cache[key] = (time.time() + TTL[path], data)
        return data

    def quotes(self, symbols):
        unique = list(dict.fromkeys(s.upper() for s in symbols))  # drop duplicates, keep order
        rows = {}
        for i in range(0, len(unique), MAX_QUOTES):
            chunk = unique[i:i + MAX_QUOTES]
            body = self.get("/v1/markets/stock/quotes", ticker=",".join(chunk))["body"]
            rows.update({q["symbol"]: q for q in body})
        missing = [s for s in unique if s not in rows]  # unknown symbols are dropped silently
        return rows, missing


if __name__ == "__main__":
    client = MboumClient(budget=100)
    watchlist = ["AAPL", "MSFT", "NVDA", "AAPL", "TSLA", "ZZZZNOPE"]

    rows, missing = client.quotes(watchlist)
    print(f"{len(rows)} rows, missing {missing}, weight used {client.used}")

    rows, missing = client.quotes(watchlist)  # same call again within 60 seconds
    print(f"second call, weight used {client.used}")

Run it and the demo asks for six symbols, one a duplicate and one that does not exist. It costs weight 2, returns four rows, and the second call is free because the cache still holds the answer.

Best practices

  • Compare the row count. An unknown symbol is dropped without an error, and duplicates come back twice. In our test, 200 symbols returned 198 rows, so the client reports what is missing.
  • Cache by how fast the data changes. Quotes can live for a minute. Daily history and analyst ratings can live for an hour or more.
  • Stop polling when the market is closed. Each quotes row has a marketState, such as POST, so you can pause refreshes without an extra request.
  • Do the cheap work yourself. If you already fetch daily history at weight 1, calculate an SMA locally rather than paying 2 for the indicator endpoint.

Next steps

Put the budget in a shared store such as Redis if several workers call the API, and log client.used so you see the trend before the month ends. You can get a free key at mboum.com/pages/api, and every endpoint is described in the API documentation.

The data is for information only. It is not investment advice.