Accessing the Bra data

So you want to navigate through the database of bras that Bratabase exposes.

The first thing to do is to visit the brands link on the API's root.

That will show you the list of bras so you can navigate to each of them and from them you can navigate to the list of models for this brand under its models key. Do the same thing to see each model's detail and see its sizes collection to discover the list of sizes we know for the particular model.

Sample

For this example I will be using the command line curl. If you have Mac or Linux you should already have this installed, if you are on Windows you may need to install it.

Another way to explore through the API is through your browser, paste the URLs on your address bar and you will see the responses, the JSONView extension will do wonders

Start by visiting the API root, and we'll navigate from there:

$ curl -i https://api.bratabase.com/
{
    "self": "https://api.bratabase.com/", 
    "meta": {
        "welcome": <string>,
    }, 
    "links": {
        "me": <url>,
        "brands": "https://api.bratabase.com/brands/", 
        "rate_limit": <url>
    }, 
    "rel": "resource", 
    "spec": <url>
}

We are interested on the url under brands, so we follow that.

$ curl -i https://api.bratabase.com/brands/
{
    "links": {}, 
    "self": "https://api.bratabase.com/brands/", 
    "collection": [
        ... not shown for sanity ...
        {
            "bratabase_url": "http://www.bratabase.com/browse/panache/", 
            "href": "https://api.bratabase.com/brands/panache/", 
            "name": "Panache"
        }, 
        ... not shown for sanity ...
    ], 
    "meta": {
       ...
    }, 
    "rel": "collection", 
    "spec": <url>
}

And we will be presented with the brands collection. On this example, we're only interested on the brand Panache so I left that item shown, as you can see it has three keys, we're interested on the href that will direct us to the the Panache brand entity's detail. So we follow that link:

$ curl -i https://api.bratabase.com/brands/panache/

And we'll see the details for the brand Panache! (this is a snapshot as of Sept 19 2013)

{
    "body": {
        "bratabase_url": "http://www.bratabase.com/browse/panache/", 
        "bra_count": 2308, 
        "name": "Panache", 
        "default_sizing_system": "UK", 
        "logo": "http://media.bratabase.com/logos/Panache_Superbra_logo.jpg", 
        "twitter": null, 
        "facebook": null, 
        "slug": "panache", 
        "last_modified_at": "2013-09-19T23:29:13.511558", 
        "official_url": "http://www.panache-lingerie.com/"
    }, 
    "links": {
        "models": "https://api.bratabase.com/brands/panache/models/", 
        "related": "https://api.bratabase.com/brands/panache/related/"
    }, 
    "self": "https://api.bratabase.com/brands/panache/", 
    "meta": {
        "collection": "https://api.bratabase.com/brands/"
    }, 
    "rel": "entity", 
    "spec": null
}

You can see that the body has a bunch of attributes about Panache, its URL, how many bras there are for the brand, a link to an image of the Logo, etc.

Let's check the models that Panache makes, we follow the link under the models key:

$ curl -i https://api.bratabase.com/brands/panache/models/

This will show the first page of the collection of models that Panache makes (that we know of):

{
    "links": {
        "brand": "https://api.bratabase.com/brands/panache/"
    }, 
    "self": "https://api.bratabase.com/brands/panache/models/", 
    "collection": [
        ... not shown for sanity ...
        {
            "bratabase_url": "http://www.bratabase.com/browse/panache/andorra-full-cup-5675/", 
            "href": "https://api.bratabase.com/brands/panache/models/andorra-full-cup-5675/", 
            "name": "Andorra Full Cup"
        }, 
        ... not shown for sanity ...
    ], 
    "meta": {
        ...
    }, 
    "rel": "collection", 
    "spec": null
}

Again, we follow the href key to read the full details for the model we want, in this case Andorra Full cup (5675).

$ curl -i https://api.bratabase.com/brands/panache/models/andorra-full-cup-5675/

And this is the detail for a model, much more interesting:

{
    "body": {
        "bratabase_url": "http://www.bratabase.com/browse/panache/andorra-full-cup-5675/", 
        "code": "5675", 
        "official_url": "http://www.panache-lingerie.com/GB/superbra-by-panache/collection/21540706/Full-Cup-Bra/", 
        "main_stock_picture": null, 
        "bra_count": 267, 
        "full_name": "Andorra Full Cup (5675)", 
        "main_picture": "http://media.bratabase.com/cache/a3/4c/a34c00bde4f2eaab0724f68418827100.jpg", 
        "brand_slug": "panache", 
        "slug": "andorra-full-cup-5675", 
        "is_discontinued": false, 
        "name": "Andorra Full Cup", 
        "last_modified_at": "2013-09-19T23:29:17.915596", 
        "type": "Regular bra", 
        "manufacturer_stock_pictures": [
            {
                "url": "https://bratabase-media.s3.amazonaws.com/pictures/stock/s-panache-andorra-full-cup-5675%3A0xd3643f88L%3A0%3A3811.jpg", 
                "text": "Black"
            }, 
            .... more images ,,,,
        ]
    }, 
    "links": {
        "brand": "https://api.bratabase.com/brands/panache/", 
        "same_cut": "https://api.bratabase.com/brands/panache/models/andorra-full-cup-5675/same-cut/", 
        "related": "https://api.bratabase.com/brands/panache/models/andorra-full-cup-5675/related/", 
        "sizes": "https://api.bratabase.com/brands/panache/models/andorra-full-cup-5675/sizes/"
    }, 
    "self": "https://api.bratabase.com/brands/panache/models/andorra-full-cup-5675/", 
    "meta": {
        "collection": "https://api.bratabase.com/brands/panache/models/"
    }, 
    "rel": "entity", 
    "spec": null
}

Ok, this is a little verbose, but again, all the interesting attributes are under body, there you can see how many bras we have in that model, the name and code of the model, whether or not it is discontinued, but also a link to the official page of the bra by the brand (which many times the brand decides to move) or a picture of the bra and interestingly, a list of official manufacturer's pictures for this bra in case you need to show pictures of this. This response is described on the model's detail page.

Take a look at the links key of the response, it contains a number of other links, to related models and other models with the same cut as this bra. For more information on what's behind these links make sure to follow the model's spec.

I hope that this shows you how to navigate through the API, it is mainly just knowing what is the link you are interested about and following that URL.


Edit