Written by Patrick
Over a week ago
The CollyBird API is the primary way to read and write to the CollyBird system. It's an HTTP-based API that apps can use to programmatically create, replace, update and delete with resources in the system.
All data transfers conform to HTTP/1.1, and all endpoints require HTTPS. Because the Graph API is HTTP-based, it works with any language that has an HTTP library, such as cURL and urllib. This means you can use the Graph API directly in your browser. For example, requesting this URL in your browser...
https://www.collybird.com/api/roshambo
... is equivalent to performing this cURL request:
curl 'http://localhost/api/roshambo' \
-H 'Accept: application\json' \
-H 'Authorization: Bearer 42|K...y'
All requests are passed to the www.collybird.com
host URL.
Access tokens allow your app to access the Roshambo API. Almost all Roshambo API endpoints require an access token of some kind, so each time you access an endpoint, your request may require one. They typically perform two functions:
To read from or write to a resource such as the Roshambo service, you construct a request that looks like the following:
{HTTP method} https://www.collybird.com/{resource}?{query-parameters}
The components of a request include:
After you make a request, a response is returned that includes:
The CollyBird API uses the HTTP method on your request to determine what your request is doing. Depending on the resource, the API may support operations including actions, functions, or CRUD operations described below.
Method | Desription |
GET | Read data from a resource. |
POST | Create a new resource, or perform an action. |
PUT | Replace a resource with a new one. |
DELETE | Remove a resource. |
Curl and Postman are tools that you can use to build and test requests using the CollyBird API. Curl is run from the command line and Postman has a GUI.
The following example retrieves a list of matches from the Roshambo service.
Request:
curl 'https://www.collybird.com/api/login' \
-H 'Accept: application\json' \
-X POST -d email='[email protected]' \
-d password='GetSchwifty!' \
-d device_name='curl-client'
Response:
{"token":"42|TyXIzXUh5EoxQi7Gqd4fFkNC8TeoLrrUrh7A7OdE"}
The following example retrieves a list of matches from the Roshambo service.
Request:
curl 'https://www.collybird.com/api/roshambo' \
-H 'Accept: application\json' \
-H 'Authorization: Bearer 42|TyXIzXUh5EoxQi7Gqd4fFkNC8TeoLrrUrh7A7OdE'
Response:
{
"hits": {
"found": 3,
"hit": [{
"roshambo_id": "98922767-1771-499e-90ae-da1160336db1",
"url": "https:\/\/www.collybird.com\/projects\/roshambo\/98922767-1771-499e-90ae-da1160336db1",
"ourMove": "S",
"theirMove": null,
"winner": null
}, {
"roshambo_id": "98922764-781d-4784-a7bc-a5e3e6240d84",
"url": "https:\/\/www.collybird.com\/projects\/roshambo\/98922764-781d-4784-a7bc-a5e3e6240d84",
"ourMove": "R",
"theirMove": null,
"winner": null
}, {
"roshambo_id": "9892275d-1a9c-47b4-8615-cf5faf0ab4ca",
"url": "https:\/\/www.collybird.com\/projects\/roshambo\/9892275d-1a9c-47b4-8615-cf5faf0ab4ca",
"ourMove": "P",
"theirMove": null,
"winner": null
}]
}
}
The following example creates a new roshambo match with the rock as the move.
Request:
curl 'https://www.collybird.com/api/roshambo/create' \
-H 'Accept: application\json' \
-H 'Authorization: Bearer 42|TyXIzXUh5EoxQi7Gqd4fFkNC8TeoLrrUrh7A7OdE' \
-d move='R'
Response:
{
"attacker_id": 13,
"attacker_move": "R",
"roshambo_id": "989229c1-843b-4d3e-a836-19c150283fcc",
"updated_at": "2023-02-27T22:02:11.000000Z",
"created_at": "2023-02-27T22:02:11.000000Z"
}