Skip to content

Instantly share code, notes, and snippets.

@adiwids
Last active February 8, 2019 06:15
Show Gist options
  • Save adiwids/e4ae37428a165f4fdffbfdc5051029c8 to your computer and use it in GitHub Desktop.
Save adiwids/e4ae37428a165f4fdffbfdc5051029c8 to your computer and use it in GitHub Desktop.
Contoh JSON response RESTFull API

Simple

GET https://ludweb.herokuapp.com/api/v1/relationships.json

{
    "relationships": [
        {
            "name": "engaged_with",
            "display_name": "Engaged with"
        },
        {
            "name": "in_relationship_with",
            "display_name": "In relationship with"
        },
        {
            "name": "married_with",
            "display_name": "Married with"
        },
        {
            "name": "single",
            "display_name": "Single"
        }
    ]
}

Standard

local server via tunneling

GET http://spree.ngrok.io/api/v1/products.json?page=1&per_page=2&sort_by=Name

{
    "products": [
        {
            "id": 4,
            "name": "Edincoat",
            "description": "Quis hic rem enim mollitia. Neque quis tenetur esse omnis qui. In odit praesentium non tempore expedita hic.",
            "price": "599000.0",
            "display_price": "Rp599.000,00",
            "available_on": "2019-02-08T13:13:25.694+07:00",
            "slug": "edincoat",
            "meta_description": null,
            "meta_keywords": null,
            "shipping_category_id": 1,
            "taxon_ids": [
                3
            ],
            "total_on_hand": null,
            "master": {
                "id": 4,
                "name": "Edincoat",
                "sku": "",
                "price": "599000.0",
                "weight": "0.0",
                "height": null,
                "width": null,
                "depth": null,
                "is_master": true,
                "slug": "edincoat",
                "description": "Quis hic rem enim mollitia. Neque quis tenetur esse omnis qui. In odit praesentium non tempore expedita hic.",
                "track_inventory": false,
                "option_values": [],
                "images": [
                    {
                        "id": 5,
                        "position": 1,
                        "attachment_content_type": "image/png",
                        "attachment_file_name": "p_military_01_2x.png",
                        "type": "Spree::Image",
                        "attachment_updated_at": "2019-02-08T13:13:30.819+07:00",
                        "attachment_width": 590,
                        "attachment_height": 590,
                        "alt": null,
                        "viewable_type": "Spree::Variant",
                        "viewable_id": 4,
                        "mini_url": "/spree/products/5/mini/p_military_01_2x.png?1549606410",
                        "small_url": "/spree/products/5/small/p_military_01_2x.png?1549606410",
                        "product_url": "/spree/products/5/product/p_military_01_2x.png?1549606410",
                        "large_url": "/spree/products/5/large/p_military_01_2x.png?1549606410",
                        "zoom_url": "/spree/products/5/zoom/p_military_01_2x.png?1549606410"
                    }
                ],
                "display_price": "Rp599.000,00",
                "options_text": "",
                "in_stock": true,
                "is_backorderable": false,
                "total_on_hand": null,
                "is_destroyed": false
            },
            "variants": [],
            "option_types": [
                {
                    "id": 2,
                    "name": "color",
                    "presentation": "Color",
                    "position": 1
                },
                {
                    "id": 1,
                    "name": "size",
                    "presentation": "Size",
                    "position": 2
                }
            ],
            "product_properties": [],
            "classifications": [
                {
                    "taxon_id": 3,
                    "position": 3,
                    "taxon": {
                        "id": 3,
                        "name": "Jacket",
                        "pretty_name": "Categories -> Jacket",
                        "permalink": "categories/jacket",
                        "parent_id": 1,
                        "taxonomy_id": 1,
                        "taxons": []
                    }
                }
            ],
            "has_variants": false,
            "detail": null
        },
        {
            "id": 5,
            "name": "Escort Guard",
            "description": "Quis hic rem enim mollitia. Neque quis tenetur esse omnis qui. In odit praesentium non tempore expedita hic.",
            "price": "1299000.0",
            "display_price": "Rp1.299.000,00",
            "available_on": "2019-02-08T13:13:25.694+07:00",
            "slug": "escort-guard",
            "meta_description": null,
            "meta_keywords": null,
            "shipping_category_id": 1,
            "taxon_ids": [
                3
            ],
            "total_on_hand": null,
            "master": {
                "id": 5,
                "name": "Escort Guard",
                "sku": "",
                "price": "1299000.0",
                "weight": "0.0",
                "height": null,
                "width": null,
                "depth": null,
                "is_master": true,
                "slug": "escort-guard",
                "description": "Quis hic rem enim mollitia. Neque quis tenetur esse omnis qui. In odit praesentium non tempore expedita hic.",
                "track_inventory": false,
                "option_values": [],
                "images": [
                    {
                        "id": 6,
                        "position": 1,
                        "attachment_content_type": "image/png",
                        "attachment_file_name": "p_trialmaster_01_2x.png",
                        "type": "Spree::Image",
                        "attachment_updated_at": "2019-02-08T13:13:31.904+07:00",
                        "attachment_width": 582,
                        "attachment_height": 582,
                        "alt": null,
                        "viewable_type": "Spree::Variant",
                        "viewable_id": 5,
                        "mini_url": "/spree/products/6/mini/p_trialmaster_01_2x.png?1549606411",
                        "small_url": "/spree/products/6/small/p_trialmaster_01_2x.png?1549606411",
                        "product_url": "/spree/products/6/product/p_trialmaster_01_2x.png?1549606411",
                        "large_url": "/spree/products/6/large/p_trialmaster_01_2x.png?1549606411",
                        "zoom_url": "/spree/products/6/zoom/p_trialmaster_01_2x.png?1549606411"
                    }
                ],
                "display_price": "Rp1.299.000,00",
                "options_text": "",
                "in_stock": true,
                "is_backorderable": false,
                "total_on_hand": null,
                "is_destroyed": false
            },
            "variants": [],
            "option_types": [
                {
                    "id": 2,
                    "name": "color",
                    "presentation": "Color",
                    "position": 1
                },
                {
                    "id": 1,
                    "name": "size",
                    "presentation": "Size",
                    "position": 2
                }
            ],
            "product_properties": [],
            "classifications": [
                {
                    "taxon_id": 3,
                    "position": 4,
                    "taxon": {
                        "id": 3,
                        "name": "Jacket",
                        "pretty_name": "Categories -> Jacket",
                        "permalink": "categories/jacket",
                        "parent_id": 1,
                        "taxonomy_id": 1,
                        "taxons": []
                    }
                }
            ],
            "has_variants": false,
            "detail": null
        }
    ],
    "count": 2,
    "total_count": 6,
    "current_page": 1,
    "per_page": 2,
    "pages": 3,
    "current_sorter": {
        "id": null,
        "name": "Nama",
        "scope": "ascend_by_name"
    },
    "available_sortings": [
        {
            "id": null,
            "name": "Nama",
            "scope": "ascend_by_name"
        }
    ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment