0
0

eBayのカテゴリー一覧をAPIで取得する方法

Last updated at Posted at 2024-04-05

事前知識

  • eBayのカテゴリーは、年に数回Seller Updateにて変更が発表されます
  • 最新のカテゴリー及び変更内容、過去のカテゴリーは、以下のURLで知ることができます
    https://pages.ebay.com/sellerinformation/news/categorychanges.html
  • カテゴリーは、各販売サイトごとに違います(例えば、USとUKでは違います)
  • 出品は、リーフノード(末端)にのみ可能です

getCategoryTreeを利用する

RESTful APIs > Commerce APIs > Taxonomy API > getCategoryTree
https://developer.ebay.com/api-docs/commerce/taxonomy/resources/category_tree/methods/getCategoryTree

GET https://api.ebay.com/commerce/taxonomy/v1/category_tree/{category_tree_id}

Traditional Selling APIs > Trading API側にも、GetCategoriesがあります。同じく、カテゴリーIDとカテゴリー名をツリーで取得できます。

category_tree_id

このIDはカテゴリIDではなく、販売サイトごとに割り振られたIDです。getDefaultCategoryTreeIdをコールすることで取得することができます。
https://developer.ebay.com/api-docs/commerce/taxonomy/resources/category_tree/methods/getDefaultCategoryTreeId
現時点(2024/4)では、eBay USは0、eBay Motorsは100です。

USのカテゴリーを取得してみる

GET https://api.ebay.com/commerce/taxonomy/v1/category_tree/0

以下のような戻り値が返ってきます。

{
  "categoryTreeId": "0",
  "categoryTreeVersion": "130",
  "rootCategoryNode": {
    "category": {
      "categoryId": "0",
      "categoryName": "Root"
    },
    "childCategoryTreeNodes": [
      {
        "category": {
          "categoryId": "1",
          "categoryName": "Collectibles"
        },
        "parentCategoryTreeNodeHref": "https://api.ebay.com/commerce/taxonomy/v1/category_tree/0/get_category_subtree?category_id=0",
        "childCategoryTreeNodes": [
          {
            "category": {
              "categoryId": "34",
              "categoryName": "Advertising"
            },
続く…

他のcategory_tree関連コール

https://developer.ebay.com/api-docs/commerce/taxonomy/resources/methods
各カテゴリーの必須Item Specifics等を取得することが可能です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0