or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

index.md

index.mddocs/

0

# Google Shopping Merchant Quota

1

2

A Python client library for the Google Shopping Merchant Quota API that enables programmatic management of Merchant Center account quotas. This library provides access to quota groups, usage tracking, and method-level quota information for Google's merchant services.

3

4

## Package Information

5

6

- **Package Name**: google-shopping-merchant-quota

7

- **Language**: Python

8

- **Installation**: `pip install google-shopping-merchant-quota`

9

10

## Core Imports

11

12

```python

13

from google.shopping.merchant_quota import QuotaServiceClient, QuotaServiceAsyncClient

14

```

15

16

Version-specific imports:

17

18

```python

19

# v1 (stable) - recommended

20

from google.shopping.merchant_quota_v1 import QuotaServiceClient, QuotaServiceAsyncClient

21

22

# v1beta - for beta features

23

from google.shopping.merchant_quota_v1beta import QuotaServiceClient, QuotaServiceAsyncClient

24

```

25

26

Data types:

27

28

```python

29

from google.shopping.merchant_quota import (

30

QuotaGroup,

31

MethodDetails,

32

ListQuotaGroupsRequest,

33

ListQuotaGroupsResponse

34

)

35

```

36

37

## Basic Usage

38

39

```python

40

from google.shopping.merchant_quota import QuotaServiceClient, ListQuotaGroupsRequest

41

42

# Create a client with default authentication

43

client = QuotaServiceClient()

44

45

# List quota groups for a merchant account

46

parent = "accounts/123456789" # Your merchant account ID

47

request = ListQuotaGroupsRequest(parent=parent)

48

49

# Get paginated results

50

page_result = client.list_quota_groups(request=request)

51

52

# Iterate through quota groups

53

for quota_group in page_result:

54

print(f"Quota Group: {quota_group.name}")

55

print(f"Usage: {quota_group.quota_usage}/{quota_group.quota_limit}")

56

print(f"Per-minute limit: {quota_group.quota_minute_limit}")

57

58

# Show method details

59

for method in quota_group.method_details:

60

print(f" Method: {method.method} ({method.version})")

61

print(f" Path: {method.path}")

62

```

63

64

Async usage:

65

66

```python

67

import asyncio

68

from google.shopping.merchant_quota import QuotaServiceAsyncClient, ListQuotaGroupsRequest

69

70

async def main():

71

# Create async client

72

async with QuotaServiceAsyncClient() as client:

73

parent = "accounts/123456789"

74

request = ListQuotaGroupsRequest(parent=parent)

75

76

# Get async paginated results

77

page_result = await client.list_quota_groups(request=request)

78

79

# Iterate through quota groups

80

async for quota_group in page_result:

81

print(f"Quota Group: {quota_group.name}")

82

print(f"Usage: {quota_group.quota_usage}/{quota_group.quota_limit}")

83

84

asyncio.run(main())

85

```

86

87

## Capabilities

88

89

### Quota Service Client

90

91

Synchronous client for accessing quota group information and managing API quotas.

92

93

```python { .api }

94

from typing import Callable, Dict, Optional, Sequence, Tuple, Union

95

from google.auth import credentials as ga_credentials

96

from google.api_core import client_options as client_options_lib

97

from google.api_core import gapic_v1

98

from google.api_core import retry as retries

99

from google.shopping.merchant_quota_v1.services.quota_service import pagers

100

from google.shopping.merchant_quota_v1.services.quota_service.transports.base import QuotaServiceTransport

101

102

try:

103

OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault, None]

104

except AttributeError:

105

OptionalRetry = Union[retries.Retry, object, None]

106

107

class QuotaServiceClient:

108

def __init__(

109

self,

110

*,

111

credentials: Optional[ga_credentials.Credentials] = None,

112

transport: Optional[Union[str, QuotaServiceTransport, Callable[..., QuotaServiceTransport]]] = None,

113

client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,

114

client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,

115

):

116

"""

117

Initialize QuotaService client.

118

119

Args:

120

credentials: The authorization credentials to attach to requests

121

transport: The transport to use for requests

122

client_options: Custom options for the client

123

client_info: The client info used to send a user-agent string

124

"""

125

126

def list_quota_groups(

127

self,

128

request: Optional[Union[ListQuotaGroupsRequest, dict]] = None,

129

*,

130

parent: Optional[str] = None,

131

retry: OptionalRetry = gapic_v1.method.DEFAULT,

132

timeout: Union[float, object] = gapic_v1.method.DEFAULT,

133

metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),

134

) -> pagers.ListQuotaGroupsPager:

135

"""

136

List quota groups for a merchant account.

137

138

Args:

139

request: The request object containing parent and pagination parameters

140

parent: Required. The merchant account (format: accounts/{account})

141

retry: Retry configuration

142

timeout: Request timeout in seconds

143

metadata: Additional gRPC metadata

144

145

Returns:

146

Pager for iterating through quota groups

147

"""

148

149

@classmethod

150

def from_service_account_info(

151

cls, info: dict, *args, **kwargs

152

) -> "QuotaServiceClient":

153

"""

154

Create client from service account info dictionary.

155

156

Args:

157

info: Service account info in Google format

158

159

Returns:

160

QuotaServiceClient instance

161

"""

162

163

@classmethod

164

def from_service_account_file(

165

cls, filename: str, *args, **kwargs

166

) -> "QuotaServiceClient":

167

"""

168

Create client from service account JSON file.

169

170

Args:

171

filename: Path to service account JSON file

172

173

Returns:

174

QuotaServiceClient instance

175

"""

176

177

def quota_group_path(self, account: str, group: str) -> str:

178

"""

179

Generate quota group resource path.

180

181

Args:

182

account: Merchant account ID

183

group: Quota group ID

184

185

Returns:

186

Resource path string (accounts/{account}/quotas/{group})

187

"""

188

189

@staticmethod

190

def parse_quota_group_path(path: str) -> Dict[str, str]:

191

"""

192

Parse quota group resource path.

193

194

Args:

195

path: Resource path string

196

197

Returns:

198

Dictionary with 'account' and 'group' keys

199

"""

200

201

def __enter__(self) -> "QuotaServiceClient":

202

"""Context manager entry."""

203

204

def __exit__(self, type, value, traceback):

205

"""Context manager exit."""

206

```

207

208

### Quota Service Async Client

209

210

Asynchronous client for accessing quota group information with async/await support.

211

212

```python { .api }

213

from typing import Callable, Optional, Sequence, Tuple, Union

214

from google.auth import credentials as ga_credentials

215

from google.api_core import client_options as client_options_lib

216

from google.api_core import gapic_v1

217

from google.api_core import retry_async as retries_async

218

from google.shopping.merchant_quota_v1.services.quota_service import pagers

219

from google.shopping.merchant_quota_v1.services.quota_service.transports.base import QuotaServiceTransport

220

221

try:

222

OptionalAsyncRetry = Union[retries_async.AsyncRetry, gapic_v1.method._MethodDefault, None]

223

except AttributeError:

224

OptionalAsyncRetry = Union[retries_async.AsyncRetry, object, None]

225

226

class QuotaServiceAsyncClient:

227

def __init__(

228

self,

229

*,

230

credentials: Optional[ga_credentials.Credentials] = None,

231

transport: Optional[Union[str, QuotaServiceTransport, Callable[..., QuotaServiceTransport]]] = None,

232

client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,

233

client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,

234

):

235

"""

236

Initialize async QuotaService client.

237

238

Args:

239

credentials: The authorization credentials to attach to requests

240

transport: The transport to use for requests

241

client_options: Custom options for the client

242

client_info: The client info used to send a user-agent string

243

"""

244

245

async def list_quota_groups(

246

self,

247

request: Optional[Union[ListQuotaGroupsRequest, dict]] = None,

248

*,

249

parent: Optional[str] = None,

250

retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT,

251

timeout: Union[float, object] = gapic_v1.method.DEFAULT,

252

metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),

253

) -> pagers.ListQuotaGroupsAsyncPager:

254

"""

255

Asynchronously list quota groups for a merchant account.

256

257

Args:

258

request: The request object containing parent and pagination parameters

259

parent: Required. The merchant account (format: accounts/{account})

260

retry: Async retry configuration

261

timeout: Request timeout in seconds

262

metadata: Additional gRPC metadata

263

264

Returns:

265

Async pager for iterating through quota groups

266

"""

267

268

@classmethod

269

def from_service_account_info(

270

cls, info: dict, *args, **kwargs

271

) -> "QuotaServiceAsyncClient":

272

"""

273

Create async client from service account info dictionary.

274

275

Args:

276

info: Service account info in Google format

277

278

Returns:

279

QuotaServiceAsyncClient instance

280

"""

281

282

@classmethod

283

def from_service_account_file(

284

cls, filename: str, *args, **kwargs

285

) -> "QuotaServiceAsyncClient":

286

"""

287

Create async client from service account JSON file.

288

289

Args:

290

filename: Path to service account JSON file

291

292

Returns:

293

QuotaServiceAsyncClient instance

294

"""

295

296

async def __aenter__(self) -> "QuotaServiceAsyncClient":

297

"""Async context manager entry."""

298

299

async def __aexit__(self, exc_type, exc_val, exc_tb):

300

"""Async context manager exit."""

301

```

302

303

### Pagination Support

304

305

Iterators for handling paginated quota group responses.

306

307

```python { .api }

308

from typing import AsyncIterator, Iterator

309

from google.shopping.merchant_quota_v1.types.quota import QuotaGroup

310

311

class ListQuotaGroupsPager:

312

"""

313

Synchronous iterator for paginated quota group results.

314

315

Automatically handles pagination and yields individual QuotaGroup objects.

316

"""

317

def __iter__(self) -> Iterator[QuotaGroup]:

318

"""Iterate through quota groups."""

319

320

class ListQuotaGroupsAsyncPager:

321

"""

322

Asynchronous iterator for paginated quota group results.

323

324

Automatically handles pagination and yields individual QuotaGroup objects.

325

"""

326

def __aiter__(self) -> AsyncIterator[QuotaGroup]:

327

"""Async iterate through quota groups."""

328

```

329

330

## Data Types

331

332

### Quota Group

333

334

Information about quota groups containing related API methods with shared quotas.

335

336

```python { .api }

337

from typing import List

338

339

class QuotaGroup:

340

"""

341

Quota group information for methods in the Merchant API.

342

343

The quota is shared between all methods in the group. Groups are returned

344

even if none of the methods have usage.

345

"""

346

name: str

347

"""

348

Resource name of the quota group.

349

Format: accounts/{account}/quotas/{group}

350

"""

351

352

quota_usage: int

353

"""

354

Current quota usage (number of calls made today).

355

Daily quotas reset at 12:00 PM midday UTC.

356

"""

357

358

quota_limit: int

359

"""

360

Maximum number of calls allowed per day for the group.

361

"""

362

363

quota_minute_limit: int

364

"""

365

Maximum number of calls allowed per minute for the group.

366

"""

367

368

method_details: List[MethodDetails]

369

"""

370

List of all methods that this quota group applies to.

371

"""

372

```

373

374

### Method Details

375

376

Details about individual API methods within quota groups.

377

378

```python { .api }

379

class MethodDetails:

380

"""

381

Method details for API methods within quota groups.

382

"""

383

method: str

384

"""

385

Method name (e.g., "products.list").

386

"""

387

388

version: str

389

"""

390

API version that the method belongs to.

391

"""

392

393

subapi: str

394

"""

395

Sub-API that the method belongs to.

396

"""

397

398

path: str

399

"""

400

Method path (e.g., "products/v1/productInputs.insert").

401

"""

402

```

403

404

### List Quota Groups Request

405

406

Request message for listing quota groups.

407

408

```python { .api }

409

class ListQuotaGroupsRequest:

410

"""

411

Request parameters for listing quota groups.

412

"""

413

parent: str

414

"""

415

Required. The merchant account that owns the quota groups.

416

Format: accounts/{account}

417

"""

418

419

page_size: int

420

"""

421

Optional. Maximum number of quotas to return (default 500, max 1000).

422

Values above 1000 will be coerced to 1000.

423

"""

424

425

page_token: str

426

"""

427

Optional. Token for retrieving subsequent pages.

428

All other parameters must match the original call.

429

"""

430

```

431

432

### List Quota Groups Response

433

434

Response message containing quota groups and pagination information.

435

436

```python { .api }

437

class ListQuotaGroupsResponse:

438

"""

439

Response containing quota groups and pagination data.

440

"""

441

quota_groups: List[QuotaGroup]

442

"""

443

Quota groups with usage and limits.

444

Groups are sorted in descending order by quota_usage.

445

"""

446

447

next_page_token: str

448

"""

449

Token for retrieving the next page.

450

Empty if there are no more pages.

451

"""

452

453

@property

454

def raw_page(self):

455

"""Raw page property for pagination support."""

456

```

457

458

## Authentication

459

460

The client supports multiple authentication methods:

461

462

### Default Credentials

463

464

```python

465

from google.shopping.merchant_quota import QuotaServiceClient

466

467

# Uses Application Default Credentials (ADC)

468

client = QuotaServiceClient()

469

```

470

471

### Service Account File

472

473

```python

474

client = QuotaServiceClient.from_service_account_file(

475

"path/to/service-account.json"

476

)

477

```

478

479

### Service Account Info

480

481

```python

482

service_account_info = {

483

"type": "service_account",

484

"project_id": "your-project-id",

485

# ... other service account fields

486

}

487

488

client = QuotaServiceClient.from_service_account_info(service_account_info)

489

```

490

491

### Custom Credentials

492

493

```python

494

from google.oauth2 import service_account

495

496

credentials = service_account.Credentials.from_service_account_file(

497

"path/to/service-account.json"

498

)

499

500

client = QuotaServiceClient(credentials=credentials)

501

```

502

503

## Error Handling

504

505

The client follows Google API client library conventions for error handling:

506

507

```python

508

from google.api_core import exceptions

509

from google.shopping.merchant_quota import QuotaServiceClient

510

511

client = QuotaServiceClient()

512

513

try:

514

parent = "accounts/123456789"

515

request = ListQuotaGroupsRequest(parent=parent)

516

page_result = client.list_quota_groups(request=request)

517

518

for quota_group in page_result:

519

print(quota_group.name)

520

521

except exceptions.NotFound:

522

print("Merchant account not found")

523

except exceptions.PermissionDenied:

524

print("Permission denied - check authentication and account access")

525

except exceptions.InvalidArgument as e:

526

print(f"Invalid request parameters: {e}")

527

except exceptions.GoogleAPIError as e:

528

print(f"API error: {e}")

529

```

530

531

## Transport Options

532

533

The client supports multiple transport protocols:

534

535

```python

536

from google.shopping.merchant_quota_v1.services.quota_service import (

537

QuotaServiceClient,

538

transports

539

)

540

541

# gRPC transport (default)

542

client = QuotaServiceClient(

543

transport=transports.QuotaServiceGrpcTransport()

544

)

545

546

# REST transport

547

client = QuotaServiceClient(

548

transport=transports.QuotaServiceRestTransport()

549

)

550

551

# Async gRPC transport

552

async_client = QuotaServiceAsyncClient(

553

transport=transports.QuotaServiceGrpcAsyncIOTransport()

554

)

555

```

556

557

## API Versions

558

559

The package supports both stable v1 and beta v1beta APIs:

560

561

### v1 (Stable - Recommended)

562

563

```python

564

from google.shopping.merchant_quota_v1 import QuotaServiceClient

565

566

client = QuotaServiceClient()

567

```

568

569

### v1beta (Beta Features)

570

571

```python

572

from google.shopping.merchant_quota_v1beta import QuotaServiceClient

573

574

client = QuotaServiceClient()

575

```

576

577

The main package (`google.shopping.merchant_quota`) re-exports the v1 API by default for convenience.