Skip to content

Get one character

To get a specific character from Rick and Morty API, construct your query like this:

Terminal window
curl -X POST \
-H 'Content-Type: application/json' \
-d '{
"query": "query GetOneCharacterDeets($id: ID!) { character(id: $id) { name status species type gender origin { name } location { name } image created } }",
"variables": { "id": "YOUR_CHARACTER_ID_HERE" }
}' \
https://rickandmortyapi.com/graphql

The results will be a JSON object containing a results array. You can see an example of this below:

results shape
{
"data": {
"character": {
"name": "Rick Sanchez",
"status": "Alive",
"species": "Human",
"type": "",
"gender": "Male",
"origin": {
"name": "Earth (C-137)"
},
"location": {
"name": "Citadel of Ricks"
},
"image": "https://rickandmortyapi.com/api/character/avatar/1.jpeg",
"created": "2017-11-04T18:48:46.250Z"
}
}
}