NextSchoolNextSchool Data API

Making Requests

How to structure GraphQL requests to the NextSchool Data API

Making Requests

All API interactions use a single endpoint with GraphQL.

Endpoint

EnvironmentURL
ProductionPOST https://data.nextschool.io/
SandboxPOST https://sandbox.nextschool.io/

Required Headers

HeaderValueRequired
Content-Typeapplication/jsonYes
AuthorizationBearer <access_token>Yes (for data queries)

Request Format

Every request is a POST with a JSON body containing:

{
  "query": "your GraphQL query or mutation",
  "variables": {}
}

Queries vs Mutations

Queries read data:

query {
  students(limit: 10) {
    id
    fullName
  }
}

Mutations perform actions (login, logout, etc.):

mutation {
  login(username: "user", password: "pass") {
    accessToken
  }
}

Using Variables

Instead of inline arguments, use variables for cleaner queries:

{
  "query": "query GetStudents($limit: Int, $search: String) { students(limit: $limit, search: $search) { id fullName } }",
  "variables": {
    "limit": 10,
    "search": "สมชาย"
  }
}

Pagination

Use limit and offset for pagination:

# Page 1 (first 20 results)
{ students(limit: 20, offset: 0) { id fullName } }

# Page 2 (next 20 results)
{ students(limit: 20, offset: 20) { id fullName } }

# Page 3
{ students(limit: 20, offset: 40) { id fullName } }

Response Format

Successful response:

{
  "data": {
    "students": [
      { "id": 1, "fullName": "เด็กชายสมชาย ใจดี" }
    ]
  }
}

Error response:

{
  "errors": [
    {
      "message": "Authentication required",
      "extensions": {
        "code": "UNAUTHENTICATED"
      }
    }
  ]
}

Field Selection

With GraphQL, you request only the fields you need. This reduces response size and improves performance:

# Minimal — just names
{ students(limit: 10) { id fullName } }

# Detailed — include all info
{
  students(limit: 10) {
    id
    code
    fullName
    classroomName
    gender
    dob
    mobileNo
    status
    statusText
    imageURI
  }
}

On this page