vscgames
  • Welcome
  • Getting Started
    • CreateAPIKey
    • CreateMerchantKey
  • Products
  • Mutations
    • buyVoucher
    • FreeFireTopupOrder
    • DeltaForceTopupOrder
    • FreeFireMerchantTopup
    • DeltaForceMerchantTopupOrder
  • Queries
    • getProductsByCategory
    • getProductById
    • getOrderById
    • getUserOrders
    • getTopupsProducts
    • getTopupProduct
    • getPlayerDetails
    • getTopupOrder
    • getUserTopupOrders
  • REST API
    • COMING soon
  • CONTACT
    • Support
Powered by GitBook
On this page
  1. Queries

getProductsByCategory

Last Updated 11th May, 2025

This query returns all products that belong to a specific category based on the provided categoryid. It fetches directly from the database using the Product collection.


๐Ÿ”— Endpoint

  • URL: https://api.vscgames.com/graphql

  • Method: POST

  • Content-Type: application/json


๐Ÿ“– GraphQL Query

graphqlCopyEditquery getProductsByCategory($categoryid: String!) {
  getProductsByCategory(categoryid: $categoryid) {
    _id
    name
    price
    categoryid
  }
}

๐Ÿง  Note: This query only matches documents where categoryid equals the provided value. The data is returned as an array of product objects.


๐Ÿ“ฅ Parameters

Name
Type
Required
Description

categoryid

String

โœ… Yes

The unique ID of the product category


โœ… Example Response

jsonCopyEdit{
  "data": {
    "getProductsByCategory": [
      {
        "_id": "64ff86c1b879f5c87e9b9a7f",
        "name": "PUBG UC 60",
        "price": 0.99,
        "categoryid": "fps-topups"
      }
    ]
  }
}

๐Ÿงช Code Samples

Python

pythonCopyEditimport requests

url = "https://api.vscgames.com/graphql"
headers = {"Content-Type": "application/json"}
query = '''
query getProductsByCategory($categoryid: String!) {
  getProductsByCategory(categoryid: $categoryid) {
    _id
    name
    price
    categoryid
  }
}
'''
variables = {"categoryid": "fps-topups"}

response = requests.post(url, json={"query": query, "variables": variables}, headers=headers)
print(response.json())

JavaScript

javascriptCopyEditconst fetch = require("node-fetch");

const query = `
query getProductsByCategory($categoryid: String!) {
  getProductsByCategory(categoryid: $categoryid) {
    _id
    name
    price
    categoryid
  }
}`;

const variables = { categoryid: "fps-topups" };

fetch("https://api.vscgames.com/graphql", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ query, variables })
})
  .then(res => res.json())
  .then(data => console.log(data));
PreviousDeltaForceMerchantTopupOrderNextgetProductById

Last updated 23 days ago