Support wiki

This is the wiki.gg support wiki! It's a different site from your content wiki!

Cargo/Exporting data

From Support Wiki
Jump to navigation Jump to search

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

Queries in Cargo include various display formats that can be used for exporting data: "csv", "json", "excel", "feed", "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

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 page MediaWiki: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

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 page MediaWiki: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

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 page MediaWiki: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

feed

The "feed" format has the following parameters, all optional:

  • feed type - sets the type of the feed; the set of allowed types is specified in $wgFeedClasses, and by default is "atom" or "rss" (default is "atom")
  • link text - sets the text of the link (default is "View Atom feed" or "View RSS feed", or the value at the page MediaWiki:cargo-viewfeed)
  • feed title - sets the feed's title element (default is "News feed")
  • feed description - sets the feed's description (RSS) or subtitle (Atom) element

Additionally, the query can/should include the following fields:

  • title - sets the item's title element (RSS/Atom); if title is not set, _pageName is used, so one of these must be included in the query
  • the query must include at least one field of type Date or Datetime - the first Date/Datetime field sets the item's pubDate (RSS) or updated element
  • description (optional) - sets the item's description (RSS) or summary (Atom) element; if not set, the full wikitext of the specified page is used
  • url - sets the item's link element (RSS/Atom); if not set, the URL of the specified wiki page is used
  • author (optional) - sets the item's author element
  • comments (optional) - sets the item's comments element (RSS only), which is meant to hold the URL of a page for comments relating to the item
  • id (optional) - sets the item's unique ID; if not set, the URL of the wiki page is used

The feed item's guid (RSS) or id (Atom) element is set automatically to be a URL based on the wiki's URL plus the _pageName.

icalendar

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 page MediaWiki: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

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 page MediaWiki:cargo-viewjson)
  • parse values - if set, causes the text displayed to be parsed into HTML instead of kept as wikitext

API

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, see https://support.wiki.gg/api.php?action=help&modules=cargoquery or Special:ApiSandbox.