Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit b7aaabe

Browse files
authored
Merge pull request #5907 from dewimagento/filtering.md
Filtering.md
2 parents 56b847a + 2928405 commit b7aaabe

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

_data/toc/marketplace-api.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ pages:
2424
- label: Reports
2525
url: /marketplace/eqp/v1/reports.html
2626
versionless: true
27+
28+
- label: Filtering
29+
url: /marketplace/eqp/v1/filtering.html
30+
versionless: true
31+

marketplace/eqp/v1/filtering.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
group: marketplace-api
3+
title: Filtering
4+
---
5+
6+
Some GET batch request endpoints support sorting, filtering, and pagination.
7+
8+
Currently, the `files` endpoints support only pagination, while package endpoints support all three.
9+
10+
## Paginating batch requests
11+
12+
The following GET request parameters are passed to request a subset of the results.
13+
14+
|Field|Type|Default|Description|
15+
|-----|----|-------|-----------|
16+
|offset|int|0|The record in the list from which to begin. The list starts at 0.|
17+
|limit|int|20|Number of records to return, starting from `offset`. -1 will return all remaining records.|
18+
19+
The result comes with a header `X-Total-Count`, which gives the number of total records.
20+
21+
## Sorting batch requests
22+
23+
If a field is listed as filterable, it is also sortable. To sort, pass in the `sort` GET parameter:
24+
25+
|Field|Type|Description|
26+
|-----|----|-----------|
27+
|sort|string|Comma-separated list of field names to sort by. Fields may be prefixed with '-' to sort in descending order, or '+' for ascending.|
28+
29+
For example, to sort all versions of all packages, M2 packages first, then M1,
30+
grouped alphabetically by name, with newest packages first:
31+
32+
```HTTP
33+
GET /rest/v1/products/packages/?sort=-platform,+name,-version
34+
```
35+
36+
## Filtering batch requests
37+
38+
You can use multiple response fields as filters in batch GET requests.
39+
40+
For example, to get a package with the submission_id "12345", one way is
41+
to call the single-object convenience endpoint, without using filters:
42+
43+
```HTTP
44+
GET /rest/v1/products/packages/12345/
45+
```
46+
47+
Or alternatively, call the batch endpoint to return a list and filter it by `submission_id`,
48+
so that the list contains only one item:
49+
50+
```HTTP
51+
GET /rest/v1/products/packages/?submission_id=12345
52+
```
53+
54+
The difference is that the first returns a single object or an error, while the second returns a list containing zero or one elements.
55+
The following request filters all `themes` sorted by `platform` in ascending order and `created_time` in descending order:
56+
57+
**Request**
58+
59+
```bash
60+
curl -X GET \
61+
-H 'Authorization: Bearer baGXoStRuR9VCDFQGZNzgNqbqu5WUwlr.cAxZJ9m22Le7' \
62+
https://developer-api.magento.com/rest/v1/products/packages?type=theme&sort=+platform,-created_time
63+
```
64+
65+
**Response**
66+
67+
A list of theme packages can be returned in the same way as described in [Get package details](packages.html#get-package-details).

0 commit comments

Comments
 (0)