API reference - Liutos/cuckoo GitHub Wiki

Overview

There're several objects in cuckoo:

  • context. Stored in table t_context, briefly represents the current environment;
  • remind. Stored in table t_remind, the date and time specification of the notification;
  • repeat. Stored in table t_repeat, tell cuckoo how to generate the next remind;
  • task. Stored in table t_task, describe the thing to be reminded.

Each object has its own APIs.

APIs

Context

You can create and retrive contexts through HTTP APIs.

Create

POST /context
Content-Type: application/json

{
  "name": "context name"
}

When create successfully, responds 201.

Search

GET /context?name=${name}&sort=${sort}
  • name. Optional. If set, the resulting contexts' name must equal to it;
  • sort. Optional. If set, must be form <field>:<direction>, and control the resulting contexts' order. Default is create_at:desc.

Get current context's name

GET /context/current

Responds

{
  "context": "name"
}

Remind

You can create, retrive, and update reminds.

Create a remind

POST /remind
Content-Type: application/json

{
  "duration": 0,
  "restricted_hours": [],
  "restrictedWdays": [],
  "timestamp": 0,
  "repeat_type": ""
}
  • duration. Optional, means the display duration of a notification window. Not supported by all reminders;
  • restricted_hours. Optional. If set, must be a numeric array contains 24 elements. Controls whether the remind should be triggered at specific hours;
  • restrictedWdays. Optional. Like restricted_hours but controls which day should reminds be triggered;
  • timestamp. Required, the target time a remind should be triggered;
  • repeat_type. Optional. Controls how the next remind be generated.

If create successfully, responds 201 and the remind object.

Retrive a remind

GET /remind/:id
  • id means the id field of target remind object and its nested repeat object.

Update a remind

PATCH /remind/:id
Content-Type: application/json

{
  "duration": 0,
  "restricted_hours": [],
  "restrictedWdays": [],
  "timestamp": 0,
  "repeat_type": ""
}

When update successfully, responds 204.

Task

You can create, delete, retrive, and update tasks.

Create

POST /task
Content-Type: application/json

{
  "brief": "",
  "context_id": 0,
  "detail": "",
  "device": "",
  "icon": "",
  "icon_file": "",
  "remind_id": 0
}
  • brief. Required, a short description of the task;
  • context_id. Optional. If set, means the task should be reminded only when the context match;
  • detail. Optional, a long description of the task;
  • device. Optional, currently the only valid value is mobilePhone, means the notification should be push to cellphone. The only supported way for pushing is by WeChat account;
  • icon. Optional, the link of a icon to be show in notification window;
  • icon_file. Optional, the path of a icon file to be show in Alfred's Workflow result list;
  • remind_id. Optional but recommended, means the id of the remind object attached to this task.

Responds 201 and the task object when create successfully.

Delete

DELETE /task/:id

Remove the specific task.

Get a task

GET /task/:id

Search

GET /task?brief=${brief}&context_id=${context_id}&detail=${detail}&sort=${sort}&state=${state}
  • state. Optional, returns only tasks whose state match.

Get the following tasks

GET /task/following?contextId=${}
  • contextId. Optional, returns only tasks whose context_id field match.

Update a task

PATCH /task/:id
Content-Type: application/json

{
  "brief": "",
  "context_id": 0,
  "detail": "",
  "device": "",
  "icon": "",
  "icon_file": "",
  "remind_id": 0
  "state": ""
}
⚠️ **GitHub.com Fallback** ⚠️