All requests must have the "API-KEY" header to be permitted. If you do not have an API Key you can obtain one at www.bigskirmish.com/developer/register.
All request have an API Key header that is passed like this:
`"API-KEY: your_api_key"
If you do not have an API Key header, with a valid API Key as the value, your request will respond back with a 404 status.
HTTP Method: POST
HEADERS:"API-KEY: your_api_key"
URL Endpoint: /users
Body:
{"first_name":"Walter",
"last_name":"White",
"username":"heisenberg",
"email":"[email protected]",
"password":"a_secure_password"
}
HTTP Status Code: 201
{"user":
{"id":1,
"first_name":"Walter",
"last_name":"White",
"username":"heisenberg",
"email":"[email protected]",
"token":"39cb0516-687GHE0194730f-4e8a-fd2b24835dd"
}
}
HTTP Method: POST
HEADERS:"API-KEY: your_api_key"
URL Endpoint: /users/authenticate
Body:
{"login":"your_email_address",
"password":"a_secure_password"
}
HTTP Status Code: 200
{"user":
{"id":1,
"first_name":"Walter",
"last_name":"White",
"username":"heisenberg",
"email":"[email protected]",
"token":"39cb0516-687GHE0194730f-4e8a-fd2b24835dd"
}
}
Note:
"login" is the field because at some point this will accept a
username or an email address. Currently only email is supported
HTTP Method: GET
Headers: "Authorization:Token token='39cb0516-687GHE0194730f-4e8a-fd2b24835dd'"
URL Endpoint: /users/:user_id
Body: no body
HTTP Status Code: 200
{"user":
{"id":1,
"first_name":"Walter",
"last_name":"White",
"username":"heisenberg",
"email":"[email protected]",
"token":"39cb0516-687GHE0194730f-4e8a-fd2b24835dd"
}
}
HTTP Method: GET
Headers: "Authorization:Token token='39cb0516-687GHE0194730f-4e8a-fd2b24835dd'"
URL Endpoint:/users/:user_id/wars
Body:
{"war":
{"name":"Darts",
"has_end":true,
"ending_date":1406786400,
"ending_score":4,
"prize":"Loser buys dinner",
"is_private":false,
"open_registration":false
}
}
First Time Registrant:
- Requests have API Key
- Registers by passing username/password
- Writes to token for user
- Token is passed back in create response
- Next requests have API Key header and Authorization Header for token
All Subsequent Uses:
- Enters username/password and reads user token for session
- Pass user token from then on out to register.
- If user logs out it sets the token to nil