Allegro WebAPI

Programming interface of the Allegro platform

doGetCatsData

Last change: 07.03.2013 r.
Availability:
This method allows for loading a full tree of categories available in a selected country.

  1. country-code | int | required
    Country identifier (a list of country identifiers can be loaded using the doGetCountries method).
  2. local-version | long | non-required
    Outdated parameter (it is required to enter any value appropriate for the parameter type).
  3. webapi-key | string | required
    User's WebAPI key.



Sample structure of method call

$dogetcatsdata_request = array(
   'country-id' => 1,
   'local-version' => 0,
   'webapi-key' => 'g2fe408289'
);

  1. cats-list | CatInfoType[]
    Array of structures containing information on each category.
    1. cat-id | int
      Category identifier.
    2. cat-name | string
      Category name.
    3. cat-parent | int
      Supracategory identifier (or 0 for main categories).
    4. cat-position | int
      Position of a category in comparison with other categories of the same tier (indexed from 0).
    5. cat-is-product-catalogue-enabled | int
      Outdated field (will always return 0).
  2. ver-key | long
    Version key value relevant for a selected country and WebAPI key provided
  3. ver-str | string
    Component version of a category’s tree structure relevant for a WebAPI key provided.



Sample structure of server reply

$dogetcatsdata_response = array(
   'cats-list' => array(
      array(
         'cat-id' => 26013,
         'cat-name' => 'Antique and Art',
         'cat-parent' => 0,
         'cat-position' => 0,
         'cat-is-product-catalogue-enabled' => 0),
      array(...),
      array(
         'cat-id' => 8999,
         'cat-name' => 'Amplifiers and loudspeakers',
         'cat-parent' => 5564,
         'cat-position' => 6,
         'cat-is-product-catalogue-enabled' => 0),
      array(...),
      array(
         'cat-id' => 19393,
         'cat-name' => 'Nokia',
         'cat-parent' => 19357,
         'cat-position' => 5,
         'cat-is-product-catalogue-enabled' => 0),
      array(...)),
   'ver-key' => 16551276,
   'ver-str' => '1.2.63'
);

  • ERR_INPUT_COUNTRY_ERROR
    Invalid country identifier (zero or empty value has been provided in the parameter).
  • ERR_NO_DATABASE
    Problems with Allegro database.
  • ERR_WEBAPI_EXPIRED
    Expiry date of WebAPI key has been exceeded.
  • ERR_WEBAPI_KEY
    Invalid value of WebAPI key or WebAPI key has been blocked.
  • ERR_WEBAPI_KEY_INACTIVE
    The WebAPI key has been deactivated (User Agreement not accepted).
  • ERR_WEBAPI_NOT_AVAIL
    Problems with Allegro WebAPI service.

Allegro is not to be held liable for consequences of using examples of the published code. It does not guarantee its correct operation either. The code you see serves as an example only and may contain errors.

#1 (25.05.2010 y.) / vb.net (Author: kopsoe)
  1. Dim Baza As New DataSet("Baza")
  2. Baza.Tables.Add(New DataTable("ListaKategorii"))
  3. Dim Allegro As New AllegroWebApiService
  4. Dim wer_key As Long
  5. Dim wer_str As String = Nothing
  6. Dim wynik() As CatInfoType = Allegro.doGetCatsData(1, 0, "g2fe408289", wer_key, wer_str)
  7. With Baza.Tables(0).Columns
  8. .Add(New DataColumn("cat-id", Type.GetType("System.Int32")))
  9. .Add(New DataColumn("cat-name", Type.GetType("System.String")))
  10. .Add(New DataColumn("cat-parent", Type.GetType("System.Int32")))
  11. .Add(New DataColumn("cat-position", Type.GetType("System.Int32")))
  12. End With
  13. For Each element In wynik
  14. With Baza.Tables(1)
  15. .Rows.Add()
  16. .Rows(.Rows.Count - 1).Item(0) = CType(element.catid, Int32)
  17. .Rows(.Rows.Count - 1).Item(1) = CType(element.catname, String)
  18. .Rows(.Rows.Count - 1).Item(2) = CType(element.catparent, Int32)
  19. .Rows(.Rows.Count - 1).Item(3) = CType(element.catposition, Int32)
  20. End With
  21. Next
#2 (15.05.2011 y.) / c# (Author: saper_2)
  1. private void button7_Click(object sender, EventArgs e)
  2. {
  3. addLog("Init AllegroWebApiService... ", false); // addLog(string text, bool Add_CRLF=true)
  4. AllegroWebApiService api = new AllegroWebApiService();
  5. addLog("DONE.");
  6.  
  7. DataSet Cats = new DataSet("Cats");
  8. Cats.Tables.Add("Cats"); // add table
  9. // add columns to table
  10. Cats.Tables[0].Columns.Add(new DataColumn("cat-id", Type.GetType("System.Int32")));
  11. Cats.Tables[0].Columns.Add(new DataColumn("cat-name", Type.GetType("System.String")));
  12. Cats.Tables[0].Columns.Add(new DataColumn("cat-parent", Type.GetType("System.Int32")));
  13. Cats.Tables[0].Columns.Add(new DataColumn("cat-position", Type.GetType("System.Int32")));
  14.  
  15. addLog("+++++ Get Categories List : BEGIN +++++");
  16. try
  17. {
  18. long verkey;
  19. string verstr;
  20. CatInfoType[] cita = api.doGetCatsData(API_INFO.CountryCode, 0x0, API_INFO.WebApiKey, out verkey, out verstr);
  21.  
  22. foreach (CatInfoType cit in cita)
  23. {
  24. Cats.Tables[0].Rows.Add();
  25. // this maybe done less dirty but it works too
  26. Cats.Tables[0].Rows[Cats.Tables[0].Rows.Count - 1][0] = (Int32)cit.catid;
  27. Cats.Tables[0].Rows[Cats.Tables[0].Rows.Count - 1][1] = (string)cit.catname;
  28. Cats.Tables[0].Rows[Cats.Tables[0].Rows.Count - 1][2] = (Int32)cit.catparent;
  29. Cats.Tables[0].Rows[Cats.Tables[0].Rows.Count - 1][3] = (Int32)cit.catposition;
  30. }
  31. // no filter, sort by cat-parent ascending, and cat-position ascending
  32. Cats.Tables[0].Select("", "cat-parent ASC, cat-position ASC");
  33. addLog("Categories: " + Cats.Tables[0].Rows.Count.ToString() + " (ver-key=0x"+verkey.ToString("X16")+" <"+verkey.ToString()+">, ver-str=""+verstr+"")");
  34. for (int i = 0; i < Cats.Tables[0].Rows.Count; i++)
  35. {
  36. addLog(
  37. " - [" + Convert.ToString(Cats.Tables[0].Rows[i][0]) + "] "" + Convert.ToString(Cats.Tables[0].Rows[i][1]) + """ +
  38. ", parent=" + Convert.ToString(Cats.Tables[0].Rows[i][2]) +
  39. ", position=" + Convert.ToString(Cats.Tables[0].Rows[i][2])
  40. );
  41. }
  42.  
  43. }
  44. catch (System.Web.Services.Protocols.SoapException ee)
  45. {
  46. addLog("Error: Code=" + ee.Code + Environment.NewLine + ee.Message);
  47. }
  48. addLog("----- Get Categories List : END -----");
  49. }
#3 (09.12.2010 y.) / php (Author: gifam)
  1. $list = $client->doGetStatesInfo(228, "WEBAPI_KEY");
  2.  
  3. for($i=0;$i<sizeOf($list);$i++)
  4. echo $list[$i]->{'state-id'}.' : '.$list[$i]->{'state-name'}."<br />n";