Stock Check By SKU API Documentation

Authentication

All API requests require authentication using a Bearer token. You can find your API key in your GMK Online account settings. If you do not have one you will need to contact the GMK sales office to set one up.

Header Format:

Authorization: Bearer your-api-key-here

Endpoints

Stock Query

POST /stock-query-by-sku/

Parameters

Name Type Required Description
skus array Yes* Array of product SKUs to check stock for (JSON encoded). Use this for multiple SKUs.
sku string Yes* Single product SKU to check stock for. Use this for single SKU lookup.
format string Yes Response format (json, xml, csv, text)

* Either 'skus' or 'sku' must be provided

Response Formats

{
    "status": "success",
    "data": [
        {
            "sku": "BAM-82099",
            "description": "Product Description",
            "stock_status": "In Stock",
            "quantity": 10,
            "timestamp": "2025-03-04T13:20:50Z",
            "last_updated": "2025-03-04 13:20:50"
        },
        {
            "sku": "BAM-82100",
            "description": "Another Product",
            "stock_status": "In Stock",
            "quantity": 5,
            "timestamp": "2025-03-04T13:20:50Z",
            "last_updated": "2025-03-04 13:20:50"
        }
    ]
}

<?xml version="1.0"?>
<stock>
    <status>success</status>
    <data>
        <sku>BAM-82099</sku>
        <description>BULLPUP BARREL WASHER MEDIUM 75</description>
        <stock-status>In Stock</stock-status>
        <quantity>10</quantity>
        <timestamp>2025-03-03T16:35:55Z</timestamp>
        <last_updated>2025-03-03 16:35:55</last_updated>
    </data>
</stock>

sku,description,stock-status,quantity,timestamp,last_updated
BAM-82099,"BULLPUP BARREL WASHER MEDIUM 75","In Stock",10,"2025-03-03T16:35:55Z","2025-03-03 16:35:55"

10

Example Request

curl -X POST https://api.gmk.co.uk/stock-query-by-sku/ \
    -H "Authorization: Bearer your-api-key-here" \
    -d "sku=BAM-82099&format=json"

Code Examples


$apiKey = 'your-api-key-here';
$sku = 'BAM-82099';

$ch = curl_init();
curl_setopt_array($ch, [
    CURLOPT_URL => 'https://api.gmk.co.uk/stock-query-by-sku/',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => http_build_query([
        'sku' => $sku,
        'format' => 'json'
    ]),
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . $apiKey
    ]
]);

$response = curl_exec($ch);
$data = json_decode($response, true);

if ($data['status'] === 'success') {
    $quantity = $data['data']['quantity'];
    echo "Stock level: " . $quantity;
}

curl_close($ch);

import requests

api_key = 'your-api-key-here'
sku = 'BAM-82099'

headers = {
    'Authorization': f'Bearer {api_key}'
}

data = {
    'sku': sku,
    'format': 'json'
}

response = requests.post(
    'https://api.gmk.co.uk/stock-query-by-sku/',
    headers=headers,
    data=data
)

if response.status_code == 200:
    data = response.json()
    if data['status'] == 'success':
        quantity = data['data']['quantity']
        print(f"Stock level: {quantity}")

const axios = require('axios');

const apiKey = 'your-api-key-here';
const sku = 'BAM-82099';

const data = new URLSearchParams();
data.append('sku', sku);
data.append('format', 'json');

axios.post('https://api.gmk.co.uk/stock-query-by-sku/', data, {
    headers: {
        'Authorization': `Bearer ${apiKey}`
    }
})
.then(response => {
    if (response.data.status === 'success') {
        const quantity = response.data.data.quantity;
        console.log(`Stock level: ${quantity}`);
    }
})
.catch(error => console.error('Error:', error));

using System;
using System.Net.Http;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text.Json;

class Program
{
    static async Task Main()
    {
        var apiKey = "your-api-key-here";
        var sku = "BAM-82099";

        using (var client = new HttpClient())
        {
            client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");

            var formData = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair("sku", sku),
                new KeyValuePair("format", "json"),
            });

            var response = await client.PostAsync(
                "https://api.gmk.co.uk/stock-query-by-sku/",
                formData
            );

            if (response.IsSuccessStatusCode)
            {
                var jsonString = await response.Content.ReadAsStringAsync();
                var data = JsonSerializer.Deserialize(jsonString);
                var quantity = data.RootElement
                    .GetProperty("data")
                    .GetProperty("quantity")
                    .GetInt32();
                
                Console.WriteLine($"Stock level: {quantity}");
            }
        }
    }

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;

public class StockCheck {
    public static void main(String[] args) {
        String apiKey = "your-api-key-here";
        String sku = "BAM-82099";

        String formData = String.format("sku=%s&format=json",
            URLEncoder.encode(sku, StandardCharsets.UTF_8));

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.gmk.co.uk/stock-query-by-sku/"))
            .header("Content-Type", "application/x-www-form-urlencoded")
            .header("Authorization", "Bearer " + apiKey)
            .POST(HttpRequest.BodyPublishers.ofString(formData))
            .build();

        try {
            HttpResponse response = client.send(request,
                HttpResponse.BodyHandlers.ofString());
            
            if (response.statusCode() == 200) {
                // Using any JSON library (e.g., Jackson, Gson)
                // Parse response and get quantity
                System.out.println("Response: " + response.body());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Error Responses

Authentication Error

{
    "status": "error",
    "message": "No valid Bearer token provided, see api.gmk.co.uk/documentation/stock-query-by-sku for more information"
}

Invalid Format

{
    "status": "error",
    "message": "Invalid format specified. Supported formats: json, xml, csv, text"
}
Test API
Enter multiple SKUs by putting each one on a new line