This API documentation should provide you with all you need to know about writing clients using the API provided by Main and Me. The API is clean, stable, and easy to use, as you'll see.

All non-GET requests require authentication. Getting an authentication token for the API from your client is fairly straightforward.

1. Point users to http://www.mainandme.com/api/v1/auth/:provider where :provider is the one of the support OAuth providers, such as 'facebook' or 'twitter'. This should be done in web browser or equivalent view.

2. Users will then go through the authentication process with their provider. If the authorization is successful the application will return a JSON object back to your client containing the user's details as well as an API token.

{
  "id": 1,
  "name": "Bob Smith",
  "email": "bob@example.com",
  "lat": 42.40470906625,
  "lng": -71.12506773,
  "admin": true,
  "like_count": 17,
  "follower_count": 0,
  "created_at": "2012-03-16T17:14:17Z",
  "updated_at": "2012-03-27T17:30:36Z",
  "avatar_url": "http://graph.facebook.com/1234567890/picture?type=square",
  "api_token": "177139e544791c0a6383a37344a37e41",
  "is_following": false,
  "permissions": {
    "manage": true,
    "read": true,
    "create": true,
    "update": true,
    "destroy": true
  }
}
      

3. Pass the API token as a header when making API requests: Authentication: 177139e544791c0a6383a37344a37e41. Alternatively, if you don't like doing that, you can pass it along as query parameter: http://www.mainandme.com/api/v1/products?_token=177139e544791c0a6383a37344a37e41