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

getProductById

Last Updated 11th May, 2025

The getProductById query fetches a single product using its unique productid. If the product does not exist, it throws an error.


๐Ÿ”— Endpoint

URL: https://api.vscgames.com/graphql Method: POST Content-Type: application/json


๐Ÿ” Query Structure

query getProductById($productid: String!) {
  getProductById(productid: $productid) {
    _id
    name
    price
    categoryid
  }
}

๐Ÿ“ฅ Parameters

Name
Type
Required
Description

productid

String

โœ… Yes

The unique ID of the product


โœ… Successful Response

{
  "data": {
    "getProductById": {
      "_id": "prd123",
      "name": "Free Fire 110 Diamonds",
      "price": 1.99,
      "categoryid": "cat001"
    }
  }
}

๐Ÿšซ Error Response

If the product ID is not found in the database:

{
  "errors": [
    {
      "message": "Product not found",
      "path": ["getProductById"]
    }
  ]
}

๐Ÿงช Code Examples

Python

import requests

url = "https://api.vscgames.com/graphql"
headers = {"Content-Type": "application/json"}

query = """
query getProductById($productid: String!) {
  getProductById(productid: $productid) {
    _id
    name
    price
    categoryid
  }
}
"""

variables = {
  "productid": "prd123"
}

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

JavaScript

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

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

const variables = {
  productid: "prd123"
};

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

Last updated 23 days ago