Search…
Simple call sequence example
Learn how to get a list of categories.

Step 1: (Optional). Get an OAuth access token

To get the OAuth access token, use the POST oauth20/token under the OAuth Token resource.
Request Sample
Response Body
1
POST /oauth20/token/
2
{
3
4
client_id=a78b756bd47e258841d7f007f3f62a&grant_type=password
5
6
}
Copied!
1
{
2
3
"access_token": "your_access_token",
4
5
"token_type": "bearer",
6
7
"expires_in": "3599",
8
9
"refresh_token": "6131be829ea22ccc5ed1199024ba060bd7ed87e8"
10
11
}
Copied!

Step 2: Get the categories

To get the top-level categories, use the GET shoppers/me/categories resource.
Use the access token acquired in step 1 as the bearer token in the Authorization header (see Request sample below). This example request overrides the default text format (XML) for the Commerce API. In the Accept header, the format is set to JSON as application/json.
The response returns the top-level categories available in the Categories resource (see Response sample below). The response returns the default resource fields available for a resource and the displayName, thumbnailImage, and products resource fields. You can expand or filter the response using the fields or expand query parameters. The links provided in the response indicate the next possible step you could take in a call sequence.
Request Sample
Response Sample
1
GET https://api.digitalriver.com/v1/shoppers/me/categories HTTP/1.1
2
3
Header:
4
5
Accept: application/json
6
7
Authorization: bearer your_access_token
Copied!
1
1. {"categories": {
2
2. "relation": "http://developers.digitalriver.com/v1/shoppers/CategoriesResource",
3
3. "uri": "http://api.digitalriver.com/v1/shoppers/me/categories",
4
4. "category": [
5
5. {
6
6. "relation": "http://developers.digitalriver.com/v1/shoppers/CategoriesResource",
7
7. "uri": "http://api.digitalriver.com/v1/shoppers/me/categories/38366200",
8
8. "displayName": "Books",
9
9. "thumbnailImage": null,
10
10. "products": {
11
11. "relation": "http://developers.digitalriver.com/v1/shoppers/ProductsResource",
12
12. "uri": "http://api.digitalriver.com/v1/shoppers/me/categories/38366200/products"
13
13. }
14
14. },{
15
15. "relation": "http://developers.digitalriver.com/v1/shoppers/CategoriesResource",
16
16. "uri": "http://api.digitalriver.com/v1/shoppers/me/categories/38366400",
17
17. "displayName": "Accessories",
18
18. "thumbnailImage": null,
19
19. "products": {
20
20. "relation": "http://developers.digitalriver.com/v1/shoppers/ProductsResource",
21
21. "uri": "http://api.digitalriver.com/v1/shoppers/me/categories/38366400/products"
22
22. }
23
23. }, {
24
24. "relation": "http://developers.digitalriver.com/v1/shoppers/CategoriesResource",
25
25. "uri": "http://api.digitalriver.com/v1/shoppers/me/categories/38366700",
26
26. "displayName": "Flyleaf Folio",
27
27. "thumbnailImage": null,
28
28. "products": {
29
29. "relation": "http://developers.digitalriver.com/v1/shoppers/ProductsResource",
30
30. "uri": "http://api.digitalriver.com/v1/shoppers/me/categories/38366700/products"
31
31. }
32
32. },{
33
33. "relation": "http://developers.digitalriver.com/v1/shoppers/CategoriesResource",
34
34. "uri": "http://api.digitalriver.com/v1/shoppers/me/categories/40436400",
35
35. "displayName": "Newspapers",
36
36. "thumbnailImage": "http://drh1.img.digitalriver.com/DRHM/Storefront/Company/.../thumbnail/blog2_thumb_image.jpg",
37
37. "products": {
38
38. "relation": "http://developers.digitalriver.com/v1/shoppers/ProductsResource",
39
39. "uri": "http://api.digitalriver.com/v1/shoppers/me/categories/40436400/products"
40
40. }
41
41. },{
42
42. "relation": "http://developers.digitalriver.com/v1/shoppers/CategoriesResource",
43
43. "uri": "http://api.digitalriver.com/v1/shoppers/me/categories/40436500",
44
44. "displayName": "Blogs",
45
45. "thumbnailImage": null,
46
46. "products": {
47
47. "relation": "http://developers.digitalriver.com/v1/shoppers/ProductsResource",
48
48. "uri": "http://api.digitalriver.com/v1/shoppers/me/categories/40436500/products"
49
49. }
50
50. }
51
51. ]
52
52. }}
Copied!

Reading a JSON response

A JSON response object is an unordered set of name-value pairs. the {curly brackets} describe objects. The [square brackets] describe lists. The Response sample above starts a list on line 4 and ends it on line 51. Text strings must be enclosed by double-quotes. JSON directly supports number values, so numbers are not treated as strings and are not enclosed by double-quotes. JSON does not support date-time values; therefore, dates and timestamps are typically formatted as strings.
Last modified 1yr ago