API into your Farm!

You can do all sorts of cool things using The Coop APIs.

Action URL Method Sandbox
Retrieves user that's tied to the access token /api/me GET  
Unlock the Barn /api/USER_ID/barn-unlock POST try it
Put the Toilet Seat Down /api/USER_ID/toiletseat-down POST try it
Feed Your Chickens /api/USER_ID/chickens-feed POST try it
Collect Eggs from Your Chickens /api/USER_ID/eggs-collect POST try it
Get the Number of Eggs Collected Today /api/USER_ID/eggs-count POST try it

Success Response

{
    "action": "The action (e.g. \"barn-unlock\")",
    "success": true,
    "message": "Some summary message",
    "data": "A raw, related piece of data if applicable"
}

Error Response

{
    "error": "A key (e.g. access_denied) for the error",
    "error_description": "A longer description of the error"
}

Authentication via OAuth

COOP's API uses OAuth for authentication and supports the following grant types:

  • Client Credentials
  • Authorization Code

Here are the important endpoints and their parameters

URL Description
POST /token

The endpoint used for requesting an access token, using either the authorization_code or client_credentials grant type.

http://coop.apps.symfonycasts.com/token

This accepts the following POST fields:

  • client_id
  • client_secret
  • grant_type Either client_credentials or authorization_code
  • redirect_uri (authorization_code only) Must match redirect_uri from the original /authorize call
  • code (authorization_code only) The authorization code
GET /authorize

When using the authorization code (traditional "web") grant type, start by redirecting the user to this URL:

http://coop.apps.symfonycasts.com/authorize

This accepts the following GET parameters

  • client_id
  • response_type Either code or token
  • redirect_uri (authorization_code only) The URL that COOP will redirect the user back to after granting or denying authorization.
  • scope The permissions the user should authorize, separated by a space (e.g. "eggs-count profile"). One of:
    barn-unlock
    toiletseat-down
    chickens-feed
    eggs-collect
    eggs-count
    profile
  • (Optional) state A key that's returned on the redirect_uri that can be used as a CSRF token.

Once the user is redirected back to redirect_uri, you'll have a code query parameter. Use this with the next endpoint to exchange that code for an access token.

Authorizing your API Requests

Once you have an access token, send it via the Authorization header:

POST /collect-eggs HTTP/1.1
Host: coop.apps.symfonycasts.com
Authorization: Bearer ACCESSTOKENHERE

Here is a list of your applications:

Well let's not waste any more time... Create your Application!