**Revised after public discussion, April 1 2017**
== Problem ==
Wikimedia is managing a growing amount of machine readable data as wiki page content. The latest addition is the Data namespace on commons, which hosts tabular data like [[https://commons.wikimedia.org/wiki/Data:Dolmens_of_the_Preseli_Hills.tab|Data:Dolmens_of_the_Preseli_Hills.tab]] and geographic data like [[https://commons.wikimedia.org/wiki/Data:Avignon_City_Wall.map|Data:Avignon_City_Wall.map]].
There is currently no canonical URL for referring to and retrieving these data sets. Canonical URLs are needed as stable identifiers (URIs) in linked data.
**Concrete need:** Wikidata can reference geo-shape data from the Data namespace on Commons. To represent such references in RDF, the data set needs a canonical URI. See {T159517}
== Proposed Solution ==
* Use URLs of the form https://commons.wikimedia.org/data/Data:Avignon_City_Wall.map to identify and retrieve machine readable page content.
* The ```/data/``` path is rewritten to a special page, Special:PageData
* Special Special:PageData will redirect (with status 303) to an appropriate (and typically cacheable) URL for retrieving the page data. For now, this will use the ```action=raw``` interface.
* Special:PageData may apply content negotiation based on the Accept header sent by the client. In the first iteration, it will only check if any accept header sent by the client is compatible with the content model of the requested page.
* The 303 redirects are not cecheable for now, because they depend on the Accept header; complex normalization would be needed to allow the cache to vary on the Accept header without causing massive cache fragementation.
Note that in contrast to Wikidata entity URIs, the above URIs identify //descriptions// (data), not the thing described by the data.
== Status Quo ==
* There is a way to get raw page data for most data types, using action=raw with the "ugly" URL form: <https://commons.wikimedia.org/w/index.php?title=Data:Avignon_City_Wall.map&action=raw>. However, this is not supported for data types that have "direct editing " disabled. E.g. <https://www.wikidata.org/w/index.php?title=Q23&action=raw> does not work.
* Wikidata uses <https://www.wikidata.org/entity/Q23> as the canonical URI of concepts, and <https://www.wikidata.org/wiki/Special:EntityData/Q23> as the canonical URI of the description. Both apply content negotiation and trigger a 303 redirect. The canonical URL for a specific serialization has the form <https://www.wikidata.org/wiki/Special:EntityData/Q23.ttl>.
== Concerns an Alternatives Considered ==
* Do not include the namespace after /data/, e.g. https://commons.wikimedia.org/data/Avignon_City_Wall.map
* That would mean this URL pattern cannot be used as a general mechanism to refer to page content. It would be specific to the Data namespace on Commons.
* Use "raw" instead of "data", e.g. https://commons.wikimedia.org/raw/Data:Avignon_City_Wall.map
* "raw" is less descriptive, and may not be correct if content negotiation is applied.
* Use REST API URLS
* The REST API offers fairly clean URLs, but they still expose details about the web application and API version. Even the fact that they expose the fact that this is an API is too specific in a context where URLs are used as identifiers.
* Apply content negotiation to the established page URLs using the ```/wiki/``` path
* The ``/wiki/`` path really points to a UI for interacting with the page. Using it to refer to the page content can be confusing. On the other hand, such URLs are already in use for referring to Wikipedia pages in RDF.
* "URLs don't need to be pretty"
* While URLs do not have to be pretty, they should be stable, especially when they are to be used as stable unique identifiers. Remocing all application specific information from the URL provides more stability by adding a layer of abstraction.
== Resources ==
* https://www.w3.org/TR/cooluris/
* https://www.w3.org/TR/dwbp/#UniqueIdentifiers
* https://www.w3.org/TR/ld-bp/#HTTP-URIS
* https://data.gov.uk/resources/uris
* http://philarcher.org/diary/2013/uripersistence/#minimal
* https://www.w3.org/Provider/Style/URI.html