Skip to main content

Data arrays

The examples on syntax page describe how to retrieve data for a single instrument. This method may be inconvenient when it comes to obtaining the same type of data for a large number of tools at once. For this purpose, the GraphQL API has interfaces for obtaining data arrays.


Available interfaces

Specific interfaces are used to obtain data arrays for multiple instruments at once: instruments, bonds, derivatives and stocks.

Example from schema

type Query {
instruments(
includeOld: Boolean! = false
includeNonBaseBoards: Boolean! = false
first: Int
after: String
last: Int
before: String
where: InstrumentModelFilterInput
order: [InstrumentModelSortInput!]
): InstrumentsConnection
bonds(
includeOld: Boolean! = false
includeNonBaseBoards: Boolean! = false
first: Int
after: String
last: Int
before: String
where: BondFilterInput
order: [BondSortInput!]
): BondsConnection
derivatives(
includeOld: Boolean! = false
includeNonBaseBoards: Boolean! = false
first: Int
after: String
last: Int
before: String
where: DerivativeFilterInput
order: [DerivativeSortInput!]
): DerivativesConnection
stocks(
includeOld: Boolean! = false
includeNonBaseBoards: Boolean! = false
first: Int
after: String
last: Int
before: String
where: StockFilterInput
order: [StockSortInput!]
): StocksConnection
}

Interface arguments are used for pagination, sorting and filtering of received data. More details about them in the corresponding articles.


Sending requests

The instruments, bonds, derivatives, and stocks fields are redirected to the same interfaces that are used to retrieve data on an individual instrument (Instrument, Bond, Derivative, and Stock), but combined into nodes. Thus, the body of the operation is similar to the examples above, only lengthened by one path field:

Request example
{
instruments {
nodes {
basicInformation {
symbol
exchange
description
shortName
type
market
}
}
}
}

As a response, the system will return a list of the first 10 instruments with the actual values of the data fields specified in the operation.


Increasing selection

To get a different number of objects, use one of the two arguments of the path root field:

  • first - returns the first N objects from the beginning of the total list
  • last - returns the first N objects from the end of the total list

Both arguments expect a value in Int format and are mutually exclusive, so only one of them can be stated in a single operation simultaneously.

Request example
{
instruments(first: 50) {
nodes {
basicInformation {
symbol
exchange
description
shortName
type
market
}
}
}
}

n response, the system will return the first 50 records from the beginning of the total list instead of the standard 10.


Edges and nodes

All fields in the examples above are grouped into nodes, which are interacted with. Referring to a node allows you to get data in arrays without having to specify each instrument of interest separately. However, nodes are not the highest level of field aggregation, as they themselves are part of the edges, which include fields and arguments for further filtering, sorting and pagination of the obtained data.

The proper way to construct a query with an allowance for further operations with the returned data is to add the edges path field between the root path field and the nodes included in it to the already known structure:

Request example
{
instruments {
edges {
node {
basicInformation {
symbol
exchange
description
shortName
type
market
}
}
}
}
}

The response from the system to a request in its current form is no different from example above, but this structure opens up possibilities for further transformation of the responses received.


What's next?

Additionally, we recommend reading the following related articles: