Skip to content

Instantly share code, notes, and snippets.

@jvelo
Last active January 4, 2016 19:09
Show Gist options
  • Save jvelo/8665021 to your computer and use it in GitHub Desktop.
Save jvelo/8665021 to your computer and use it in GitHub Desktop.
Catalog API design
{
"_links": {
"self": {
"href": "/api/products/my-product"
},
"web": {
"href": "/products/my-product"
}
},
"slug": "my-product",
"m odel": "my-model",
"title": "Nom du produit",
"description": "<p>Lorem ipsum dolor</p>\n",
"onShelf": true,
"price": 50,
"weight": null,
"stock": 1,
"addons": [],
"variesWith": "size",
"_embedded": {
"features": {
"size": {
"_links": {
"self": {
"href": "/api/products/my-product/feature/size"
}
},
"xs": {
"_links": {
"self": {
"href": "/api/products/my-product/feature/size/xs"
}
},
"slug": "xs",
"title": "Extra small",
"addons": []
},
"m": {
"_links": {
"self": {
"href": "/api/products/my-product/feature/size/m"
}
},
"slug": "m",
"title": "Medium",
"addons": []
}
},
"color": {
"_links": {
"self": {
"href": "/api/products/my-product"
}
},
"red": {
"_links": {
"self": {
"href": "/api/products/my-product/feature/color/red"
}
},
"slug": "red",
"title": "Ketchup",
"addons": []
},
"yellow": {
"_links": {
"self": {
"href": "/api/products/my-product/feature/color/yellow"
}
},
"slug": "yellow",
"title": "Mayonnaise",
"addons": []
}
}
},
"variants": {
"xs-red": {
"_links": {
"self": {
"href": "/api/products/variants/xs-red"
}
},
"features": {
"color": "red",
"size": "xs"
}
}
},
"images": [
{
"href": "/api/images/lilie",
"title": null,
"slug": "lilie",
"file": {
"extension": "png",
"href": "/images/lilie.png"
},
"description": null,
"thumbnails": [],
"featured": true
},
{
"href": "/api/images/puppet-maria",
"title": null,
"slug": "puppet-maria",
"file": {
"extension": "jpg",
"href": "/images/puppet-maria.jpg"
},
"description": null,
"thumbnails": [],
"featured": null
},
{
"href": "/api/images/ki8zxx7",
"title": null,
"slug": "ki8zxx7",
"file": {
"extension": "jpg",
"href": "/images/ki8zxx7.jpg"
},
"description": null,
"thumbnails": [],
"featured": null
}
]
},
"_relationships": {
"collections": [
{
"href": "/api/collections/collection-1",
"title": "Collection 1",
"slug": "collection-1"
}
]
}
}
{
"slug": "product-1",
"model": "my-model",
"title": "Nom du produit",
"description": "<p>Lorem ipsum dolor</p>\n",
"onShelf": true,
"price": 50,
"weight": null,
"stock": 1,
"featuredImage": {
"href": "/api/images/lilie",
"title": null,
"slug": "lilie",
"file": {
"extension": "png",
"href": "/images/lilie.png"
},
"description": null,
"thumbnails": [],
"featured": true
},
"collections": [
{
"href": "/api/collections/collection-1",
"title": "Collection 1",
"slug": "collection-1"
}
],
"images": [
{
"href": "/api/images/lilie",
"title": null,
"slug": "lilie",
"file": {
"extension": "png",
"href": "/images/lilie.png"
},
"description": null,
"thumbnails": [],
"featured": true
},
{
"href": "/api/images/puppet-maria",
"title": null,
"slug": "puppet-maria",
"file": {
"extension": "jpg",
"href": "/images/puppet-maria.jpg"
},
"description": null,
"thumbnails": [],
"featured": null
},
{
"href": "/api/images/ki8zxx7",
"title": null,
"slug": "ki8zxx7",
"file": {
"extension": "jpg",
"href": "/images/ki8zxx7.jpg"
},
"description": null,
"thumbnails": [],
"featured": null
}
],
"addons": [],
"href": "/api/products/product-1",
"variesWith": "size"
}
GET /api/products/my-tshirt
GET /api/products/my-tshirt/features/
GET /api/products/my-tshirt/features/size/
GET /api/products/my-tshirt/features/size/xs
GET /api/products/my-tshirt/features/color/red
GET /api/products/my-tshirt/variants/
GET /api/products/my-tshirt/variants/xs-red
PUT /api/products/my-tshirt/features/size/xs
POST /api/products/my-tshirt/features/color/ -> 201 created /api/products/my-tshirt/features/color/yellow
PUT /api/products/my-tshirt/variants/xs-red
POST /api/products/my-tshirt/variants/ -> 201 created /api/products/my-tshirt/variants/xxl-yellow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment