Categories, Tags, and Collections (GQL)

Programmatically create, read, update, and delete categories, tags, and collections using the GraphQL Platform API.

Get category details

This query obtains information similar to that displayed on the Categories tab of the Admin Panel.

query categories(
  $where: CategoryWhereInput
  $orderBy: CategoryOrderByInput
  $pagination: PaginationInput
) {
  categoriesV2(where: $where, orderBy: $orderBy, pagination: $pagination) {
    nodes {
      id
      name
      slugifiedName
      status
      shortDescription
      longDescription
      thumbnail
      pageTitle
      weight
      createdAt
      updatedAt
      deletedAt
    }
    edges {
      node {
        id
      }
      cursor
    }
    pageInfo {
      hasNextPage
      hasPreviousPage
      startCursor
      endCursor
    }
  }
}
{
  "where": {
    "language": "EN_US"
  },
  "orderBy": {
    "fields": {
      "fieldName": "NAME",
      "by": "DESC"
    }
  },
  "pagination": {
    "first": 3
  }
}

Create a category

This mutation creates a category similarly to creating a category using the Categories tab of the Admin Panel.

mutation createCategory($category: CategoryCreateInput!) {
  createCategory(category: $category) {
    id
    thumbnail
    weight
    longDescription
    shortDescription
    name
  }
}
{
  "category": {
    "information": [
      {
        "name": "Example category",
        "language": "EN_US",
        "longDescription": "**Long** description.",
        "shortDescription": "Short description"
      }
    ],
    "thumbnail": "https://rapidapi-prod-collections.s3.amazonaws.com/category/data.png",
    "weight": 5
  }
}

Update a category

This mutation updates a category similarly to updating a category using the Categories tab of the Admin Panel. The category's id can be obtained from the categoriesV2 query shown above.

mutation updateCategory($category: CategoryUpdateInput!) {
  updateCategory(category: $category) {
    id
    thumbnail
    weight
    longDescription
    shortDescription
    name
  }
}
{
  "category": {
    "id": "category_e31a40fb-9763-4bfc-95a8-0301a0d82100",
    "information": [
      {
        "name": "Example category",
        "language": "EN_US",
        "longDescription": "**Long** description updated.",
        "shortDescription": "Short description"
      }
    ],
    "thumbnail": "https://rapidapi-prod-collections.s3.amazonaws.com/category/data.png",
    "weight": 5,
    "color": null
  }
}

Delete a category

This mutation deletes a category. The category's id can be obtained from the categoriesV2 query shown above.

mutation deleteCategories($categories: [ID!]!) {
  deleteCategories(categories: $categories) {
    id
    deleted
  }
}
{
  "categories": [
    "category_e31a40fb-9763-4bfc-95a8-0301a0d82100"
  ]
}

Get tag definitions

This query obtains information similar to that displayed on the Tags tab of the Admin Panel.

query tagDefinitions{
  tagDefinitions {
    edges {
      node {
        id
        color
        description
        status
        type
        name
        values
        editableByProvider
        forceEnumValidation
        isVisible
        requiredOnAPI
        showTagName
        createdAt
        updatedAt
      }
      cursor
    }
    pageInfo {
      hasNextPage
      hasPreviousPage
      startCursor
      endCursor
    }
    nodes {
      id
      color
      description
      status
      type
      name
      values
      editableByProvider
      forceEnumValidation
      isVisible
      requiredOnAPI
      showTagName
      createdAt
      updatedAt
    }
  }
}

Delete tag definition

In the variables, specify the tag id as defined in query.tagDefinitions above.

mutation deleteTagDefinition($id: ID!) {
  deleteTagDefinition(id: $id)
}
{
  "id": "tagdefinition_e6a65f62-811e-4ad6-884d-6a05554ca54f"
}

Get collections

This query obtains information similar to that displayed on the Collections tab of the Admin Panel.

query getCollections($order: CollectionsOrderByInput) {
  collections(orderBy: $order) {
    data {
      id
      title
      apis {
        id
      }
      shortDescription
      longDescription
      thumbnail
      weight
      brand
    }
    total
  }
}
{
  "order": {
    "sortingFields": [
      {
        "fieldName": "weight",
        "order": "ASC"
      }
    ]
  }
}

Create a collection

This mutation creates a collection similarly to creating a collection using the Collections tab of the Admin Panel. If your collection will include a Spotlight, use the createSpotlight mutation before calling createCollection.

mutation createCollection($input: CollectionCreateInput!) {
  createCollection(input: $input) {
    id
  }
}
{
  "input": {
    "title": "Example Collection",
    "apis": [
      "api_05433514-c272-4a59-a4f1-6cd281032c1a",
      "collectionspotlight_7580bb7c-cc9a-4a70-a5fb-26cac50284f6"
    ],
    "weight": 4,
    "shortDescription": "Collection description",
    "longDescription": "**Long** description."
  }
}

Update a collection

This mutation updates a collection similarly to updating a collection using the Collections tab of the Admin Panel. The collection's id can be obtained from the collections query shown above.

mutation updateCollections($collections: [UpdateCollectionsInput]!) {
  updateCollections(collections: $collections) {
    id
    title
    apis {
      id
    }
    shortDescription
    longDescription
    thumbnail
    weight
    brand
  }
}
{
  "input": {
    "id": "collection_9b1e90c3-7f3f-42c1-ad9a-99cf4ed4a808",
    "title": "Example Collection",
    "apis": [
      "api_05433514-c272-4a59-a4f1-6cd281032c1a",
      "collectionspotlight_7580bb7c-cc9a-4a70-a5fb-26cac50284f6"
    ],
    "shortDescription": "Collection description",
    "longDescription": "**Long** description updated.",
    "thumbnail": null,
    "weight": 4
  }
}

Delete a collection

This mutation deletes a collection. The collection's id can be obtained from the collections query shown above.

mutation deleteCollection($id: ID!) {
  deleteCollection(id: $id)
}
{
  "id": "collection_9b1e90c3-7f3f-42c1-ad9a-99cf4ed4a808"
}