**Problem**
Getting data for a single item either gives you a huge (~47KB) response:
https://www.wikidata.org/wiki/Special:EntityData/Q817266.json
This response also doesn't telll you what the ids represent. For instance there is no way to know what a `P136` id represents without making another set of requests with //huge// responses.
or to query for properties on a single item, is a little complicated:
```
SELECT ?title (sample(?image) as ?singleImage) (group_concat(?genreLabel; separator="; ") as ?genres) WHERE {
wd:Q817266 rdfs:label ?title filter (lang(?title) = "en") .
optional { wd:Q817266 wdt:P18 ?image . }
optional { wd:Q817266 wdt:P136 ?genre . }
service wikibase:label { bd:serviceParam wikibase:language "en". ?genre rdfs:label ?genreLabel. }
} group by ?title
````
I'm not sure this would return anything at all if the title is missing in English. And this is just three properties, it will get even more complicated with more properties. Also, it would be extremely difficult to get nested properties. For instance, if I wanted to get each genre's `P136` image `P19` I wouldn't be able to do that (at least not well) without a subsiquent query. And adding another item id to the query would make it even more complex (etc. etc.)
SPARQL is fantastic at doing what it does: making complex queries and getting a list of items back. But it's not very good at getting a bunch of nested properties on a single item.
It would be really helpful if you could request data about a single item (or multiple by id) and get back a subset of nested .
**Solution**
I think it would be really helpful if Wikidata supported [[ http://graphql.org | GraphQL ]] ([[ http://facebook.github.io/graphql/ | spec ]]) which is used not only by Facebook, but is also now the exclusive method for [[ https://developer.github.com/v4/ |GitHub's API ]].
The above SPARQL query could look like this (based on the work done in T173214#3865779):
```
{
item(id: "Q817266") {
label(language: "en") {
text
}
images: statements(propertyIds: "P18") {
image: mainsnak {
value: datavalue
}
}
genres: statements(propertyIds: "P136") {
item {
label(language: "en") {
text
}
}
}
}
}
```
which would give a repsonse like this:
```
lang=json
{
"data": {
"item": {
"label": {
"text": "Easy A"
},
"images": [
{
"image": {
"value": "Easy A.svg"
}
}
],
"genres": [
{
"genre": {
"label": {
"text": "comedy film"
}
}
},
{
"genre": {
"label": {
"text": "teen film"
}
}
},
{
"genre": {
"label": {
"text": "LGBT-related film"
}
}
}
]
}
}
}
```
This makes the query a whole lot small and easier to do and [[ https://github.com/graphql/graphiql | GraphiQL ]] also supports introspection as seen in T173214#3865779 so the whole thing is self-documenting.