Skip to content
Snorre Magnus Davøen edited this page Jul 16, 2013 · 32 revisions

The Microbrewit API is a RESTful API that consist of a series of resources (users, recipees, breweries, etc) each with it's own route (api.microbrew.it/user/...). The API is developed according to format rules provided in the JSON API draft.

Requests

The API use various forms of requests depending on the action being done for a resource. Each request will return a standard json response. If you want to use the API from within a browser you need to include a named parameter callback in the request, with a function name as value. This name will be used to wrap the JSON response. See JSONP on Wikipedia for more information.

Responses

The API returns JSON responses in two general forms:

Message responses

{'message': 'Info about response',
'something', 'somevalue'}

All message responses includes a message key with a corresponding string value. This is used to provide information about the response. The response object can also include other data depending on which URL is requested.

Example:http://api.microbrew.it/user/login/bob?password=pass&callback=userlogin

Yields:userlogin({})

Error responses:

{'error': 'Info about error',
'errorcode', 'somecode'}

Error response objects will always include an error key which can be used to identify when errors occur. They will also include an error code which can be used to identify the nature and origin of the errors. The error object may include other information as well.

API URLs

Users

Add user

POST - api.microbrew.it/user/add

User login

POST - api.microbrew.it/user/login/:username

User logout

GET - api. microbrew.it/user/logout/:username

User update

POST - api.microbrew.it/user/update/:username (username needs to be implemented in node api) Request params: “email”, “password” and “settings”.

User(s) details

GET - api.microbrew.it/user/:userids

Example usage:

Single user: http://api.microbrew.it/user/thisismyusername

{users: [{
  id: 'thisismyusername',
  href: 'http://api.microbrew.it/user/thisismyusername',
  username: 'thisismyusername',
  email: 'some@email.com',
  breweryName: 'My Awesome Brewery',
  settings: {}
  }]
}

Recipees

Add recipee

api.microbrew.it/recipee/add

Recipee details

api.microbrew.it/beer/details/:breweryname/:breweryid/:beer

Breweries

Malts

Add malt

GET - api.microbrewit/malt/add

Update malt

GET - api.microbrew.it/malt/update/:malt Request params: ….

Clone this wiki locally