Extension:Cargo/Exporting data
You can export the data contained in Cargo to use by other systems. There are various ways to do it: via display formats, via the API, and through direct SQL querying.
Export display formats[edit]
Queries in Cargo include several display formats that can be used for exporting data: "csv", "json", "excel", "bibtex", "icalendar" and "zip". If you set one of these as the display format, you will simply see a link as the query result. Clicking on that link will download a file (provided by the page Special:CargoExport) to the user's computer, that holds that structured data. Any outside system can also directly access that URL, if it has access to the wiki.
bibtex[edit]
The "bibtex" format has the following parameters, all optional:
link text
- sets the text of the link (default is "View BibTeX", or the value at the pageMediaWiki:cargo-viewbibtex
)default entry type
- sets the default type of the BibTeX entries, e.g. article, book, booklet, etc. (default is "article")
In addition, you can set aliases for various queried fields in order to have them be included in the BibTeX output. The full set of handled aliases is: address, annote, author, booktitle, chapter, crossref, doi, edition, editor, howpublished, institution, journal, key, month, note, number, organization, pages, publisher, school, series, title, type, volume, year. A description for each field can be found here.
csv[edit]
The "csv" format has the following parameters, all optional:
delimiter
- sets the separator character (default is comma)link text
- sets the text of the link (default is "View CSV", or the value at the pageMediaWiki:cargo-viewcsv
)filename
- sets the name of the file that is downloaded (default is "results.csv")parse values
- if set, causes the text displayed to be parsed into HTML instead of kept as wikitext
excel[edit]
The "excel" format has the following parameters, all optional:
link text
- sets the text of the link (default is "View XLS", or the value at the pageMediaWiki:cargo-viewxls
)filename
- sets the name of the file that is downloaded (default is "results.xls")parse values
- if set, causes the text displayed to be parsed into HTML instead of kept as wikitext
icalendar[edit]
The "icalendar" format has the following parameters, all optional:
link text
— sets the text of the link (default is "View iCalendar", or the value at the pageMediaWiki:cargo-viewicalendar
)filename
— sets the name of the file that is downloaded (default is "export.ics")icalendar name
— name of the exported calendar (often displayed by calendar clients)icalendar description
— description of the exported calendar, can not contain any formatting
json[edit]
The "json" format has the following parameters, all optional:
link text
- sets the text of the link (default is "View JSON", or the value at the pageMediaWiki:cargo-viewjson
)parse values
- if set, causes the text displayed to be parsed into HTML instead of kept as wikitext
zip[edit]
The "zip" format creates a Zip file out of a set of files that have been uploaded to the wiki. It can be used either when querying such files directly (such as by querying the _fileData table), or querying a field that holds file names, such as a field called "Photo". If it's the latter, the field must be of type "File".
This format has the following parameters, both optional:
link text
— sets the text of the link (default is "Download ZIP", or the value at the pageMediaWiki:cargo-downloadzip
)filename
— sets the name of the file that is downloaded (default is "results.zip")
API[edit]
Cargo defines the "cargoquery" MediaWiki API action, which lets you call the equivalent of #cargo_query from an outside the wiki, returning the results in MediaWiki-specific JSON and XML formats. To see its usage syntax, search for "action=cargoquery" here.
Database querying[edit]
Finally, because Cargo stores its data in fairly simple database tables, you should be able to have other systems directly query its data using SQL, provided of course that they have access to that database. You can see an explanation of Cargo's data storage, including some special fields and tables, at Database storage details.