> ## Documentation Index
> Fetch the complete documentation index at: https://docs.climatifai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Climatifai GraphQL API overview

> The Climatifai GraphQL API provides all REST capabilities plus crop comparison, agroclimatic alerts, and RAG context in a single flexible endpoint.

The Climatifai API exposes a GraphQL endpoint at `/graphql`, powered by [Strawberry](https://strawberry.rocks) and FastAPI. It supports everything the REST API offers — crop advisor scores, climate series, fire hotspots, fire risk, and geocoding — plus three capabilities exclusive to GraphQL: side-by-side crop comparison, live agroclimatic alerts for eight LATAM zones, and semantic document search via RAG context. You can select exactly the fields you need in a single request, which is particularly useful when building dashboards or mobile clients where bandwidth matters.

## Endpoint

```text theme={null}
POST api.climatifai.com/graphql
```

Send all GraphQL operations as HTTP `POST` requests with a JSON body containing a `query` string (and optionally `variables`).

You can also open `GET api.climatifai.com/graphql` in a browser to access the **GraphiQL IDE**, an in-browser playground where you can explore the schema, run queries interactively, and inspect field-level documentation.

## Design

All operations are queries (read-only). The schema exposes no mutations or subscriptions — every call retrieves data without modifying state.

## Available queries

| Query                                         | Description                                          |
| --------------------------------------------- | ---------------------------------------------------- |
| `advisor(lat, lon, cropId, season)`           | Agricultural aptitude score for a crop at a location |
| `climate(lat, lon, from, to, scenario)`       | Historical climate baseline and CMIP6 projections    |
| `hotspots(lat, lon, radiusKm, days, source)`  | Active NASA FIRMS fire hotspots near a point         |
| `fireRisk(lat, lon, radiusKm)`                | Aggregated 0–100 fire risk score                     |
| `compare(lat, lon, cropIdA, cropIdB, season)` | Side-by-side comparison of two crops with a winner   |
| `alerts`                                      | Live agroclimatic alerts for 8 key LATAM zones       |
| `geocode(q, count)`                           | Place search for LATAM regions                       |
| `ragContext(query, limit)`                    | Semantic search over agroclimatic documents          |

For the full argument list, return types, and copy-paste examples for each query, see the [Query Reference](/api/graphql-queries).

## GraphiQL playground

Open `GET /graphql` in a browser to access the interactive GraphiQL IDE. It auto-completes field names and arguments, displays inline schema documentation, and lets you run queries against the live API without writing any code.

```text theme={null}
https://api.climatifai.com/graphql
```

## Basic usage

Send a `POST` request with `Content-Type: application/json` and a body containing your `query` string.

```bash cURL theme={null}
curl --request POST \
  --url "https://api.climatifai.com/graphql" \
  --header "Content-Type: application/json" \
  --data '{
    "query": "{ fireRisk(lat: 19.4326, lon: -99.1332, radiusKm: 100) { riskScore riskLabel hotspotCount } }"
  }'
```

```json Response theme={null}
{
  "data": {
    "fireRisk": {
      "riskScore": 42.7,
      "riskLabel": "Medio",
      "hotspotCount": 5
    }
  }
}
```
