Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Manufacturer Center API (MfC) cho phép các ứng dụng tương tác trực tiếp với
Nền tảng Manufacturer Center. Để giúp bạn
hãy bắt đầu, chúng tôi cung cấp mã mẫu trong Java và .NET.
Hướng dẫn này sẽ giúp bạn tạo đơn đăng ký đầu tiên bằng cách sử dụng Manufacturer
API trung tâm. Trước khi có thể bắt đầu lập trình, có một số việc bạn cần làm.
Hỗ trợ REST
API REST của chúng tôi hỗ trợ các thao tác CRUD cơ bản cho 2 loại tài nguyên:
Sản phẩm dành cho Chủ sở hữu thương hiệu
và Đối tác dữ liệu.
Nhớ đảm bảo bạn đã dùng email nào để tạo tài khoản Manufacturer Center này
tài khoản của bạn vì bạn sẽ cần đến tài khoản đó sau này. Trong ảnh chụp màn hình, bạn sẽ thấy biểu tượng này
được đại diện là manufacturer_user@example.com.
Tạo yêu cầu API đầu tiên của bạn (không cần một dòng mã!)
Chuyển đến API
Explorer ở
tài liệu dành cho nhà phát triển của chúng tôi về Accounts.Products.list.
Đảm bảo rằng Tài khoản Google đã đăng nhập có trong danh sách "Người dùng" cài đặt
trong thẻ Cài đặt.
Trong APIs Explorer, hãy đảm bảo rằng Google OAuth 2.0 được chọn trong
Trình đơn thả xuống Xác thực:
Nhập accounts/{account_id}, thay thế {account_id} bằng
Mã nhà sản xuất từ tài khoản Manufacturer Center của bạn vào tài khoản "cha mẹ"
của biểu mẫu rồi nhấp vào Thực thi.
Bạn sẽ thấy một phản hồi thành công. Xin chúc mừng! Bạn đã tạo
yêu cầu API Manufacturer Center đầu tiên.
Nếu bạn chưa có sản phẩm nào trong Manufacturer Center, thì sẽ không có sản phẩm nào
trong danh sách. Tại thời điểm này, bạn có thể chuyển sang các yêu cầu khác và xem xét
những gì họ làm. Vì đây là một API RESTful nên tất cả các yêu cầu đều hoạt động tương tự nhau. Đáp
bước tiếp theo là thử
Accounts.Products.get.
Tạo Dự án trên Bảng điều khiển API của Google
Các yêu cầu đối với Manufacturer Center API được thực hiện thông qua dự án của bạn trên Bảng điều khiển API. Ở đây, chúng tôi giả định rằng bạn sẽ truy cập vào
tài khoản Manufacturer Center, vì vậy, bạn nên sử dụng dịch vụ
tài khoản để đơn giản hoá
quy trình xác thực. Xem phần Dịch vụ
Hướng dẫn về tài khoản cung cấp thông tin chi tiết về cách
thiết lập một tài khoản dịch vụ mới để sử dụng với tài khoản Manufacturer Center.
Yêu cầu API được uỷ quyền đầu tiên của bạn bằng Java
Bây giờ, bạn đã thiết lập một tài khoản dịch vụ và thêm mã tài khoản dịch vụ vào
tài khoản Manufacturer Center, bạn có thể truy cập vào tài khoản của mình bằng
có sẵn Mã mẫu. Hướng dẫn này sử dụng mã Java
mẫu để minh hoạ khi sử dụng API.
Nếu bạn chưa làm theo hướng dẫn về cấu hình trong tài liệu README
đi kèm với tệp nguồn, bạn sẽ nhận được lỗi rằng không có mẫu nào
có thể tìm thấy cấu hình. Làm theo hướng dẫn trong tài liệu README để tạo
thư mục cấu hình và để điền thư mục cấu hình thích hợp
của bạn. Tệp JSON mà bạn đã tải xuống trong khi thiết lập dịch vụ
tài khoản nên được đặt trong thư mục đó cùng với tên tệp
service-account.json. Hãy nhớ cho mã vị trí của tệp bằng cách
đặt biến môi trường sau.
Tại thời điểm này, chương trình Java sẽ hoàn tất việc thực thi và in ra
danh sách sản phẩm tìm thấy hoặc một thông báo cho biết không có
trong tài khoản. Nếu bạn gặp lỗi như "Người dùng không thể truy cập
1234567890", thì nhiều khả năng là bạn chưa thiết lập
người dùng tài khoản dịch vụ làm người dùng được uỷ quyền trong Manufacturer Center. Từ
Trên quan điểm của API, dự án Bảng điều khiển API đã gửi một yêu cầu vào
thay mặt cho người dùng không có trong danh sách Manufacturer Center được uỷ quyền
quản trị viên của Google sẽ từ chối yêu cầu đó.
Bạn có thể thử nghiệm chạy ProductsListSample bao nhiêu lần tuỳ ý
vì đó là yêu cầu chỉ đọc. Bạn cũng có thể khám phá
các mẫu mà chúng tôi đã tạo cho cả Java và .NET.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-31 UTC."],[[["\u003cp\u003eThe Manufacturer Center API allows direct interaction with the Manufacturer Center platform, offering code samples in Java and .NET to facilitate application development.\u003c/p\u003e\n"],["\u003cp\u003eBefore using the API, you need to set up a Manufacturer Center account and make an initial API request using the API Explorer to authorize access.\u003c/p\u003e\n"],["\u003cp\u003eA Google API Console project with a service account is necessary to make requests to the Manufacturer Center API, enabling secure communication.\u003c/p\u003e\n"],["\u003cp\u003eYou can access your Manufacturer Center account using provided sample code (e.g., Java samples) after configuring a service account and adding it as an authorized user.\u003c/p\u003e\n"],["\u003cp\u003eThe samples demonstrate various API functionalities, including listing products and performing other read-only operations, allowing for experimentation and further exploration.\u003c/p\u003e\n"]]],[],null,["# Get Started\n\nThe Manufacturer Center (MfC) API allows apps to interact directly with the\n[Manufacturer Center platform](https://manufacturers.google.com). To help you\nget started, we offer [code samples](/manufacturers/libraries) in Java and .NET.\n\nThis guide will help you create your first application using the Manufacturer\nCenter API. Before you can start coding, there are a few things you need to do.\n\nREST Support\n------------\n\nOur REST API supports basic CRUD operations for 2 different types of resources:\n\n- [Product](/manufacturers/reference/rest/v1/accounts.products) for Brand Owners and Data Partners.\n- And [ProductCertification](/manufacturers/reference/rest/v1/accounts.languages.productCertifications) for Certification Bodies.\n\nThe rest of this documentation will be written mainly for [Product](/manufacturers/reference/rest/v1/accounts.products) but the process should be similar for [ProductCertification](/manufacturers/reference/rest/v1/accounts.languages.productCertifications).\n\nSet up your Manufacturer Center Account\n---------------------------------------\n\n1. Create a [Manufacturer Center\n Account](//support.google.com/manufacturers/answer/7064831).\n\n | **Note:** Certification Body users can't create an account this way but need to contact our support directly.\n2. Be sure to remember which email you used to create this Manufacturer Center\n account, as you will need that later. In the screenshots, you'll see it\n represented as **manufacturer_user@example.com**.\n\nMake your first API request (without a line of code!)\n-----------------------------------------------------\n\n1. Head over to the [APIs\n Explorer](/manufacturers/reference/rest/v1/accounts.products/list#try-it) in\n our developer documentation for `Accounts.Products.list`.\n\n2. Ensure that the logged in Google account is listed in the 'Users' setting\n in the Settings tab.\n\n3. In the APIs Explorer, make sure that **Google OAuth 2.0** is selected in the\n **Authentication** drop-down menu:\n\n4. Enter `accounts/{account_id}`, replacing `{account_id}` with your\n Manufacturer ID from your Manufacturer Center account, into the 'parent'\n field of the form, and click **Execute**.\n\n | **Note:** If you have not previously granted OAuth2 permission, you will now be asked to authorize the call.\n5. You should see a successful response. Congratulations! You've made your\n first Manufacturer Center API request.\n\n6. If you have no products in your Manufacturer Center yet, there won't be any\n in the list. At this point, you can hop to other requests and take a look at\n what they do. Since this is a RESTful API, all requests work similarly. A\n good next step, once you have products, is to try\n [`Accounts.Products.get`](/manufacturers/reference/rest/v1/accounts.products/get#try-it).\n\nCreate a Google API Console Project\n-----------------------------------\n\nRequests to the Manufacturer Center API are made through your API Console project. Here we assume you will be accessing your own\nManufacturer Center account, so we suggest using [service\naccounts](/identity/protocols/OAuth2ServiceAccount) to simplify the\nauthentication flow. See the [Service\nAccounts](/manufacturers/how-tos/service-accounts) Guide for details on how to\nset up a new service account to use with your Manufacturer Center account.\n| **Note:** If you are interested in making calls on behalf of clients with their own Manufacturer Center accounts, then see the [Authorize\n| Requests](/manufacturers/how-tos/authorizing) guide.\n\nYour first authorized API request using Java\n--------------------------------------------\n\nNow that you've set up a service account and added the service account ID to\nyour Manufacturer Center account, you can access your account using the\navailable [Samples code](/manufacturers/libraries). This guide uses the Java\nsamples to demonstrate using the API.\n\n1. Install [Apache Maven](https://maven.apache.org/), if you haven't already.\n\n2. Download our [Shopping\n samples](//github.com/googleads/googleads-shopping-samples/) from our GitHub\n page.\n\n3. From within the `java` subdirectory, build the Java samples:\n\n $ mvn compile\n\n4. Now run the `ProductsListSample` (the example for [ProductCertification](/manufacturers/reference/rest/v1/accounts.languages.productCertifications) would be `ListProductCertificationsSample`) code:\n\n $ mvn exec:java -Dexec.mainClass=\"shopping.manufacturers.v1.samples.products.ProductsListSample\"\n\n5. If you haven't followed the configuration directions in the README\n accompanying the source files, you will get an error that no sample\n configuration could be found. Follow the directions in the README to create\n the configuration directory and to populate it with the appropriate\n information. The JSON file you downloaded while setting up your service\n account should be placed in that directory with the filename\n `service-account.json`. Remember to tell the code where your file is by\n setting the following environment variable.\n\n export GOOGLE_APPLICATION_CREDENTIALS=\u003cPath to your JSON credentials file\u003e\n\n6. Now that you have set up the samples configuration, run the\n `ProductsListSample` code again.\n\n $ mvn exec:java -Dexec.mainClass=\"shopping.manufacturers.v1.samples.products.ProductsListSample\"\n\n7. At this point, the Java program should finish executing, and print out\n either a list of products that it found, or a message that there were no\n products in your account. If you get an error such as \"User cannot access\n account 1234567890\", it's most likely because you have not set up the\n service account user as an authorized user in Manufacturer Center. From the\n API's standpoint, the API Console project sent a request on\n behalf of a user who was not on the list of authorized Manufacturer Center\n administrators, so it would, of course, reject that request.\n\n8. You can experiment with running `ProductsListSample` as many times as you\n want, since it is a read-only request. You can also explore the other\n samples that we've created for both Java and .NET."]]