Sample code for 30+ languages & platforms
Zig

Shopware List Articles

See more Shopware Examples

This example shows you how to obtain information about a Shopware product list. With the optional limit parameter, it's possible to specify how many products you wish the API call to return.

Chilkat Zig Downloads

Zig
const std = @import("std");
const chilkat = @import("chilkat");

pub fn main(init: std.process.Init) !void {
    const alloc = init.arena.allocator();

    var success: bool = false;

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    const http = try chilkat.Http.init();
    defer http.deinit();

    http.setLogin("api_username");
    http.setPassword("api_key");
    http.setBasicAuth(true);

    const sb_response_body = try chilkat.StringBuilder.init();
    defer sb_response_body.deinit();
    http.quickGetSb("https://my-shopware-shop.com/api/articles?limit=2", sb_response_body) catch {
        std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
        return;
    };

    const j_resp = try chilkat.JsonObject.init();
    defer j_resp.deinit();
    j_resp.loadSb(sb_response_body) catch {};
    j_resp.setEmitCompact(false);

    std.debug.print("Response Body:\n", .{});
    std.debug.print("{s}\n", .{try j_resp.emit(alloc)});

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "data": [
    //     {
    //       "id": 8283,
    //       "mainDetailId": 11398,
    //       "supplierId": 28,
    //       "taxId": 1,
    //       "priceGroupId": 1,
    //       "filterGroupId": null,
    //       "configuratorSetId": null,
    //       "name": "TERRA PC-GAMER 8000 iQ9650 VU - \u00e5\u00a0  \u00c7  Produktmer",
    //       "description": "TERRA PC-GAMER 8000 iQ9650 VU - \u00e5\u00a0  \u00c7  Produktmer",
    //       "descriptionLong": "...",
    //       "added": "2000-01-01T00:00:00+0100",
    //       "active": true,
    //       "pseudoSales": 0,
    //       "highlight": false,
    //       "keywords": null,
    //       "metaTitle": "TERRA PC-GAMER 8000 iQ9650 VU - \u00e5\u00a0  \u00c7  Produktmer",
    //       "changed": "2021-02-21T18:20:39+0100",
    //       "priceGroupActive": false,
    //       "lastStock": false,
    //       "crossBundleLook": 0,
    //       "notification": true,
    //       "template": "",
    //       "mode": 0,
    //       "availableFrom": null,
    //       "availableTo": null,
    //       "mainDetail": {
    //         "id": 11398,
    //         "articleId": 8283,
    //         "unitId": 9,
    //         "number": "WT-1000104",
    //         "supplierNumber": "",
    //         "kind": 1,
    //         "additionalText": "",
    //         "active": true,
    //         "inStock": 28,
    //         "stockMin": null,
    //         "lastStock": false,
    //         "weight": "0.000",
    //         "width": null,
    //         "len": null,
    //         "height": null,
    //         "ean": "4039407005390",
    //         "purchasePrice": "0",
    //         "position": 1,
    //         "minPurchase": 1,
    //         "purchaseSteps": 0,
    //         "maxPurchase": 0,
    //         "purchaseUnit": "0.0000",
    //         "referenceUnit": "1.000",
    //         "packUnit": "Stk",
    //         "shippingFree": false,
    //         "releaseDate": null,
    //         "shippingTime": "20",
    //         "attribute": {
    //           "id": 11271,
    //           "articleDetailId": 11398,
    //           "attr1": null,
    //           "attr2": null,
    //           "attr3": null,
    //           "attr4": null,
    //           "attr5": null,
    //           "attr6": null,
    //           "attr7": null,
    //           "attr8": null,
    //           "attr9": null,
    //           "attr10": null,
    //           "attr11": "Attributfeld 11 deutsch",
    //           "attr12": null,
    //           "attr13": null,
    //           "attr14": "Wortmann - 80061",
    //           "attr15": null,
    //           "attr16": null,
    //           "attr17": "21.02.2021 18:36:46",
    //           "attr18": null,
    //           "attr19": "21.02.2021 18:36:46",
    //           "attr20": "0,00",
    //           "apostroph": ""
    //         }
    //       }
    //     },
    //     {
    //       "id": 8284,
    //       "mainDetailId": 11399,
    //       "supplierId": 28,
    //       "taxId": 1,
    //       "priceGroupId": 1,
    //       "filterGroupId": null,
    //       "configuratorSetId": null,
    //       "name": "TERRA PC-GAMER 9000 iE5420 VU\rProduktmer",
    //       "description": "TERRA PC-GAMER 9000 iE5420 VU\rProduktmer",
    //       "descriptionLong": "...",
    //       "added": "2000-01-01T00:00:00+0100",
    //       "active": true,
    //       "pseudoSales": 0,
    //       "highlight": false,
    //       "keywords": null,
    //       "metaTitle": "TERRA PC-GAMER 9000 iE5420 VU\rProduktmer",
    //       "changed": "2021-02-21T18:20:35+0100",
    //       "priceGroupActive": false,
    //       "lastStock": true,
    //       "crossBundleLook": 0,
    //       "notification": true,
    //       "template": "",
    //       "mode": 0,
    //       "availableFrom": null,
    //       "availableTo": null,
    //       "mainDetail": {
    //         "id": 11399,
    //         "articleId": 8284,
    //         "unitId": 9,
    //         "number": "WT-1000105",
    //         "supplierNumber": "",
    //         "kind": 1,
    //         "additionalText": "",
    //         "active": true,
    //         "inStock": 0,
    //         "stockMin": null,
    //         "lastStock": true,
    //         "weight": "0.000",
    //         "width": null,
    //         "len": null,
    //         "height": null,
    //         "ean": "4039407006137",
    //         "purchasePrice": "0",
    //         "position": 1,
    //         "minPurchase": 1,
    //         "purchaseSteps": 0,
    //         "maxPurchase": 0,
    //         "purchaseUnit": "0.0000",
    //         "referenceUnit": "1.000",
    //         "packUnit": "Stk",
    //         "shippingFree": false,
    //         "releaseDate": null,
    //         "shippingTime": "20",
    //         "attribute": {
    //           "id": 11272,
    //           "articleDetailId": 11399,
    //           "attr1": null,
    //           "attr2": null,
    //           "attr3": null,
    //           "attr4": null,
    //           "attr5": null,
    //           "attr6": null,
    //           "attr7": null,
    //           "attr8": null,
    //           "attr9": null,
    //           "attr10": null,
    //           "attr11": "Attributfeld 11 deutsch",
    //           "attr12": null,
    //           "attr13": null,
    //           "attr14": "Wortmann - 80061",
    //           "attr15": null,
    //           "attr16": null,
    //           "attr17": "21.02.2021 18:36:50",
    //           "attr18": null,
    //           "attr19": "21.02.2021 18:36:50",
    //           "attr20": "0,00",
    //           "apostroph": ""
    //         }
    //       }
    //     }
    //   ],
    //   "total": 9,
    //   "success": true
    // }

    // Sample code for parsing the JSON response...
    // Use the following online tool to generate parsing code from sample JSON:
    // Generate Parsing Code from JSON

    var id: i32 = 0;
    var main_detail_id: i32 = 0;
    var supplier_id: i32 = 0;
    var tax_id: i32 = 0;
    var price_group_id: i32 = 0;
    var filter_group_id: [:0]const u8 = "";
    var configurator_set_id: [:0]const u8 = "";
    var name: [:0]const u8 = "";
    var description: [:0]const u8 = "";
    var description_long: [:0]const u8 = "";
    var added: [:0]const u8 = "";
    var active: bool = false;
    var pseudo_sales: i32 = 0;
    var highlight: bool = false;
    var keywords: [:0]const u8 = "";
    var meta_title: [:0]const u8 = "";
    var changed: [:0]const u8 = "";
    var price_group_active: bool = false;
    var last_stock: bool = false;
    var cross_bundle_look: i32 = 0;
    var notification: bool = false;
    var template: [:0]const u8 = "";
    var mode: i32 = 0;
    var available_from: [:0]const u8 = "";
    var available_to: [:0]const u8 = "";
    var main_detail_article_id: i32 = 0;
    var main_detail_unit_id: i32 = 0;
    var main_detail_number: [:0]const u8 = "";
    var main_detail_supplier_number: [:0]const u8 = "";
    var main_detail_kind: i32 = 0;
    var main_detail_additional_text: [:0]const u8 = "";
    var main_detail_active: bool = false;
    var main_detail_in_stock: i32 = 0;
    var main_detail_stock_min: [:0]const u8 = "";
    var main_detail_last_stock: bool = false;
    var main_detail_weight: [:0]const u8 = "";
    var main_detail_width: [:0]const u8 = "";
    var main_detail_len: [:0]const u8 = "";
    var main_detail_height: [:0]const u8 = "";
    var main_detail_ean: [:0]const u8 = "";
    var main_detail_purchase_price: [:0]const u8 = "";
    var main_detail_position: i32 = 0;
    var main_detail_min_purchase: i32 = 0;
    var main_detail_purchase_steps: i32 = 0;
    var main_detail_max_purchase: i32 = 0;
    var main_detail_purchase_unit: [:0]const u8 = "";
    var main_detail_reference_unit: [:0]const u8 = "";
    var main_detail_pack_unit: [:0]const u8 = "";
    var main_detail_shipping_free: bool = false;
    var main_detail_release_date: [:0]const u8 = "";
    var main_detail_shipping_time: [:0]const u8 = "";
    var main_detail_attribute_id: i32 = 0;
    var main_detail_attribute_article_detail_id: i32 = 0;
    var main_detail_attribute_attr1: [:0]const u8 = "";
    var main_detail_attribute_attr2: [:0]const u8 = "";
    var main_detail_attribute_attr3: [:0]const u8 = "";
    var main_detail_attribute_attr4: [:0]const u8 = "";
    var main_detail_attribute_attr5: [:0]const u8 = "";
    var main_detail_attribute_attr6: [:0]const u8 = "";
    var main_detail_attribute_attr7: [:0]const u8 = "";
    var main_detail_attribute_attr8: [:0]const u8 = "";
    var main_detail_attribute_attr9: [:0]const u8 = "";
    var main_detail_attribute_attr10: [:0]const u8 = "";
    var main_detail_attribute_attr11: [:0]const u8 = "";
    var main_detail_attribute_attr12: [:0]const u8 = "";
    var main_detail_attribute_attr13: [:0]const u8 = "";
    var main_detail_attribute_attr14: [:0]const u8 = "";
    var main_detail_attribute_attr15: [:0]const u8 = "";
    var main_detail_attribute_attr16: [:0]const u8 = "";
    var main_detail_attribute_attr17: [:0]const u8 = "";
    var main_detail_attribute_attr18: [:0]const u8 = "";
    var main_detail_attribute_attr19: [:0]const u8 = "";
    var main_detail_attribute_attr20: [:0]const u8 = "";
    var main_detail_attribute_apostroph: [:0]const u8 = "";

    _ = j_resp.intOf("total");
    success = j_resp.boolOf("success");
    var i: i32 = 0;
    const count_i = j_resp.sizeOfArray("data");
    while (i < count_i) {
        j_resp.setI(i);
        id = j_resp.intOf("data[i].id");
        main_detail_id = j_resp.intOf("data[i].mainDetailId");
        supplier_id = j_resp.intOf("data[i].supplierId");
        tax_id = j_resp.intOf("data[i].taxId");
        price_group_id = j_resp.intOf("data[i].priceGroupId");
        filter_group_id = try j_resp.stringOf(alloc, "data[i].filterGroupId");
        configurator_set_id = try j_resp.stringOf(alloc, "data[i].configuratorSetId");
        name = try j_resp.stringOf(alloc, "data[i].name");
        description = try j_resp.stringOf(alloc, "data[i].description");
        description_long = try j_resp.stringOf(alloc, "data[i].descriptionLong");
        added = try j_resp.stringOf(alloc, "data[i].added");
        active = j_resp.boolOf("data[i].active");
        pseudo_sales = j_resp.intOf("data[i].pseudoSales");
        highlight = j_resp.boolOf("data[i].highlight");
        keywords = try j_resp.stringOf(alloc, "data[i].keywords");
        meta_title = try j_resp.stringOf(alloc, "data[i].metaTitle");
        changed = try j_resp.stringOf(alloc, "data[i].changed");
        price_group_active = j_resp.boolOf("data[i].priceGroupActive");
        last_stock = j_resp.boolOf("data[i].lastStock");
        cross_bundle_look = j_resp.intOf("data[i].crossBundleLook");
        notification = j_resp.boolOf("data[i].notification");
        template = try j_resp.stringOf(alloc, "data[i].template");
        mode = j_resp.intOf("data[i].mode");
        available_from = try j_resp.stringOf(alloc, "data[i].availableFrom");
        available_to = try j_resp.stringOf(alloc, "data[i].availableTo");
        main_detail_id = j_resp.intOf("data[i].mainDetail.id");
        main_detail_article_id = j_resp.intOf("data[i].mainDetail.articleId");
        main_detail_unit_id = j_resp.intOf("data[i].mainDetail.unitId");
        main_detail_number = try j_resp.stringOf(alloc, "data[i].mainDetail.number");
        main_detail_supplier_number = try j_resp.stringOf(alloc, "data[i].mainDetail.supplierNumber");
        main_detail_kind = j_resp.intOf("data[i].mainDetail.kind");
        main_detail_additional_text = try j_resp.stringOf(alloc, "data[i].mainDetail.additionalText");
        main_detail_active = j_resp.boolOf("data[i].mainDetail.active");
        main_detail_in_stock = j_resp.intOf("data[i].mainDetail.inStock");
        main_detail_stock_min = try j_resp.stringOf(alloc, "data[i].mainDetail.stockMin");
        main_detail_last_stock = j_resp.boolOf("data[i].mainDetail.lastStock");
        main_detail_weight = try j_resp.stringOf(alloc, "data[i].mainDetail.weight");
        main_detail_width = try j_resp.stringOf(alloc, "data[i].mainDetail.width");
        main_detail_len = try j_resp.stringOf(alloc, "data[i].mainDetail.len");
        main_detail_height = try j_resp.stringOf(alloc, "data[i].mainDetail.height");
        main_detail_ean = try j_resp.stringOf(alloc, "data[i].mainDetail.ean");
        main_detail_purchase_price = try j_resp.stringOf(alloc, "data[i].mainDetail.purchasePrice");
        main_detail_position = j_resp.intOf("data[i].mainDetail.position");
        main_detail_min_purchase = j_resp.intOf("data[i].mainDetail.minPurchase");
        main_detail_purchase_steps = j_resp.intOf("data[i].mainDetail.purchaseSteps");
        main_detail_max_purchase = j_resp.intOf("data[i].mainDetail.maxPurchase");
        main_detail_purchase_unit = try j_resp.stringOf(alloc, "data[i].mainDetail.purchaseUnit");
        main_detail_reference_unit = try j_resp.stringOf(alloc, "data[i].mainDetail.referenceUnit");
        main_detail_pack_unit = try j_resp.stringOf(alloc, "data[i].mainDetail.packUnit");
        main_detail_shipping_free = j_resp.boolOf("data[i].mainDetail.shippingFree");
        main_detail_release_date = try j_resp.stringOf(alloc, "data[i].mainDetail.releaseDate");
        main_detail_shipping_time = try j_resp.stringOf(alloc, "data[i].mainDetail.shippingTime");
        main_detail_attribute_id = j_resp.intOf("data[i].mainDetail.attribute.id");
        main_detail_attribute_article_detail_id = j_resp.intOf("data[i].mainDetail.attribute.articleDetailId");
        main_detail_attribute_attr1 = try j_resp.stringOf(alloc, "data[i].mainDetail.attribute.attr1");
        main_detail_attribute_attr2 = try j_resp.stringOf(alloc, "data[i].mainDetail.attribute.attr2");
        main_detail_attribute_attr3 = try j_resp.stringOf(alloc, "data[i].mainDetail.attribute.attr3");
        main_detail_attribute_attr4 = try j_resp.stringOf(alloc, "data[i].mainDetail.attribute.attr4");
        main_detail_attribute_attr5 = try j_resp.stringOf(alloc, "data[i].mainDetail.attribute.attr5");
        main_detail_attribute_attr6 = try j_resp.stringOf(alloc, "data[i].mainDetail.attribute.attr6");
        main_detail_attribute_attr7 = try j_resp.stringOf(alloc, "data[i].mainDetail.attribute.attr7");
        main_detail_attribute_attr8 = try j_resp.stringOf(alloc, "data[i].mainDetail.attribute.attr8");
        main_detail_attribute_attr9 = try j_resp.stringOf(alloc, "data[i].mainDetail.attribute.attr9");
        main_detail_attribute_attr10 = try j_resp.stringOf(alloc, "data[i].mainDetail.attribute.attr10");
        main_detail_attribute_attr11 = try j_resp.stringOf(alloc, "data[i].mainDetail.attribute.attr11");
        main_detail_attribute_attr12 = try j_resp.stringOf(alloc, "data[i].mainDetail.attribute.attr12");
        main_detail_attribute_attr13 = try j_resp.stringOf(alloc, "data[i].mainDetail.attribute.attr13");
        main_detail_attribute_attr14 = try j_resp.stringOf(alloc, "data[i].mainDetail.attribute.attr14");
        main_detail_attribute_attr15 = try j_resp.stringOf(alloc, "data[i].mainDetail.attribute.attr15");
        main_detail_attribute_attr16 = try j_resp.stringOf(alloc, "data[i].mainDetail.attribute.attr16");
        main_detail_attribute_attr17 = try j_resp.stringOf(alloc, "data[i].mainDetail.attribute.attr17");
        main_detail_attribute_attr18 = try j_resp.stringOf(alloc, "data[i].mainDetail.attribute.attr18");
        main_detail_attribute_attr19 = try j_resp.stringOf(alloc, "data[i].mainDetail.attribute.attr19");
        main_detail_attribute_attr20 = try j_resp.stringOf(alloc, "data[i].mainDetail.attribute.attr20");
        main_detail_attribute_apostroph = try j_resp.stringOf(alloc, "data[i].mainDetail.attribute.apostroph");
        i = i + 1;
    }
}