Modern GraphQL API for Client St0r, providing flexible and efficient data querying alongside the REST API v1.
POST /api/v2/graphql/
Visit http://your-domain/api/v2/graphql/playground/ for an interactive GraphQL IDE.
mutation {
tokenAuth(username: "your_username", password: "your_password") {
token
refreshToken
}
}Include the token in headers:
Authorization: JWT your-token-here
query {
me {
id
username
email
firstName
lastName
}
}query {
organizations {
edges {
node {
id
name
memberCount
assetCount
passwordCount
}
}
}
}query {
assets(organization: 1, isActive: true, name_Icontains: "server") {
edges {
node {
id
name
assetType {
name
}
manufacturer
model
serialNumber
organization {
name
}
}
}
}
}query {
documents(title_Icontains: "network", organization: 1) {
edges {
node {
id
title
category {
name
}
createdAt
updatedAt
}
}
}
}query {
expiringSoon(days: 30) {
id
name
type
expirationDate
daysUntilExpiry
organization {
name
}
}
}query {
dashboardStats {
totalOrganizations
totalAssets
totalPasswords
totalDocuments
totalDiagrams
activeMonitors
}
}mutation {
createAsset(
name: "New Server"
assetTypeId: 1
organizationId: 1
manufacturer: "Dell"
model: "PowerEdge R740"
serialNumber: "ABC123"
description: "Production web server"
) {
success
errors
asset {
id
name
serialNumber
}
}
}mutation {
updateAsset(
id: 123
name: "Updated Server Name"
description: "Updated description"
isActive: true
) {
success
errors
asset {
id
name
description
}
}
}mutation {
deleteAsset(id: 123) {
success
errors
}
}mutation {
createDocument(
title: "Network Documentation"
content: "Complete network topology and configuration details..."
organizationId: 1
categoryId: 5
) {
success
errors
document {
id
title
createdAt
}
}
}query {
organizations {
edges {
node {
id
name
assets {
edges {
node {
name
assetType {
name
}
}
}
}
passwords {
totalCount
}
documents {
totalCount
}
}
}
}
}query {
assets(first: 10, after: "cursor-here") {
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
edges {
cursor
node {
id
name
}
}
}
}query {
assets(
organization: 1
assetType: 2
isActive: true
name_Icontains: "server"
orderBy: "-created_at"
) {
edges {
node {
id
name
createdAt
}
}
}
}exact: Exact matchiexact: Case-insensitive exact matchcontains: Contains substringicontains: Case-insensitive containsstartswith: Starts withistartswith: Case-insensitive starts withendswith: Ends withiendswith: Case-insensitive ends with
exact: Exact matchlt: Less thanlte: Less than or equalgt: Greater thangte: Greater than or equal
exact: true or false
exact: Exact datelt: Before datelte: Before or on dategt: After dategte: After or on dateyear: Yearmonth: Monthday: Day
Get the complete schema:
query {
__schema {
types {
name
description
}
}
}Get type details:
query {
__type(name: "AssetType") {
name
fields {
name
type {
name
}
}
}
}Errors are returned in a structured format:
{
"data": null,
"errors": [
{
"message": "Authentication required",
"locations": [{"line": 2, "column": 3}],
"path": ["assets"]
}
]
}- Authenticated: 1000 requests per hour
- Unauthenticated: 100 requests per hour
# ✅ Good - Request specific fields
query {
assets {
edges {
node {
id
name
}
}
}
}
# ❌ Bad - Requesting everything
query {
assets {
edges {
node {
id
name
description
serialNumber
manufacturer
model
... # All fields
}
}
}
}fragment AssetDetails on AssetType {
id
name
manufacturer
model
serialNumber
}
query {
asset(id: 1) {
...AssetDetails
}
}query {
assets: assets(first: 10) {
edges {
node {
id
name
}
}
}
documents: documents(first: 10) {
edges {
node {
id
title
}
}
}
}query GetAsset($id: Int!) {
asset(id: $id) {
id
name
description
}
}
# Variables
{
"id": 123
}npm install @apollo/client graphqlimport { ApolloClient, InMemoryCache, gql } from '@apollo/client';
const client = new ApolloClient({
uri: 'https://your-domain/api/v2/graphql/',
cache: new InMemoryCache(),
headers: {
Authorization: `JWT ${token}`
}
});
const GET_ASSETS = gql`
query {
assets {
edges {
node {
id
name
}
}
}
}
`;
client.query({ query: GET_ASSETS })
.then(result => console.log(result));pip install gql[all]from gql import gql, Client
from gql.transport.requests import RequestsHTTPTransport
transport = RequestsHTTPTransport(
url='https://your-domain/api/v2/graphql/',
headers={'Authorization': f'JWT {token}'}
)
client = Client(transport=transport, fetch_schema_from_transport=True)
query = gql('''
query {
assets {
edges {
node {
id
name
}
}
}
}
''')
result = client.execute(query)
print(result)Real-time updates using WebSocket subscriptions:
subscription {
assetUpdated {
id
name
updatedAt
}
}| REST API v1 | GraphQL API v2 |
|---|---|
GET /api/v1/assets/ |
query { assets { ... } } |
GET /api/v1/assets/:id/ |
query { asset(id: X) { ... } } |
POST /api/v1/assets/ |
mutation { createAsset(...) { ... } } |
PUT /api/v1/assets/:id/ |
mutation { updateAsset(id: X, ...) { ... } } |
DELETE /api/v1/assets/:id/ |
mutation { deleteAsset(id: X) { ... } } |
- Documentation: https://github.com/agit8or1/clientst0r/wiki/GraphQL-API
- Issues: https://github.com/agit8or1/clientst0r/issues
- Discussions: https://github.com/agit8or1/clientst0r/discussions