All APIs medvedtrader.com support

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.

HTTP GET · Local Plain text / CSV Requires MT Running

Enabling the HTTP API

The HTTP API is off by default. To turn it on:

  1. Go to Settings → App → API and find the HTTP API section.
  2. Check Enable HTTP API. Leave the Port at the default, 16239, unless another program on your machine already uses it.
  3. 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).

The HTTP API has no password or key. With local network access turned on, any device on your network can read your portfolios and quotes, change portfolios and close Medved Trader. Only turn it on for a network you trust, and never expose the port to the internet.

Request format

Every request is a GET to the path /Req, with the command and its parameters as the query string:

FORMAT
http://127.0.0.1:port/Req?Command(Param1,Param2,...)
EXAMPLE
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:

StatusBodyMeaning
400Error: ...A missing or invalid parameter, or a request that isn't /Req?....
404Error: Command "..."!Unknown command.
404Error: ... or NONothing to return, for example no open Portfolio window for CURRENT, no linked symbol, or no option chain.
500error messageMedved 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

Special portfolio and symbol IDs

IDMeaningAccepted by
CURRENTThe 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
ACTIVEEvery 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:nameCreates 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.

EXAMPLE REQUEST
http://127.0.0.1:16239/Req?EnumPorts()
EXAMPLE RESPONSE
OK
WTCH1,Watchlist
TECH,Tech Stocks
K3X9QD,Swing trades

EnumPortSymbols(PortID)

Returns the symbols in a portfolio, in the order they appear, as one comma-separated line.

Parameters
NameReqContent
PortIDYA portfolio ID from EnumPorts, or CURRENT.
EXAMPLE REQUEST
http://127.0.0.1:16239/Req?EnumPortSymbols(TECH)
EXAMPLE RESPONSE
OK
AAPL,MSFT,NVDA,GOOGL

An 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.

Parameters
NameReqContent
PortIDYA portfolio ID, CURRENT, or NEW:name to create a portfolio.
SymbolYOne or more symbols to add.
Medved Trader does not check for duplicates. A symbol that is already in the portfolio is added again, so check with EnumPortSymbols first if that matters.
EXAMPLE REQUEST
http://127.0.0.1:16239/Req?AddStocksToPort(CURRENT,MSFT,INTC)
EXAMPLE RESPONSE
OK
 portfolio updated
CREATING A PORTFOLIO
http://127.0.0.1:16239/Req?AddStocksToPort(NEW:Earnings%20Week,NFLX,TSLA)

OK
 K3X9QD portfolio created

AddDetailedStocksToPort(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.

Parameters
NameReqContent
PortIDYA portfolio ID, CURRENT, or NEW:name to create a portfolio.
SymbolYThe symbol to add.
SharesNNumber of shares. Leave it empty to skip it.
PriceNBase price paid per share.
CommissionNCommission paid.

The values are read in groups of four, so keep every group complete, using empty values where needed: MSFT,100,,.

As with AddStocksToPort, duplicates are not checked.
EXAMPLE REQUEST
http://127.0.0.1:16239/Req?AddDetailedStocksToPort(CURRENT,MSFT,100,410.5,1.00,INTC,200,21.25,1.00)
EXAMPLE RESPONSE
OK
 portfolio updated

RemoveStocksFromPort(PortID,Symbol,Symbol,...)

Removes symbols from a portfolio.

Parameters
NameReqContent
PortIDYA portfolio ID or CURRENT.
SymbolYOne or more symbols to remove.
EXAMPLE REQUEST
http://127.0.0.1:16239/Req?RemoveStocksFromPort(CURRENT,MSFT,INTC)
EXAMPLE RESPONSE
OK
 portfolio updated

EnumSymbols([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.

EXAMPLE REQUEST
http://127.0.0.1:16239/Req?EnumSymbols(ACTIVE)
EXAMPLE RESPONSE
OK
AAPL,MSFT,NVDA,GOOGL,NFLX

GetLastQuote(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.

Parameters
NameReqContent
SymbolYOne or more symbols, or one of CURRENT, ACTIVE or * (see special IDs).
Fields on each line
#FieldContent
1Symbol
2–3Date, TimeTime of the last update, US Eastern.
4Last
5Bid
6Ask
7ChangeChange from the previous close.
8TickAlways -. Kept for QuoteTracker compatibility.
9VolumeDay volume.
10HighDay high.
11LowDay low.
12BidSize
13AskSize
14LastVolumeSize of the last trade.
15AvgTradeAverage trade size.
16NumTradesNumber of trades today.
17Open
1852w Low
1952w High
EXAMPLE REQUEST
http://127.0.0.1:16239/Req?GetLastQuote(AAPL,NFLX)
EXAMPLE RESPONSE
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.38

GetTimeSales(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.

Parameters
NameReqContent
SymbolYThe symbol.
FromTimeYHH: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.
ToTimeYHH: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.

Fields on each line

Date,Time,Last,Bid,Ask,Volume

EXAMPLE REQUEST
http://127.0.0.1:16239/Req?GetTimeSales(NFLX,09:45:00,09:47:00)
EXAMPLE RESPONSE
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.

Parameters
NameReqContent
SymbolYThe symbol.
FromDateYMM/DD/YYYY, or 0 for the earliest stored bar.
ToDateYMM/DD/YYYY (includes that whole day), or 0 for the latest.
FrequencyYIntraday: 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.
RTHNIntraday only. YES for regular trading hours only, NO (default) for all sessions. The hours come from the symbol's timeframe, set in Medved Trader.
NewestFirstNYES to return the newest bar first. The default, NO, is oldest first.
Fields on each line

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.

EXAMPLE REQUEST — DAILY
http://127.0.0.1:16239/Req?GetHistory(AAPL,01/02/2026,01/09/2026,1D)
EXAMPLE RESPONSE
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,39877400
EXAMPLE REQUEST — 5-MINUTE BARS, REGULAR HOURS
http://127.0.0.1:16239/Req?GetHistory(AAPL,01/09/2026,01/09/2026,5,YES)
EXAMPLE RESPONSE
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.

Parameters
NameReqContent
SymbolYThe underlying symbol.
forceNThe word force requests a fresh chain from the source instead of using the one Medved Trader already has.
Fields on each line

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.

EXAMPLE REQUEST
http://127.0.0.1:16239/Req?GetOptionChain(AAPL)
EXAMPLE RESPONSE
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.

Parameters
NameReqContent
ColorNA link group color, or Active. If it is empty or not a known color, Gray is used.
EXAMPLE REQUEST
http://127.0.0.1:16239/Req?GetLinkedSymbol(Blue)
EXAMPLE RESPONSE
OK
AAPL

If 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.

Parameters
NameReqContent
SymbolYThe symbol to set.
ColorYA link group color. Active can't be set.
EXAMPLE REQUEST
http://127.0.0.1:16239/Req?SetLinkedSymbol(DELL,Gray)
EXAMPLE RESPONSE
OK

A 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.

EXAMPLE RESPONSE
OK
1.2.1000.151

GetVersion() — deprecated

Kept only for QuoteTracker compatibility. It always returns 3.980. Use GetAppVersion instead.

CloseApp()

Closes Medved Trader, without asking for confirmation. No parameters.

EXAMPLE RESPONSE
Shutting down Medved Trader