**Main components:**
* Wikidata Query Service
**User story:**
As a user of the Wikidata Query Service,
I want to share complex queries via a short URL
in order to share my work with others (e.g. via Twitter).
**Problem:**
* Currently the maximum size for the URL to be shortened on the URL shortener is 2000 characters. This is not enough for complex Wikidata queries. It gets even worse if Unicode characters are involved.
* A suggested {T220703} was declined for security reasons. We need to find a different solution for this.
**Example:**
* [[ https://query.wikidata.org/#%23defaultView%3AMap%0ASELECT%20%3Fs%20%3FsLabel%20%3Fcoor%20%3Foperator%20%3FoperatorLabel%20%3Fimage%20%3Flayer%20WHERE%20%7B%20%20%0A%20%20%0A%20%20%20%20%20%20%20%3Fs%20wdt%3AP31%2Fwdt%3AP279%2a%20wd%3AQ28564%20%3B%0A%20%20%20%20%20%20%20%20%20%20wdt%3AP17%20wd%3AQ145%20%3B%0A%20%20%20%20%20%20%20%20%20%20wdt%3AP625%20%3Fcoor%20%3B%0A%20%20%20%20%20%20%20%20%20%20wdt%3AP137%20%3Foperator%20%3B%0A%20%20%20%20%20%20%20%20%20%20OPTIONAL%20%7B%3Fs%20wdt%3AP18%20%3Fimage%20.%7D%0A%20%20%0A%20%20VALUES%20%3Foperator%20%7B%20wd%3AQ4923796%20wd%3AQ4966533%20wd%3AQ5016926%20wd%3AQ5038400%20wd%3AQ5043224%20wd%3AQ5064127%20wd%3AQ5166758%20wd%3AQ5256629%20wd%3AQ16837157%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20wd%3AQ5623821%20wd%3AQ6083890%20wd%3AQ16997658%20wd%3AQ6901162%20wd%3AQ6984500%20wd%3AQ16998902%20wd%3AQ7161994%20wd%3AQ7236943%20wd%3AQ7321391%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20wd%3AQ5123523%20wd%3AQ7825688%20wd%3AQ7909538%20wd%3AQ8038115%20%7D%0ABIND%28%20%0A%20%20%20%20%20%20%20IF%28%3Foperator%20%3D%20wd%3AQ4923796%2C%20%22Blaenau%20Gwent%22%2C%20%0A%20%20%20%20%20%20%20IF%28%3Foperator%20%3D%20wd%3AQ4966533%2C%20%22Bridgend%22%2C%20%0A%20%20%20%20%20%20%20IF%28%3Foperator%20%3D%20wd%3AQ5016926%2C%20%22Caerphilly%22%2C%20%20%0A%20%20%20%20%20%20%20IF%28%3Foperator%20%3D%20wd%3AQ5038400%2C%20%22Cardiff%22%2C%20%20%20%0A%20%20%20%20%20%20%20IF%28%3Foperator%20%3D%20wd%3AQ5043224%2C%20%22Carmarthenshire%22%2C%20%0A%20%20%20%20%20%20%20IF%28%3Foperator%20%3D%20wd%3AQ5064127%2C%20%22Ceredigion%22%2C%20%20%20%0A%20%20%20%20%20%20%20IF%28%3Foperator%20%3D%20wd%3AQ5166758%2C%20%22Conwy%22%2C%0A%20%20%20%20%20%20%20IF%28%3Foperator%20%3D%20wd%3AQ5256629%2C%20%22Denbighshire%22%2C%0A%20%20%20%20%20%20%20IF%28%3Foperator%20%3D%20wd%3AQ16837157%2C%20%22Flintshire%22%2C%20%0A%20%20%20%20%20%20%20IF%28%3Foperator%20%3D%20wd%3AQ5623821%2C%20%22Gwynedd%22%2C%20%20%20%0A%20%20%20%20%20%20%20IF%28%3Foperator%20%3D%20wd%3AQ6083890%2C%20%22Isle%20of%20Anglesey%22%2C%0A%20%20%20%20%20%20%20IF%28%3Foperator%20%3D%20wd%3AQ16997658%2C%20%22Merthyr%20Tydfil%22%2C%0A%20%20%20%20%20%20%20IF%28%3Foperator%20%3D%20wd%3AQ6901162%2C%20%22Monmouthshire%22%2C%0A%20%20%20%20%20%20%20IF%28%3Foperator%20%3D%20wd%3AQ6984500%2C%20%22Neath%20Port%20Talbot%22%2C%20%20%20%0A%20%20%20%20%20%20%20IF%28%3Foperator%20%3D%20wd%3AQ16998902%2C%20%22Newport%22%2C%0A%20%20%20%20%20%20%20IF%28%3Foperator%20%3D%20wd%3AQ7161994%2C%20%22Pembrokeshire%22%2C%20%0A%20%20%20%20%20%20%20IF%28%3Foperator%20%3D%20wd%3AQ7236943%2C%20%22Powys%22%2C%20%20%20%0A%20%20%20%20%20%20%20IF%28%3Foperator%20%3D%20wd%3AQ7321391%2C%20%22Rhondda%20Cynon%20Taf%22%2C%0A%20%20%20%20%20%20%20IF%28%3Foperator%20%3D%20wd%3AQ5123523%2C%20%22Swansea%22%2C%0A%20%20%20%20%20%20%20IF%28%3Foperator%20%3D%20wd%3AQ7825688%2C%20%22Torfaen%22%2C%20%20%20%0A%20%20%20%20%20%20%20IF%28%3Foperator%20%3D%20wd%3AQ7909538%2C%20%22Vale%20of%20Glamorgan%22%2C%20%0A%20%20%20%20%20%20%20IF%28%3Foperator%20%3D%20wd%3AQ8038115%2C%20%22Wrexham%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22%22%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%29%20AS%20%3Flayer%29.%20%20%0A%20%20%0ASERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22%20%7D%0A%7D%0AORDER%20BY%20%3FoperatorLabel%20%3FsLabel | Some example query ]]
* [[ https://query.wikidata.org/#SELECT%20%3Fparameters%20%28SUM%28%3FstatementCount%29%20AS%20%3FcheckCount%29%20WITH%20%7B%0A%20%20SELECT%20%3Fproperty%20%28COUNT%28%3Fstatement%29%20AS%20%3FstatementCount%29%20WHERE%20%7B%0A%20%20%20%20BIND%28wd%3AQ42%20AS%20%3Fitem%29%0A%20%20%20%20%3Fitem%20%3Fp%20%3Fstatement.%0A%20%20%20%20%3Fproperty%20a%20wikibase%3AProperty%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20wikibase%3Aclaim%20%3Fp.%0A%20%20%7D%0A%20%20GROUP%20BY%20%3Fproperty%0A%7D%20AS%20%25properties%20WITH%20%7B%0A%20%20SELECT%20%3Fconstraint%20%3FrelationLabel%20%3FclassLabel%20%3FstatementCount%20WHERE%20%7B%0A%20%20%20%20INCLUDE%20%25properties.%0A%20%20%20%20%3Fproperty%20p%3AP2302%20%3Fconstraint.%0A%20%20%20%20%3Fconstraint%20ps%3AP2302%20wd%3AQ21503250%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20pq%3AP2309%20%3Frelation%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20pq%3AP2308%20%3Fclass.%0A%20%20%20%20SERVICE%20wikibase%3Alabel%20%7B%0A%20%20%20%20%20%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen%22.%0A%20%20%20%20%20%20%3Frelation%20rdfs%3Alabel%20%3FrelationLabel.%0A%20%20%20%20%20%20%3Fclass%20rdfs%3Alabel%20%3FclassLabel.%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20ORDER%20BY%20%3Fconstraint%20%3FrelationLabel%20%3FclassLabel%20%3FstatementCount%0A%7D%20AS%20%25constraintsWithParameters%20WITH%20%7B%0A%20%20SELECT%20%3Fconstraint%20%28CONCAT%28GROUP_CONCAT%28DISTINCT%20%3FrelationLabel%29%2C%20%22%20%22%2C%20GROUP_CONCAT%28DISTINCT%20%3FclassLabel%3B%20separator%20%3D%20%22%2C%20%22%29%29%20AS%20%3Fparameters_%29%20%3FstatementCount%20WHERE%20%7B%0A%20%20%20%20INCLUDE%20%25constraintsWithParameters.%0A%20%20%7D%0A%20%20GROUP%20BY%20%3Fconstraint%20%3FstatementCount%0A%7D%20AS%20%25constraintParameters%20WHERE%20%7B%0A%20%20INCLUDE%20%25constraintParameters.%0A%20%20BIND%28%0A%20%20%20%20IF%28REGEX%28%3Fparameters_%2C%20%22%2C%20.%2a%2C%22%29%2C%0A%20%20%20%20%20%20%20REPLACE%28%3Fparameters_%2C%20%22%28.%2a%29%2C%20%28.%2a%29%22%2C%20%22%241%2C%20or%20%242%22%29%2C%20%23%20the%20first%20.%2a%20is%20greedy%2C%20so%20this%20replaces%20the%20last%20%3B%0A%20%20%20%20%20%20%20REPLACE%28%3Fparameters_%2C%20%22%28.%2a%29%2C%20%28.%2a%29%22%2C%20%22%241%20or%20%242%22%29%29%0A%20%20%20%20AS%20%3Fparameters%29%0A%7D%0AGROUP%20BY%20%3Fparameters%0AHAVING%28%3FcheckCount%20%3E%201%29%0AORDER%20BY%20DESC%28%3FcheckCount%29 | Another real-life example query]]
**Solution:**
Ideas for solutions:
* The current URL-encoded strings have high redundancy. This means that a compression algorithm that is optimized for WDQS / the SPARQL syntax might enable users to create complex scripts that still fit into the 2000 character limit of the URL shortener.
* Alternative mechanism for shortening URLs (e.g. T220703#7499438)
* ...
**Acceptance criteria:**
[]
**Open questions:**
* What other solutions could you think of?
* What compression algorithm would be best suited for this purpose?