ข้อควรระวัง: คุณกําลังดูเอกสารประกอบสําหรับอินเทอร์เฟซ REST ของ API ไลบรารีของไคลเอ็นต์อย่างเป็นทางการส่วนใหญ่ของเราใช้ gRPC โปรดดูรายละเอียดใน
บทนํา REST
วิธีการของบริการ
การออกแบบ Google Ads API แตกต่างจากสถาปัตยกรรม REST แบบดั้งเดิมเนื่องจากใช้เมธอดที่กําหนดเองเป็นหลัก เช่น search
และ mutate,
แทนเมธอดแบบดั้งเดิมอย่าง list
, get
, create
, update
และ delete
การดําเนินการเหล่านี้จะแสดงใน URL ของ REST โดยใช้รูปแบบการแมป HTTP ของ :
เพื่อแยกคํากริยาที่กําหนดเองออกจาก URL ที่เหลือ
ตัวอย่างเช่น การเรียก API เปลี่ยนรูปแบบแคมเปญจะใช้ URL ต่อไปนี้
https://googleads.googleapis.com/v19/customers/1234567890/campaigns:mutate
เหตุผลหนึ่งที่ทำให้ API ใช้เมธอดที่กำหนดเองคือเพื่อจัดกลุ่มการดำเนินการหลายรายการไว้ในคำขอ API เดียว Semantics ของ REST ที่เข้มงวดจะอนุญาตให้อัปเดตแคมเปญได้ครั้งละ 1 แคมเปญเท่านั้น ตัวอย่างเช่น REST แบบดั้งเดิม update
ไปยังแคมเปญจะต้องส่งคําขอ HTTP PATCH 1 รายการต่อแหล่งข้อมูลแคมเปญ
Google Ads API กําหนดวิธีการ mutate
ที่กำหนดเองสำหรับทรัพยากรส่วนใหญ่แทน เพื่อให้สามารถรวมการดำเนินการหลายรายการไว้ในเนื้อหาคำขอเดียว
ในทํานองเดียวกัน หากต้องการเปิดใช้การอ่านแบบเป็นกลุ่ม (การดึงข้อมูลออบเจ็กต์หลายรายการพร้อมกัน) จาก API
API จะใช้เมธอด search
ที่กําหนดเองซึ่งมีภาษาการค้นหาของ Google Ads คล้ายกับ SQL
หน้าเมธอดทั่วไปจะอธิบายรายละเอียดเกี่ยวกับเมธอดที่ใช้บ่อยที่สุดใน Google Ads API
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-03-04 UTC
[null,null,["อัปเดตล่าสุด 2025-03-04 UTC"],[[["The Google Ads API utilizes custom methods like `search` and `mutate` instead of standard REST methods for efficiency and batch operations."],["This approach allows for updating multiple campaigns or fetching numerous objects within a single request, unlike traditional REST."],["Custom methods are expressed in REST URLs using a colon to separate the verb from the rest of the URL, for example, `https://googleads.googleapis.com/v18/customers/1234567890/campaigns:mutate`."],["Batching operations, like updating many campaigns simultaneously, are enabled through the custom `mutate` method, improving efficiency over individual requests."],["The `search` method uses a SQL-like query language for batch reads, enabling retrieval of multiple objects in one API call."]]],["The Google Ads API uses custom methods like `search` and `mutate` instead of standard REST methods (e.g., `list`, `get`). This is indicated in URLs by a `:` separator. `Mutate` enables batching multiple operations into one request, unlike standard `update`, which handles one campaign at a time. Similarly, `search` allows fetching multiple objects in a single request, utilizing a SQL-like query language. This deviates from REST conventions to facilitate efficient batch processing and querying.\n"]]