Getting Started
Last updated
Last updated
The GraphQL API can be queried either through a GUI interface or programmatically.
The Graphical User Interface maintained at is a great way to get started using the API and learning its syntax, as well as for quick lookups.
The Docs
section in the top right-hand corner contains the full schema for the API, and the code editor will auto-complete.
Example query on the hero
object:
Note that the GraphQL server has a recursion limit on accessing object type subfields, in most cases limited to 3 levels of depth.
All top-level query fields take arguments, set by the particular field. Every operation has two varieties: one that returns a single result and one that returns multiple results (e.g. hero
/heroes
, saleAuction
/saleAuctions
).
These fields only take a single argument:
id
: Int
/String
- the id of the Hero
, Auction
, Pet
, or Profile
.
These fields take any of the following optional arguments:
first
: Int
- the number of requested results. Default: 1000
; Max: 1000
.
skip
: Int
- skip the first x results. Default: 0
. Use to iterate beyond the 1000 result maximum per query.
orderBy
: Subfield
- the subfield to order results by. Default: id
.
orderDirection
: asc
/desc
- the order direction of the results. Default: asc
.
Example: a heroes
query using default arguments
The optional where
argument on a multi-result query allows for a high degree of flexibility. Any number of field/value pairs can be added to the array, with optional operators using the following syntax: field_operator: value
.
[none
] - equal to
_not
- not equal to
_gt
- greater than
_gte
- greater than or equal to
_lt
- less than
_lte
- less than or equal to
_in
- found in [List]
_not_in
- not found in [List]
Example: the Top 5 Ninja/Thief Heroes with the Fishing gene (ordered descending by Fishing skill)
To add a variable to a query, three things are required:
Replace the static value in the query with $variableName
Declare $variableName
as one of the variables accepted by the query and assign it a type (e.g. ID
, Int
, String
, Boolean
)
Pass variableName: value
in a separate variables dictionary
The example above also includes an expanded syntax beginning with the query
operation type, and a user-declared operation name (getHero
) for the function. The operation type is required to use variables, while the operation name is optional.
Using an alias allows you to include the same field type in your query multiple times with different arguments.
Example: a single query that separately returns Pets hatched from Blue and Grey Eggs, respectively.
Fragments allow you to reuse the same subfields on multiple operations in a single query, without having to re-type them for each instance.
Example: expanding on the previous query to request a range of fields for each operation.
Basic query implementation using the library.
Basic query implementation using the library.
where
: {ObjectArray
} - Adds a to the results.
For more on Aliases, Fragments, and other advanced syntax like Mutations and Directives, see the .