{% import "_includes/forms" as forms %} {% set welcome %} _CraftQL_ exposes the configuration of this Craft website to a [GraphQL](http://graphql.org) API. Without any additional configuration all your sections, assets, categories, and tags can be queried using the native GraphQL syntax. For example, if you had a section named `news` you could ask _CraftQL_ for five recent entries while limiting the response to only the uri, title, and body fields. _CraftQL_ would then respond with a JSON structure matching the query structure, populated with only the requested data.

Query

{
  entries(limit:5) {
    ...on News {
      uri
      title
      body
    }
  }
}

Response

{
  "data": {
    "entries": [
      {
        "uri": "news/a-news-article",
        "title": "A News Article",
        "body": "<p>This is the body…</p>"
      },
      // ...
    ]
  }
}
## Getting started You can access your GraphQL endpoint in two ways, 1. **[GraphiQL]({{ url('craftql/browse') }})**

will show you a graphical interface to GraphQL. Use it to explore your schema and test requests. Click _Docs_ in the upper right hand corner to see all the fields you can query against.

2. **Curl** {% if settings.tokens|length %}

You can query your schema directly by passing a GraphQL statement throuh a `query` variable. The following Curl statement should get you started,

$ curl -H "Authorization: bearer {{ settings.tokens[0].token|default('{TOKEN}') }}" -H "Content-type: application/json" -d '{"query":"{ helloWorld }"}' {{ siteUrl }}{{ settings.uri }}

{% else %}

Before you can use Curl you need to [add a token]({{ url('craftql/token-gen') }}) for authenticated access in to Craft.

{% endif %} {% endset %}
{{ welcome|md }}

URI

{{ forms.textField({ first: true, name: 'uri', value: settings.uri, instructions: 'The URI to the GraphQL service. Typically this is `api` but you can override it with your own preference.', }) }}

Tokens

Tokens control access in to your API. Instead of authenticating with a username and password, API access is granted via a token. Treat this token like a password because it provides privileged access in to your Craft website.

Generate a new token (for my user)

{% if settings.tokens|length > 0 %} {% for token in settings.tokens %} {% endfor %}
Name Token
{{ token.token }} Settings…
{% endif %}