For Developers

API Quickstart

This guide will teach you how to set up a quick Node.js application to load a list of schools and the students that belong to them. This guide requires a basic understanding of Node.js and the Javascript language.

Don't use NodeJS? Just want to test out some requests? Check out our Postman Collection.

Get an Access Token

Each Integration has its own integration access token that can be used to access the Edlink Graph API for a particular institution. Open the integration you want to view data for in the Edlink Dashboard, and find the Access Token field under the Summary tab. Keep this token on hand for the next steps.

Configure Axios to Make Requests

We'll configure axios to make the request. Axios is a popular npm package we use in most of our docs.

Once we've configured everything we need, we can make some requests. We're going to use pagination to fetch all of the schools stored for this integration in Edlink.

// Import the axios package
const axios = require('axios');

// You should set this variable to your access token from step 1
const access_token = '...';

// Create our request configuration
const config = {
    headers: {
        Authorization: `Bearer ${access_token}`
    }
};

// Create an array to store the schools we find
const schools = [];

// This field will hold the url for our next request
// We'll get 10000 items at a time for maximum efficiency
let url = 'https://ed.link/api/v2/graph/schools?$first=10000';

// While our url is not undefined or empty
while (url) {
    // Wait for the result of the api call to Edlink
    const result = await axios.get(url, config).then((res) => res.data);

    // Push all of the resulting data to our schools array
    schools.push(...result.$data);

    // Set the url variable so we get the next page on the next loop
    // (If $next is undefined, our pagination is over & the loop will end)
    url = result.$next;
}

// Print out how many schools we found
console.log(schools.length);

Now that we've assembled a list of all the schools, we can build a list of students for each of them.

// For every school that we found
for (const school of schools) {
    // Print out the name of the school
    console.log(school.name);

    // This field will hold the url for our next request
    // We'll get 10000 items at a time for maximum efficiency
    let url = `https://ed.link/api/v2/graph/schools/${school.id}/students?$first=10000`;

    // While our url is not undefined or empty
    while (url) {
        // Wait for the result of the api call to Edlink
        const result = await axios.get(url, config).then((res) => res.data);

        // Print out the display names of the students
        for (const student of result.$data) {
            console.log(` - ${student.display_name}`);
        }

        // Set the url variable so we get the next page on the next loop
        // If $next is undefined, our pagination is over & the loop will end
        url = result.$next;
    }
}

Where to Go From Here

Now that you have the basics down, check out some other guides on API features and functionality.