Fetch Learning Blocks

Learning Blocks

GraphQL API documentation for fetching states and learning blocks data

Endpoint

GraphQL endpoint: https://api.edupaid.2hourlearning.com/functions/v1/graphql

Authentication

The API requires a Bearer token in the Authorization header.

Authorization: Bearer <access_token>

States Query Example


// Make the GraphQL request
const response = await fetch("https://api.edupaid.2hourlearning.com/functions/v1/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${accessToken}`
  },
  body: JSON.stringify({
    query: `
      query GetStates {
        statesCollection {
          edges {
            node {
              id
              name
              code
            }
          }
        }
      }
    `
  })
})

Learning Blocks Query Example


// Make the GraphQL request
const response = await fetch("https://api.edupaid.2hourlearning.com/functions/v1/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${accessToken}`
  },
  body: JSON.stringify({
    query: `
      query GetLearningBlocks($stateId: UUID) {
        learning_blocksCollection(
          filter: {fundingSource: {state: {id: {eq: $stateId}}}}
        ) {
          edges {
            node {
              id
              name
              grade
              amount
              academicYear
              fundingSource {
                state {
                  name
                }
              }
            }
          }
        }
      }
    `,
    variables: {
      stateId: "your-state-id" // Optional: only include if filtering by state
    }
  })
})

Response Fields

States

  • id: Unique identifier for the state

  • name: Full name of the state

  • code: Two-letter state code

Learning Blocks

  • id: Unique identifier for the learning block

  • name: Name of the learning block

  • grade: Grade level

  • amount: Funding amount

  • academicYear: Academic year

  • fundingSource.state.name: State name

Usage Notes

  • State filtering is optional for the learning blocks query

  • Results are paginated using GraphQL edges/nodes pattern

  • All requests must be authenticated

  • The API follows standard GraphQL conventions

Last updated