MT HTTP API Doc
The HTTP API is a simple, URL-based way to get data out of Medved Trader and to make a few changes to it. You send a plain GET request to Medved Trader on your own machine, and it answers with plain text. That makes it easy to use from a spreadsheet, a batch file, curl, or a few lines of script.
It is backward compatible with QuoteTracker's HTTP interface, which is why its format is a little old-fashioned. It covers portfolios, last quotes, stored history, time & sales, option chains and Linked Symbols. It does not stream and it does not trade. For streaming data, account monitoring and trading, use the WebSocket API.
All times are US Eastern, both the ones you send and the ones you get back (see Dates and times).
Please contact us at support@medvedtrader.com if you're having any problems with the API.
Enabling the HTTP API
The HTTP API is off by default. To turn it on:
- Go to Settings → App → API and find the HTTP API section.
- Check Enable HTTP API. Leave the Port at the default,
16239, unless another program on your machine already uses it. - Click Apply. Changes on this page ask for your Medved Trader account password (or your PIN, if you log in with a social login).
The HTTP API, like all of Medved Trader's APIs, requires a Premium subscription. A trial subscription includes it.
Medved Trader must be running for the API to answer. Requests are served from the data Medved Trader already has, using the data sources you have set up in it.
Local network access
By default the server listens on localhost / 127.0.0.1 only, so only programs on the same PC can reach it. Checking Allow HTTP connections from local/private network also makes it listen on the PC's private network addresses (10.x.x.x, 172.16–31.x.x, 192.168.x.x).
Request format
Every request is a GET to the path /Req, with the command and its parameters as the query string:
http://127.0.0.1:port/Req?Command(Param1,Param2,...)- Command names are not case-sensitive:
GetLastQuote,getlastquoteandGETLASTQUOTEare the same. - Parameters are separated by commas. Don't put spaces after the commas.
- A command with no parameters still takes its parentheses, for example
EnumPorts(). - Any path other than
/Reqis rejected with HTTP 400.
curl "http://127.0.0.1:16239/Req?GetLastQuote(AAPL,MSFT)"Responses and errors
Every response is plain text (text/plain). On success the HTTP status is 200, the first line is OK, and the data follows on the next lines. Most data lines are comma-separated values. Each command below shows its own layout.
Failures come back with an HTTP error status and a one-line message, so check the status code as well as the text:
| Status | Body | Meaning |
|---|---|---|
| 400 | Error: ... | A missing or invalid parameter, or a request that isn't /Req?.... |
| 404 | Error: Command "..."! | Unknown command. |
| 404 | Error: ... or NO | Nothing to return, for example no open Portfolio window for CURRENT, no linked symbol, or no option chain. |
| 500 | error message | Medved Trader hit an error while processing the request. |
Two cases are reported with status 200: a portfolio ID that doesn't exist (the second line is *NOID*), and a symbol Medved Trader has no data for (Error: no quotes from GetHistory and GetTimeSales; GetLastQuote just leaves that symbol out).
Dates, times and special IDs
Dates and times
- All times, in both requests and responses, are US Eastern time. This is different from Medved Trader's other APIs (the WebSocket API and the MCP server), which use UTC throughout. Convert if you use both.
- Dates are
MM/DD/YYYY, and times areHH:MM:SSin 24-hour format. - In responses, the date and the time are separate comma-separated fields.
Special portfolio and symbol IDs
| ID | Meaning | Accepted by |
|---|---|---|
| CURRENT | The portfolio shown in the oldest Portfolio window that is still open. If no Portfolio window is open, there is no CURRENT portfolio. | EnumPortSymbols, GetLastQuote, AddStocksToPort, AddDetailedStocksToPort, RemoveStocksFromPort |
| ACTIVE | Every symbol in every portfolio that is open in a Portfolio window, without duplicates, cash rows or separators. | EnumSymbols, GetLastQuote |
| * | Every symbol Medved Trader has stored data for. | GetLastQuote |
| NEW:name | Creates a new portfolio called name. The response gives the new portfolio's ID. | AddStocksToPort, AddDetailedStocksToPort |
EnumPorts
Lists all portfolios and watchlists, one per line, as ID and name. No parameters.
http://127.0.0.1:16239/Req?EnumPorts()OK
WTCH1,Watchlist
TECH,Tech Stocks
K3X9QD,Swing tradesEnumPortSymbols(PortID)
Returns the symbols in a portfolio, in the order they appear, as one comma-separated line.
| Name | Req | Content |
|---|---|---|
| PortID | Y | A portfolio ID from EnumPorts, or CURRENT. |
http://127.0.0.1:16239/Req?EnumPortSymbols(TECH)OK
AAPL,MSFT,NVDA,GOOGLAn unknown ID returns *NOID* on the second line.
AddStocksToPort(PortID,Symbol,Symbol,...)
Adds symbols to the end of a portfolio, or creates a new portfolio with them.
| Name | Req | Content |
|---|---|---|
| PortID | Y | A portfolio ID, CURRENT, or NEW:name to create a portfolio. |
| Symbol | Y | One or more symbols to add. |
http://127.0.0.1:16239/Req?AddStocksToPort(CURRENT,MSFT,INTC)OK
portfolio updatedhttp://127.0.0.1:16239/Req?AddStocksToPort(NEW:Earnings%20Week,NFLX,TSLA)
OK
K3X9QD portfolio createdAddDetailedStocksToPort(PortID,Symbol,Shares,Price,Commission,...)
Adds symbols to the end of a portfolio together with a position: number of shares, base (paid) price and commission. Repeat the four values for each symbol.
| Name | Req | Content |
|---|---|---|
| PortID | Y | A portfolio ID, CURRENT, or NEW:name to create a portfolio. |
| Symbol | Y | The symbol to add. |
| Shares | N | Number of shares. Leave it empty to skip it. |
| Price | N | Base price paid per share. |
| Commission | N | Commission paid. |
The values are read in groups of four, so keep every group complete, using empty values where needed: MSFT,100,,.
http://127.0.0.1:16239/Req?AddDetailedStocksToPort(CURRENT,MSFT,100,410.5,1.00,INTC,200,21.25,1.00)OK
portfolio updatedRemoveStocksFromPort(PortID,Symbol,Symbol,...)
Removes symbols from a portfolio.
| Name | Req | Content |
|---|---|---|
| PortID | Y | A portfolio ID or CURRENT. |
| Symbol | Y | One or more symbols to remove. |
http://127.0.0.1:16239/Req?RemoveStocksFromPort(CURRENT,MSFT,INTC)OK
portfolio updatedEnumSymbols([ACTIVE])
Returns every symbol Medved Trader has stored data for, as one comma-separated line. With ACTIVE, it returns only the symbols in portfolios that are open in Portfolio windows.
http://127.0.0.1:16239/Req?EnumSymbols(ACTIVE)OK
AAPL,MSFT,NVDA,GOOGL,NFLXGetLastQuote(Symbol,Symbol,...)
Returns the latest quote Medved Trader has for each symbol, one line per symbol. Symbols Medved Trader has no data for are left out.
| Name | Req | Content |
|---|---|---|
| Symbol | Y | One or more symbols, or one of CURRENT, ACTIVE or * (see special IDs). |
| # | Field | Content |
|---|---|---|
| 1 | Symbol | |
| 2–3 | Date, Time | Time of the last update, US Eastern. |
| 4 | Last | |
| 5 | Bid | |
| 6 | Ask | |
| 7 | Change | Change from the previous close. |
| 8 | Tick | Always -. Kept for QuoteTracker compatibility. |
| 9 | Volume | Day volume. |
| 10 | High | Day high. |
| 11 | Low | Day low. |
| 12 | BidSize | |
| 13 | AskSize | |
| 14 | LastVolume | Size of the last trade. |
| 15 | AvgTrade | Average trade size. |
| 16 | NumTrades | Number of trades today. |
| 17 | Open | |
| 18 | 52w Low | |
| 19 | 52w High |
http://127.0.0.1:16239/Req?GetLastQuote(AAPL,NFLX)OK
AAPL,11/08/2017,14:08:44,175.67,175.66,175.67,0.86,-,15821675,175.79,174.33,300,200,60,279,56700,174.66,104.08,175.25
NFLX,11/08/2017,14:08:39,195.19,195.15,195.24,-0.70,-,2972433,197.09,194.74,200,300,100,222,13330,196,110.68,204.38GetTimeSales(Symbol,FromTime,ToTime)
Returns the individual trades Medved Trader has stored for a symbol between two times, oldest first. It only returns tick data Medved Trader has already collected or backfilled. It does not request new data.
| Name | Req | Content |
|---|---|---|
| Symbol | Y | The symbol. |
| FromTime | Y | HH:MM:SS (today), MM/DD/YYYY (from the start of that day), MM/DD/YYYY HH:MM:SS, or 0 for the earliest stored tick. |
| ToTime | Y | HH:MM:SS (today), MM/DD/YYYY (through the end of that day), MM/DD/YYYY HH:MM:SS, or 0 for the latest. |
All of these are US Eastern, and "today" is today in New York. Write the space in a date-and-time value as %20 in the URL. If both are bare times and ToTime is earlier than FromTime (e.g. 20:00:00 to 02:00:00), the range runs past midnight.
Date,Time,Last,Bid,Ask,Volume
http://127.0.0.1:16239/Req?GetTimeSales(NFLX,09:45:00,09:47:00)OK
11/08/2017,09:45:00,196.639,196.48,196.64,1
11/08/2017,09:45:00,196.481,196.48,196.63,2
11/08/2017,09:45:01,196.5504,196.48,196.63,200
11/08/2017,09:45:04,196.61,196.47,196.61,50
...GetHistory(Symbol,FromDate,ToDate,Frequency[,RTH[,NewestFirst]])
Returns OHLC bars, intraday or end-of-day, built from the data Medved Trader has already stored for the symbol. It does not request new data, so backfill the symbol in Medved Trader first (open a chart on it, for example) if you need more history.
| Name | Req | Content |
|---|---|---|
| Symbol | Y | The symbol. |
| FromDate | Y | MM/DD/YYYY, or 0 for the earliest stored bar. |
| ToDate | Y | MM/DD/YYYY (includes that whole day), or 0 for the latest. |
| Frequency | Y | Intraday: a number of minutes, e.g. 5. Leave it empty for 1-minute bars.End of day: nD for n days (e.g. 1D, 3D), or 1W, 1M, 1Y for weekly, monthly or yearly bars. |
| RTH | N | Intraday only. YES for regular trading hours only, NO (default) for all sessions. The hours come from the symbol's timeframe, set in Medved Trader. |
| NewestFirst | N | YES to return the newest bar first. The default, NO, is oldest first. |
Intraday: Date,Time,Open,High,Low,Close,Volume. The time is the bar's start, US Eastern.
End of day: Date,Open,High,Low,Close,Volume.
http://127.0.0.1:16239/Req?GetHistory(AAPL,01/02/2026,01/09/2026,1D)OK
01/02/2026,250.42,251.27,244.91,245.83,52305900
01/05/2026,245.97,247.3,243.12,246.11,41203100
...
01/09/2026,252.17,254.5,251.03,253.88,39877400http://127.0.0.1:16239/Req?GetHistory(AAPL,01/09/2026,01/09/2026,5,YES)OK
01/09/2026,09:30:00,252.17,252.9,251.64,252.55,1893400
01/09/2026,09:35:00,252.55,253.10,252.31,252.98,1022700
...GetOptionChain(Symbol[,force])
Returns the option chain for an underlying symbol, one option per line. The chain is requested from your option data source (or your default quote source), and the call waits for that source to answer, for up to 60 seconds.
| Name | Req | Content |
|---|---|---|
| Symbol | Y | The underlying symbol. |
| force | N | The word force requests a fresh chain from the source instead of using the one Medved Trader already has. |
OptionSymbol,Expiration,Strike,CallPut. The expiration is M/D/YY and CallPut is C or P. The option symbol is in Medved Trader's format, so you can pass it to GetLastQuote or add it to a portfolio.
http://127.0.0.1:16239/Req?GetOptionChain(AAPL)OK
.AAPL_260116C250,1/16/26,250,C
.AAPL_260116P250,1/16/26,250,P
...If there is no chain for the symbol, the response is NO with status 404. If the source doesn't answer within 60 seconds, the response is Error: timed out ... with status 504.
GetLinkedSymbol(Color)
Returns the symbol currently set for a link group. A group only has a symbol while at least one window is linked to that color. The Active group always has one: it follows the active window.
| Name | Req | Content |
|---|---|---|
| Color | N | A link group color, or Active. If it is empty or not a known color, Gray is used. |
http://127.0.0.1:16239/Req?GetLinkedSymbol(Blue)OK
AAPLIf the group has no symbol, the response is NO with status 404.
SetLinkedSymbol(Symbol,Color)
Sets the symbol for a link group, so every window linked to that color switches to it.
| Name | Req | Content |
|---|---|---|
| Symbol | Y | The symbol to set. |
| Color | Y | A link group color. Active can't be set. |
http://127.0.0.1:16239/Req?SetLinkedSymbol(DELL,Gray)OKA missing symbol, or a missing or unknown color, returns status 400 with Missing a symbol or Invalid Link Color.
Link group colors
Color names are not case-sensitive.
Blue, Green, Red, Cyan, Brown, Black, Gray, Pink, Purple, LawnGreen, Maroon, Yellow, Olive, Iris, Tan, Apricot, Beige, Mint, Lime, Salmon, NeonPink, Crimson, Khaki, Teal, Chocolate, and Active (read only).
GetAppVersion()
Returns the running Medved Trader version. No parameters.
OK
1.2.1000.151GetVersion() — deprecated
Kept only for QuoteTracker compatibility. It always returns 3.980. Use GetAppVersion instead.
CloseApp()
Closes Medved Trader, without asking for confirmation. No parameters.
Shutting down Medved Trader