Log in

Magic Album Lua API



Magic Album uses Lua as an embedded scripting language. You can write your own scripts to import card prices from your favorite online shops. If you do not familiar with the Lua start with reading the official documentation.

Price Scripts

Scripts responsible for price importing should be placed in "Prices" directory and had ".lua" extension. You should restart Magic Album if you delete or add scripts to this directory (application restart is not needed if you modify the content of the scripts). Every price script must include startup function

function ImportPrice(importfoil, importlangs, importsets)
  • importfoil: "Y" - if the script should import both foils and regulars, "N" - if the script should import only regulars, "O" - if the script should import only foils.
  • importlangs: array of languages script should import, represented as pairs {languageid, languagename} (see "Database\Languages.txt" file).
  • importsets: array of sets script should import, represented as pairs {setid, setname} (see "Database\Sets.txt" file).

API Functions

Magic Album provides several functions you can use in Lua scripts. These functions are grouped under "ma" table so the call will look like
ma.funcname(arg1, arg2, ... argn)


webpage = ma.GetUrl(url)

Returns downloaded web page or nil if there was an error (page not found, network problems, etc.)


file = ma.GetFile(filepath)
Returns loaded file or nil if there was an error (file not found, out of memory, etc.). For security reasons only files from the Magic Album folder can be loaded. filepath is relative to the Magic Album folder. I.e. if you call
file = ma.GetFile("Prices\\test.dat")
"MA_FOLDER\Prices\test.dat" will be loaded. Do not forget to use double slashes for paths.


ma.PutFile(filepath, data, append)

Saves data to the file. For security reasons the file is placed inside the Magic Album folder. "filepath" is relative to the Magic Album folder (see GetFile description). If "append" parameter is missing or 0 - file will be overwritten. Otherwise data will be added to the end of file.



Returns current time in seconds since January 1st, 1970.



Adds debug message to Magic Album log file.


modifiednum = ma.SetPrice(setid, langid, cardname, cardversion, regprice, foilprice, objtype)

Set the price of the certain card.

  • setid is the numeric ID of the set. You can find all available IDs in "Database\Sets.txt" file.
  • langid is the numeric ID of the language. You can find all available IDs in "Database\Languages.txt" file.
  • cardname is the name of the card in UTF-8 encoding. Magic Album tries to match the cardname first against the Oracle Name, then against the Name field.
  • cardversion is the version of the card as it is shown in Magic Album. If set to "*" all versions of the card will be processed.
  • regprice and foilprice are the numerical values. Pass zero if you do not know or do not want to set the value.
  • objtype is an object type (0 for all objects, 1 for cards, 2 for tokens, 3 for nontraditional, 4 for inserts, 5 for replicas). This parameter is optional. Default value is 0.
  • this function returns the number of modified cards.


-- Set the price of foil M11 English Celestial Purge to $4.25
ma.SetPrice(770, 1, "Celestial Purge", "", 0, 4.25)
-- Set the regular and foil prices for all versions of M10 Russian Forests (using Russian card name)
ma.SetPrice(759, 2, "Лес", "*", 0.01, 0.1, 1)


ma.SetProgress(text, position)

Sets progress bar text and position. Position is a numeric value in range 0..100.


File "Prices\MTG Mint Card.lua" is a working script example. Start with understanding it before writing your own scripts.