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));

Last updated