{"id":23080587,"url":"https://github.com/chen0040/java-magento-client","last_synced_at":"2026-03-04T09:02:22.009Z","repository":{"id":21800318,"uuid":"94070186","full_name":"chen0040/java-magento-client","owner":"chen0040","description":"Java client for communicating with Magento site","archived":false,"fork":false,"pushed_at":"2022-06-17T01:42:32.000Z","size":204,"stargazers_count":22,"open_issues_count":4,"forks_count":25,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-09-02T21:48:23.683Z","etag":null,"topics":["java","java-connector","magento","magento-connect","magento2","token-authetication","web-client"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chen0040.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-12T07:55:48.000Z","updated_at":"2024-05-28T19:50:51.000Z","dependencies_parsed_at":"2022-08-24T14:09:31.150Z","dependency_job_id":null,"html_url":"https://github.com/chen0040/java-magento-client","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chen0040/java-magento-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fjava-magento-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fjava-magento-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fjava-magento-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fjava-magento-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chen0040","download_url":"https://codeload.github.com/chen0040/java-magento-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fjava-magento-client/sbom","scorecard":{"id":275911,"data":{"date":"2025-08-11","repo":{"name":"github.com/chen0040/java-magento-client","commit":"b2fdd46c12fcec35523c43b5d7ce053d2b824353"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.1,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":1,"reason":"Found 3/25 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":9,"reason":"binaries present in source code","details":["Warn: binary detected: .mvn/wrapper/maven-wrapper.jar:1"],"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":3,"reason":"7 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-xjrr-xv9m-4pw5","Warn: Project is vulnerable to: GHSA-2qrg-x229-3v8q","Warn: Project is vulnerable to: GHSA-65fg-84f6-3jq3","Warn: Project is vulnerable to: GHSA-f7vh-qwp3-x37m","Warn: Project is vulnerable to: GHSA-fp5r-v3w9-4333","Warn: Project is vulnerable to: GHSA-w9p3-5cr8-m3jj","Warn: Project is vulnerable to: GHSA-7r82-7xv7-xcpj"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 8 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T14:23:19.134Z","repository_id":21800318,"created_at":"2025-08-17T14:23:19.134Z","updated_at":"2025-08-17T14:23:19.134Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30076935,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T08:01:56.766Z","status":"ssl_error","status_checked_at":"2026-03-04T08:00:42.919Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","java-connector","magento","magento-connect","magento2","token-authetication","web-client"],"created_at":"2024-12-16T13:15:12.655Z","updated_at":"2026-03-04T09:02:21.993Z","avatar_url":"https://github.com/chen0040.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# java-magento-client\nJava client for communicating with Magento2 site\n\n# Install\n\nAdd the following dependency to your POM file:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.chen0040\u003c/groupId\u003e\n    \u003cartifactId\u003ejava-magento-client\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.15\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n# Features\n\n* Support for token based authentication (ideal for Android or Spring application)\n* Support for V1 rest api at the current version of Magento which is Magento2 version 2.16\n* Allow access to:\n    * Product (CRUD)\n    * Product Media (CRUD)\n    * Product Inventory (RU)\n    * Product Categories (CRUD)\n    * Guest Shopping Cart (CRUD)\n    * My Shopping Cart (CRUD)\n    * Account (R)\n\n\nThe java client provides access to web apis as listed in [link](http://devdocs.magento.com/swagger/index.html) and [link2](http://devdocs.magento.com/guides/v2.0/rest/list.html) currently available for Magent 2.16.\n\nAs Magento2 by default enable a feature preventing anonymous access to most of the [web APIs](http://devdocs.magento.com/guides/v2.0/rest/anonymous-api-security.html) which could cause third-party integrations to fail. If a third-party integration calls any of these web APIs, it will receive an authentication error instead of the expected response. In this case, you might need to disable this feature. To disable this feature, log in to the Admin panel and navigate to Stores \u003e Configuration \u003e Services \u003e Magento Web API \u003e Web API Security. Then select Yes from the Allow Anonymous Guest Access menu.\n\nNote that if the anonymous is allowed, then the client.loginAsClient() or client.loginAsAdmin() do not need to be invoked if\nthe data requested (e.g., getting the categories, product listing or product detail) does not require additional permission.\n\n# Usage\n\n### Customer Login\n\nThe sample code below shows how to login to magento site and retrieve the current login account information:\n\n```java\nString magento_site_url = \"http://magento.ll\";\nString username = \"chen0040@change.me\";\nString password = \"password\";\nMagentoClient client = new MagentoClient(magento_site_url);\nString token = client.loginAsClient(username, password);\nAccount myAccount = client.getMyAccount();\n```\n\n### Admin Login\n\nThe sample code below shows how to login to magento site as the administrator and retrieve the admin login account information:\n\n```java\nString magento_site_url = \"http://magento.ll\";\nString username = \"admin\";\nString password = \"admin-password\";\nMagentoClient client = new MagentoClient(magento_site_url);\nString token = client.loginAsAdmin(username, password);\nAccount account = client.getAccountById(1);\n```\n\n### Logout\n\nThe line below shows how to logout:\n\n```java\nclient.logout();\n```\n\n### Product\n\nThe sample code below shows how to list products, get/add/update/delete a particular product by its sku\n \n```java\nMagentoClient client = new MagentoClient(magento_site_url);\n\nint pageIndex = 0;\nint pageSize = 10;\nProductPage page = client.products().page(pageIndex, pageSize);\nList\u003cProduct\u003e products = page.getItems();\n\n// check if product by sku exists\nboolean exists = client.products().hasProduct(sku);\n\n// get product detail \nProduct product = client.products().getProductBySku(sku);\n\n// action below requires admin login by default\nclient.loginAsAdmin(username, password);\n\n// create or update a product \nProduct product = new Product();\nproduct.setSku(\"B203-SKU\");\nproduct.setName(\"B203\");\nproduct.setPrice(30.00);\nproduct.setStatus(1);\nproduct.setType_id(\"simple\");\nproduct.setAttribute_set_id(4);\nproduct.setWeight(1);\nproduct.setVisibility(Product.VISIBILITY_BOTH);\nproduct.setStatus(Product.STATUS_ENABLED);\n      \nProduct saveProduct = client.products().saveProduct(product);\n\n// delete a product\nclient.products().deleteProduct(sku);\n```\n\n### Product Media\n\nThe sample code below shows how to list the media associated with a particular product:\n\n```java\nString productSku = \"B202-SKU\";\nList\u003cProductMedia\u003e mediaList = client.media().getProductMediaList(productSku);\n\n// below returns a list of absoluate/relative urls for the media (e.g. images) associated with the product\nList\u003cString\u003e imageUrls = client.media().getProductMediaAbsoluteUrls(productSku);\nList\u003cString\u003e imageUrls = client.media().getProductMediaRelativeUrls(productSku);\n```\n\nIn the above code,the entry id of a product media associated with the product can be obtained by calling the ProductMedia.getId() api.\n\nThe sample code below shows how to obtain a particular media associated with a product:\n\n```java\nString productSku = \"B202-SKU\";\nlong entryId = 1L;\n\nProductMedia media = client.media().getProductMedia(productSku, entryId);\n\n// below returns a list of absoluate/relative urls for the media (e.g. images) associated with the product\nString imageUrl = client.media().getProductMediaAbsoluteUrl(productSku, entryId);\nString imageUrl = client.media().getProductMediaRelativeUrl(productSku, entryId);\n```\n\nThe sample code below shows how to upload an image for a particular product given the bytes of the image file:\n\n```java\nString productSku = \"B202-SKU\";\nString imageFileName = \"new_image.png\";\n\nInputStream inputStream = new FileInputStream(imageFileName);\n\nByteArrayOutputStream baos = new ByteArrayOutputStream();\nint length;\nbyte[] bytes = new byte[1024];\nwhile((length = inputStream.read(bytes, 0, 1024)) \u003e 0) {\n baos.write(bytes, 0, length);\n}\nbytes = baos.toByteArray();\n\nboolean overwrite = true;\nlong uploadedEntryId = client.media().uploadImage(productSku, bytes, ImageType.Png, overwrite);\n```\n\nThe sample code below shows how to upload an image for a particular product given the file path of the image file to upload:\n\n```java\nString productSku = \"B202-SKU\";\nString imageFilePath = \"new_image.png\";\n\nboolean overwrite = true;\nlong uploadedEntryId = client.media().uploadImage(productSku, imageFilePath, overwrite);\n```\n\nThe uploadedEntryId returned is the entry id created for the newly uploaded image.\n\nThe sample code below shows how to update an image media for a particular product given the bytes of the new image:\n\n```java\nString productSku = \"B202-SKU\";\nString imageFileName = \"new_image.png\";\n\nInputStream inputStream = new FileInputStream(imageFileName);\n\nByteArrayOutputStream baos = new ByteArrayOutputStream();\nint length;\nbyte[] bytes = new byte[1024];\nwhile((length = inputStream.read(bytes, 0, 1024)) \u003e 0) {\n baos.write(bytes, 0, length);\n}\nbytes = baos.toByteArray();\nlong entryId = 1L; // entry id of the media to be updated\nboolean updated = client.media().updateImage(productSku, entryId, bytes, ImageType.Png);\n```\n\nThe sample code below shows how to update an image media for a particular product given the file path of the new image:\n\n```java\nString productSku = \"B202-SKU\";\nString imageFilePath = \"new_image.png\";\nlong entryId = 1L; // entry id of the media to be updated\nboolean updated = client.media().updateImage(productSku, entryId, imageFilePath);\n```\n\nThe sample code below shows how to delete an image or a video associated with a particular product:\n\n```java\nString productSku = \"B202-SKU\";\nlong entryId = 1L; // entry id of the media to be deleted\nboolean deleted = client.media().deleteProductMedia(productSku, entryId);\n```\n\n### Product Categories\n\nThe sample code below show how to list/add/update/delete categories, get a particular category, \n \n```java\nMagentoClient client = new MagentoClient(magento_site_url);\n\n// list categories\nCategory page = client.categories().all();\n\n// get the category that has category_id = 15 (Clean means no children of that category will be returned)\nCategory category15 = client.categories().getCategoryByIdClean(15);\nCategory category15 = client.categories().getCategoryByIdWithChildren(15);\n\n// action below requires admin login by default\nclient.loginAsAdmin(username, password);\n\n// delete category with category id = 15\nclient.categories().deleteCategory(15);\n\nCategory newCategory = ...\nclient.categories().addCategory(newCategory);\n\nnewCategory.setName(\"New Category Name\");\nclient.categories().updateCategory(newCategory);\n```\n\nThe sample code below show how to list/add/remove products under a category:\n\n```java\n// list products under category 15\nList\u003cCategoryProduct\u003e products = client.categories().getProductsInCategory(15);\n\n// add product to category\nlong categoryId = 15;\nString productSku = \"B202-SKU\";\nint position = 1;\nboolean added = client.categories().addProductToCategory(categoryId, productSku, position);\n\n// remove product from category\nboolean removed = client.categories().removeProductFromCategory(categoryId, productSku);\n```\n\n### Product Inventory \n\nThe sample code below shows how to obtain and update the inventory information for a particular product sku:\n \n```java\nMagentoClient client = new MagentoClient(magento_site_url);\n\nString productSku = \"product_dynamic_571\";\nStockItems inventory_for_sku = client.inventory().getStockItems(productSku);\n\n\n// action below requires admin login by default\nclient.loginAsAdmin(username, password);\n\n// to update the inventory for the product\ninventory_for_sku.setQty(10);\nString stockId = client.inventory().saveStockItems(productSku, inventory_for_sku);\n```\n\n### Guest Shopping Cart\n\nThe sample code below shows how to create a new guest shopping cart, add/update/delete items in the shopping cart:\n\nNote that creating guest shopping cart does not require login\n\n```java\nMagentoClient client = new MagentoClient(magento_site_url);\nString cartId = client.guestCart().newCart();\n\nCartItem item = new CartItem();\nitem.setQty(1);\nitem.setSku(\"product_dynamic_758\");\n\n// add new item to shopping cart\nitem = client.guestCart().addItemToCart(cartId, item);\nSystem.out.println(\"cartItem: \" + JSON.toJSONString(item, SerializerFeature.PrettyFormat));\n\n// update item in the shopping cart\nitem.setQty(3);\nitem = client.guestCart().updateItemInCart(cartId, item);\nSystem.out.println(\"cartItem: \" + JSON.toJSONString(item, SerializerFeature.PrettyFormat));\n\n// delete item in the shopping cart\nboolean deleted = client.guestCart().deleteItemInCart(cartId, item.getItem_id());\n\nCart cart = client.guestCart().getCart(cartId);\nCartTotal cartTotal = client.getGuestCart().getCartTotal(cartId);\n\nSystem.out.println(\"cart: \" + JSON.toJSONString(cart, SerializerFeature.PrettyFormat));\nSystem.out.println(\"cartTotal: \" + JSON.toJSONString(cartTotal, SerializerFeature.PrettyFormat));\n```\n\nThe sample code belows show how to transfer a guest cart to my cart after user login:\n\n```bash\nMagentoClient client = new MagentoClient(magento_site_url);\n\nString cartId = client.guestCart().newCart();\n\nCartItem item = new CartItem();\nitem.setQty(1);\nitem.setSku(\"product_dynamic_758\");\n\nitem = client.guestCart().addItemToCart(cartId, item);\n\nclient.loginAsClient(\"username\", \"password\");\nboolean result = client.myCart().transferGuestCartToMyCart(cartId);\n\nCart cart = client.myCart().getCart();\nCartTotal cartTotal = client.myCart().getCartTotal();\n\n```\n\n### My Shopping Cart\n\nThe sample code below shows how to create my shopping cart, add/update/delete items in the shopping cart:\n\nNote that creating my shopping cart requires login\n\n```java\nMagentoClient client = new MagentoClient(magento_site_url);\nclient.loginAsClient(\"username\", \"password\");\nString quoteId = client.myCart().newQuote();\n\nCartItem item = new CartItem();\nitem.setQty(1);\nitem.setSku(\"product_dynamic_758\");\n\n// add new item to shopping cart\nitem = client.myCart().addItemToCart(quoteId, item);\nSystem.out.println(\"cartItem: \" + JSON.toJSONString(item, SerializerFeature.PrettyFormat));\n\n// update item in the shopping cart\nitem.setQty(3);\nitem = client.myCart().updateItemInCart(quoteId, item);\nSystem.out.println(\"cartItem: \" + JSON.toJSONString(item, SerializerFeature.PrettyFormat));\n\n// delete item in the shopping cart\nboolean deleted = client.myCart().deleteItemInCart(item.getItem_id());\n\nCart cart = client.myCart().getCart();\nCartTotal cartTotal = client.myCart().getCartTotal();\n\nSystem.out.println(\"cart: \" + JSON.toJSONString(cart, SerializerFeature.PrettyFormat));\nSystem.out.println(\"cartTotal: \" + JSON.toJSONString(cartTotal, SerializerFeature.PrettyFormat));\n```\n\n\n# Notes\n\n* http://devdocs.magento.com/guides/v2.1/howdoi/webapi/search-criteria.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchen0040%2Fjava-magento-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchen0040%2Fjava-magento-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchen0040%2Fjava-magento-client/lists"}