This
The following video explains how to access SL1 data with GraphQL:
This
What is GraphQL?
GraphQL is a data query and manipulation language for application programming interfaces (APIs) and a server-side runtime for executing queries and mutations with your data. It lets you define the exact data that you want to fetch from the API and, unlike REST, enables you to retrieve data from multiple sources in a single query.
GraphQL—sometimes abbreviated "GQL"—has two main operation types that are used in SL1:
- Queries, which read and return data
- Mutations, which write and modify data
Typically used over HTTP, GraphQL lets you make a POST request using a JSON structure to an HTTP endpoint on your server; the server then processes the request, calls the database or other source to fetch the requested data, and then returns the data to you in the same JSON structure as your request.
GraphQL is data source-agnostic. This means it can query data from any source: Databases, REST APIs, microservices, flat files, or even other GraphQL servers.
For more information about GraphQL, see the GraphQL documentation.
How Does SL1 Use GraphQL?
The SL1 GraphQL API allows external systems to programmatically access data in SL1 using the GraphQL query language. The API gives access to entities in the platform, such as devices and collected data, using standard HTTP request/response protocols.
The current SL1 user interface, also referred to as "AP2", uses GraphQL exclusively to request and access SL1 data from multiple sources and consolidate it together into a unified JSON response. The current SL1 user interface does not make any REST API calls.
Authentication and User Access
The SL1 GraphQL API uses the same authentication profiles and credentials as SL1. When you log in to SL1, you are also authenticated in the SL1 GraphQL API. It does not require an additional login.
All users have access to the SL1 GraphQL API—not only administrators—but users' ability to perform actions in GraphQL is controlled in the same way as in other parts of SL1:
- A user can interact only with entities associated with their organizations. Entities are either explicitly aligned with organizations, aligned with organizations based on the user that created the entity, or are not aligned with an organization.
- Administrator users can perform all actions on all resources, regardless of organization membership.
- A user must be granted the appropriate access keys to interact with specific parts of SL1 or perform specific actions in SL1.
To access GraphQL:
- In your web browser, type the URL or IP address for SL1.
- Sign in to SL1 using your regular user credentials.
- After you have signed in to SL1, type /gql at the end of the URL or IP address that appears in the address bar. The GraphiQL user interface appears.
You might need to type your credentials again to access the GraphiQL user interface.
The GraphiQL User Interface
GraphiQL is a browser-based user interface for interactively exploring the capabilities of, and executing queries against, a GraphQL API. Unlike the SL1 REST API, all requests to the GraphQL API on a given SL1 system use the same URI.
To access the GraphiQL interface, type the URL or IP address for SL1 in a browser, add /gql to the end of the URL or IP address, and press .
GraphiQL is not maintained by ScienceLogic. You can access its documentation at https://github.com/graphql/graphiql.
For more information about using GraphiQL, see the