All Collections
For Developers
SportsEngine API
Completing Your First GraphQL Query
Completing Your First GraphQL Query

After authenticating, you can retrieve data from SportsEngine's GraphQL API by completing your first query.

Updated over a week ago

Queries can return:

  • A specific object by ID

  • A list of objects using optional filters

Let's start with a list, dig into querying by a specific ID, and finish with navigating nested queries.

All GraphQL requests are POST with the query contained in the request body.

Query Lists with Pagination

Let's build the first pagination query to retrieve a list of organizations that have given you API access. There are three areas of the query to focus on:

  • Query Variables: Located at the top of the query, you set filters and pagination options.

  • Page Information: For these types of queries, copy/paste in this section. Page information shows objects returned in the query response.

  • Results: Define the data attributes that you want back on each object.

Helpful Tip! A best practice is to request pagination and page size attributes or page information.

Page size is defaulted to page 1, with 25 items per page and a maximum of 100 items per page. This info will show by default even without page information.

To adjust a query’s page information, include the values as variables at the beginning of the query. The response page information summarizes how many pages and the object count in the response. In the example below, we are querying for the ID and name of the first 50 accessible organizations.

query organizations { 
organizations(page: 1, perPage: 50) {
pageInformation {
pages
count
page
perPage
}
results {
id
name
}
}
}

You can see in the page information there are two organizations in the results. It is important to note that the request will show no data if you don’t include a results section with an attribute.

{ 
"data": {
"organizations": {
"pageInformation": {
"pages": 1,
"count": 2,
"page": 1,
"perPage": 50
},
"results": [
{
"id": “12345”,
"name": "Club Demo #1"
},
{
"id": “67890”,
"name": "Club Demo #3"
}
]
}
}
}

Query a Specific ID

Once you have an object’s SportsEngine ID, it is easiest to query using it in the future. This is especially helpful if you receive webhooks for an object.

The example below contains an Org ID from one of the above organizations.

Request:

query organization { 
organization(id: 22518) {
id
acronym
name
sports
}
}

Response:

{ 
"data": {
"organization": {
"id": "12345",
"acronym": "CD1",
"name": "Club Demo #1",
"sports": [
"Volleyball",
"Beach Volleyball"
]
}
}
}

To minimize query complexity and prevent query loops with circular references, some attributes are only available when querying by a specific ID. See the schema documentation at https://dev.sportsengine.com/explorer for more information.

Nested Query with Pagination

Some queries contain nested queries that have their page information values. Each nested query page information uses the default page of 1 and a per page of 25 unless specified.

query Organizations { 
organizations(perPage: 100, page: 1) {
pageInformation {
pages
count
page
perPage
}
results {
id
name
registrations(page: 5, perPage: 50) {
name
id
}
}
}
}

To successfully paginate this query, first loop through registrations for an organization. Then, rinse and repeat for each organization in the list.

Did this answer your question?