Get an API Key

Email to vip@snoworange.com with the informations below:

  1. Server: International(http://doit.im) or Mainland(http://doitim.com)
  2. Developer's Doit.im username
  3. Developer Email
  4. Developer Name/ Organization
  5. App Name
  6. App's Description
  7. redirect_uri (e.g., http://myapp.com/callback)

Examination and Approval

After examined and approved, Doit.im will email the information to the proposer.

Start to use the API

UserStore.authenticate

HTTP GET https://i.doitim.com/oauth

This is used to check a username and password in order to create a short-lived authentication session that can be used for further actions.

@param

client_id
redirect_uri
response_type=code

Open the browser in the app and visit the address (e.g., https://i.doitim.com/oauth?client_id=53218f47acee1165829f604116c760f5&redirect_uri=http://i.doitim.com&response_type=code )

It will ask users to log in and authorize. After authorization, it will go to redirect_uri automatically. At the same time, the successful authorization code will be added to the URL.

Exchange code for access_token & refresh_token

HTTP POST https://i.doitim.com/service/oauth2/token

@param

code
client_secret
client_id
redirect_uri
grant_type=authorization_code

E.g.

curl -d "code=f38c898541c4e9639de7c1014416382e&client_secret=97658ad0fec0c46afa6c2d098d4a7cb&client_id=53218f47acee1165829f604116c760f5&grant_type=authorization_code&redirect_uri=http://i.doitim.com" https://i.doitim.com/service/oauth2/token

@return

    {
      "code": "200",
      "message": "success",
      "type": "oauth",
      "data": {
        "token_type": "Bearer",
        "expires_in": 7776000000,
        "access_token": "e034d9a131beab9784bc220397c418fd",
        "refresh_token": "a3b85cfed368848fa0db304378de6eb4",
        "user_id": "50e8df830cf28e61af08198e" 
        }
    }

Exchange refresh_token for access_token

HTTP POST https://i.doitim.com/service/oauth2/token

@param

refresh_token
client_secret
client_id
redirect_uri
grant_type=refresh_token

E.g.

curl -d "refresh_token=a3b85cfed368848fa0db304378de6eb4&client_secret=976508ad0fec0c46afa6c2d098d4a7cb&client_id=53218f47acee1165829f604116c760f5&grant_type=refresh_token&redirect_uri=http://i.doitim.com" https://i.doitim.com/service/oauth2/token

@return

{
  "code": "200",
  "message": "success",
  "type": "oauth",
  "data": {
    "token_type": "Bearer",
    "expires_in": 7776000000,
    "access_token": "20649ac6c66fc8534c20a47009e81a2a",
    "refresh_token": "a3b85cfed368848fa0db304378de6eb4",
    "user_id": "50e8df830cf28e61af08198e" 
  }
}

Create tasks

HTTP POST https://i.doitim.com/service/task

After an application obtains an access token, it sends the token to a Doit.im API in an HTTP authorization header. e.g., (authorization: Bearer 20649ac6c66fc8534c20a47009e81a2a) POST Data (It can be application/x-www-form-urlencoded as well as JSON.)

{
         title: task title,string,can not be null
      notes: task description,string,can be null
      start_at: start time(ms),the number of ms since 1970/1/1,int,can be null
      end_at: deadline(ms),the number of ms since 1970/1/1,int,can be null
      all_day: all day task,boolean,can not be null
      tags: tag,string array ["tag1"],can be null
      project: project name,string,can be null
      context: context name,string,can be null
      goal: goal name,string,can be null

}

The server will find the data according to the name of tags, project, context, goal( it will create new object if this name can not be found).Then the new object will be linked to the new task. Put the task in Inbox by default. If the task has Start time, put the task to the right Box according to its Start time.

E.g.

curl -H "authorization: Bearer 20649ac6c66fc8534c20a47009e81a2a" https://i.doitim.com/service/task -d "title=test&project=new project"

@return

{
  "code": "200",
  "message": "success",
  "type": "task",
  "data": {
    "task_repeatno": "cae2faa0-84ca-11e3-b352-719b368c7bdc",
    "hidden": 0,
    "archived": 0,
    "completed": 0,
    "trashed": 0,
    "deleted": 0,
    "updated": 1390549227343,
    "created": 1390549227338,
    "usn": 16231,
    "title": "test",
    "uuid": "cae2faa0-84ca-11e3-b352-719b368c7bdc",
    "spent_time": 0,
    "estimated_time": 0,
    "pos": 0,
    "local_attachments": [],
    "now": false,
    "tags": [],
    "reminders": [],
    "sent_at": 0,
    "priority": 0,
    "project": "cae14cf0-84ca-11e3-b352-719b368c7bdc",
    "end_at": 0,
    "start_at": 0,
    "all_day": true,
    "attribute": "inbox" 
  }
}

Error code

http status code = 400

throws


{
  "error": "E102",
  "code": "E102",
  "message": "access_token_is_missing  can not find  access_token" 
}
Error

code: "E100" 
  message: "invalid_request_scheme (error request scheme)" 
code: "E101" 
  message: "invalid_request_method (error request method)" 
code: "E102" 
  message: "access_token_is_missing  (do not find access_token)" 
code: "E103" 
  message: "invalid_access_token (access_token does not exsit or has been deleted by the user,or the user has changed the password.)" 
code: "E104" 
  message: "invalid_client_id (client_id does not exsit or has been deleted.)" 
code: "E105" 
  message: "client_id_is_blocked (client_id has been blocked.)" 
code: "E106" 
  message: "access_token_has_expired (access_token has expired.)" 
code: "E107" 
  message: "invalid_request_uri  (The request URL is not registered.)" 
code: "E108" 
  message: "invalid_credencial1 (The user is not authorized to access this data.)" 
code: "E109" 
  message: "invalid_credencial2 (client_id did not apply for the permission.)" 
code: "E110" 
  message: "not_trial_user (The trial user is not registered.)" 
code: "E111" 
  message: "rate_limit_exceeded1  (The user visiting speed is limited.)" 
code: "E112" 
  message: "rate_limit_exceeded2 (The IP visiting speed is limited.)" 
code: "E113" 
  message: "required_parameter_is_missing  (miss parameter)" 
code: "E114" 
  message: "unsupported_grant_type  (error grant_type)" 
code: "E115" 
  message: "unsupported_response_type (error response_type)" 
code: "E116" 
  message: "client_secret_mismatch (client_secret does not mathch.)" 
 code: "E117" 
  message: "redirect_uri_mismatch (redirect_uridoes not mathch.)" 
code: "E118" 
  message: "invalid_authorization_code (authorization_code does not exsit or has expried.)" 
code: "E119" 
  message: "invalid_refresh_token (refresh_tokendoes not exsit or has expried.)" 
code: "E120" 
  message: "username_password_mismatch (The username and passworddo not mathch)" 
code: "E121" 
  message: "invalid_user (The userdoes not exsit or has been deleted.)" 
code: "E122" 
  message: "ser_has_blocked (The user has been blocked.)" 
code: "E123" 
  message: "access_token_has_expired_since_password_changed (access_token has expired because the user change the password.)" 
code: "E124" 
  message: "access_token_has_not_expired (access_tokenhas not expired.)" 
code: "E125" 
  message: "invalid_request_scope (The scope visited isillegal. Don't need pay great attention to this isue. Genearlly,this error will not come out."