User:Rdrg109/1/11

From Wikidata
Jump to navigation Jump to search

This page describes how to see the code that was used to generate the results of a Wikidata SPARQL results URL.

TL; DR[edit]

Delete the Template:Code2 part.

For example, if the link to the results looks like

https://query.wikidata.org/embed.html#SELECT%20%3Ffoo%20{%0A%20%20VALUES%20%3Ffoo%20{%201%202%203%20}.%0A}

it now should look like

https://query.wikidata.org/#SELECT%20%3Ffoo%20{%0A%20%20VALUES%20%3Ffoo%20{%201%202%203%20}.%0A}

Additional context[edit]

Let's suppose I've written this SPARQL query. It lists the earthquakes that have happened in Peru. You don't need to understand it to understand the point of this page.

SELECT
  ?fecha
  ?item
  ?itemLabel
  ?itemDescription
  ?location
  ?locationLabel
{
  ?item
    wdt:P31 wd:Q7944;
    wdt:P276/wdt:P131* wd:Q419.
  OPTIONAL{?item wdt:P276 ?location}
  OPTIONAL{?item wdt:P585 ?fecha}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "es". }
}
ORDER BY DESC(?fecha)
Try it!

Now, I want to share the results of this query to someone. so you might want to send the URL shortened link to the results of the query. If you click on the button for generating that link, you would get the following Template:Code2. When this link is opened, the user is redirected to the following URL

https://query.wikidata.org/embed.html#SELECT%0A%20%20%3Ffecha%0A%20%20%3Fitem%0A%20%20%3FitemLabel%0A%20%20%3FitemDescription%0A%20%20%3Flocation%0A%20%20%3FlocationLabel%0A%7B%0A%20%20%3Fitem%0A%20%20%20%20wdt%3AP31%20wd%3AQ7944%3B%0A%20%20%20%20wdt%3AP276%2Fwdt%3AP131*%20wd%3AQ419.%0A%20%20OPTIONAL%7B%3Fitem%20wdt%3AP276%20%3Flocation%7D%0A%20%20OPTIONAL%7B%3Fitem%20wdt%3AP585%20%3Ffecha%7D%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22es%22.%20%7D%0A%7D%0AORDER%20BY%20DESC(%3Ffecha)

If you send that link to someone, they will only be able to see the results of the query (i.e. not the SPARQL code). In order for them to see the results, they need to delete the Template:Code2 part in the expanded URL (i.e. not the shortened one). That is, the link should now look like

https://query.wikidata.org/#SELECT%0A%20%20%3Ffecha%0A%20%20%3Fitem%0A%20%20%3FitemLabel%0A%20%20%3FitemDescription%0A%20%20%3Flocation%0A%20%20%3FlocationLabel%0A%7B%0A%20%20%3Fitem%0A%20%20%20%20wdt%3AP31%20wd%3AQ7944%3B%0A%20%20%20%20wdt%3AP276%2Fwdt%3AP131*%20wd%3AQ419.%0A%20%20OPTIONAL%7B%3Fitem%20wdt%3AP276%20%3Flocation%7D%0A%20%20OPTIONAL%7B%3Fitem%20wdt%3AP585%20%3Ffecha%7D%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22es%22.%20%7D%0A%7D%0AORDER%20BY%20DESC(%3Ffecha)