NextSchoolNextSchool Data API

Login

Authenticate with the API to get access and refresh tokens

Login

curl -X POST https://data.nextschool.io/ \
  -H "Content-Type: application/json" \
  -d '{
    "query": "mutation { login(username: \"your_username\", password: \"your_password\") { accessToken refreshToken expiresIn } }"
  }'
const response = await fetch('https://data.nextschool.io/', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    query: `mutation {
      login(username: "your_username", password: "your_password") {
        accessToken
        refreshToken
        expiresIn
      }
    }`
  })
});
const { data } = await response.json();
console.log(data.login.accessToken);
import requests

response = requests.post('https://data.nextschool.io/', json={
    'query': '''mutation {
        login(username: "your_username", password: "your_password") {
            accessToken
            refreshToken
            expiresIn
        }
    }'''
})
data = response.json()['data']['login']
print(data['accessToken'])
<?php
$ch = curl_init('https://data.nextschool.io/');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS => json_encode([
        'query' => 'mutation {
            login(username: "your_username", password: "your_password") {
                accessToken refreshToken expiresIn
            }
        }'
    ]),
    CURLOPT_RETURNTRANSFER => true,
]);
$result = json_decode(curl_exec($ch), true);
$accessToken = $result['data']['login']['accessToken'];
body, _ := json.Marshal(map[string]string{
    "query": `mutation {
        login(username: "your_username", password: "your_password") {
            accessToken refreshToken expiresIn
        }
    }`,
})
req, _ := http.NewRequest("POST", "https://data.nextschool.io/", bytes.NewBuffer(body))
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()

var result map[string]any
json.NewDecoder(resp.Body).Decode(&result)
let client = reqwest::Client::new();
let resp = client.post("https://data.nextschool.io/")
    .header("Content-Type", "application/json")
    .json(&serde_json::json!({
        "query": r#"mutation {
            login(username: "your_username", password: "your_password") {
                accessToken refreshToken expiresIn
            }
        }"#
    }))
    .send().await?
    .json::<serde_json::Value>().await?;

let access_token = resp["data"]["login"]["accessToken"].as_str().unwrap();

On this page