> For the complete documentation index, see [llms.txt](https://docs.succubus.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.succubus.space/untitled.md).

# GraphQL

## What is GraphQL?

GraphQL is a strongly typed API query language that provides an alternative to REST. It allows clients to define the structure of the data required, and exactly the same structure of the data is returned from the server. This avoids both the problems of over and under-fetching data, while also allowing for a more powerful and flexible API.

{% hint style="info" %}
Before reading these docs and using the API it's highly recommended you familiarize yourself with GraphQL by reading the [official GraphQL documentation](http://graphql.org/learn/queries/).
{% endhint %}

## Making a GraphQL API Request

{% hint style="info" %}

#### All requests made to the GraphQL endpoint must be made as a POST request to '<https://api.succubus.space/graphql>'.

{% endhint %}

When you make a request you'll need to include 2 payload objects, `query`, and `variables`.

* query: contains your query or mutation strings.
* variables: contains the variable values used within your query.

You can omit the variables object and instead hard-code your values inside your query, however, this is not recommended past the simplest of queries.

### Example Query Request

Below is a simple request that fetches a hentai by its ID.

{% tabs %}
{% tab title="Javascript" %}

```javascript
// Here we define our query as a multi-line string
// Storing it in a separate .graphql/.gql file is also possible
const query = `
query ($id: Int) { # Define which variables will be used in the query (ID)
  hentai (id: $id) { # Insert our variables into the query arguments (ID)
    id
    name
    titles
  }
}
`;

// Define our query variables and values that will be used in the query request
const variables = {
    id: 1226
};

// Define the config we'll need for our API request
const url = 'https://api.succubus.space/graphql',
    options = {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            'Accept': 'application/json',
        },
        body: JSON.stringify({
            query: query,
            variables: variables
        })
    };

// Make the HTTP Api request
fetch(url, options).then(handleResponse)
                   .then(handleData)
                   .catch(handleError);

function handleResponse(response) {
    return response.json().then(function (json) {
        return response.ok ? json : Promise.reject(json);
    });
}

function handleData(data) {
    console.log(data);
}

function handleError(error) {
    alert('Error, check console');
    console.error(error);
}
```

This request will return the following JSON response:

```javascript
{
  "data": {
    "hentai": {
      "id": "1226",
      "name": "Itadaki! Seieki",
      "titles": [
        "I`ll Have Your Semen",
        "Itadaki! Seieki",
        "Vampire Vixen",
        "いただきっ! セーエキ",
        "잘먹을게 정액"
      ]
    }
  }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.succubus.space/untitled.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
