Wednesday, 21 September 2011

StatDiary API 1.0 Documentation

The service has an open API based on XML-RPC communication. Here you are the current documentation:



Documentation format:

Call structure:


REQUEST: foo.bar(p1, p2, .., [pN-1], [pN])
RESPONSE: {...}
Explanation:
Function name: "foo.bar"
Required parameters: p1, p2, p3, ...
Non-required parameters: ..., [pN-1], [pN]
Response object (format depends on the platform and XML-RPC client): {...}


First you need a valid session:

REQUEST: system.connect()
RESPONSE: {
 sessid: STRING,
 user: {
  uid: INTEGER,
  name: STRING,
  ...
 }
}


User login:
REQUEST: user.login(sessid, username, password)
RESPONSE: {
 sessid: STRING,
 user: {
 uid: INTEGER,
  name: STRING,
  ...
 }
}


User logout:
REQUEST: user.logout(sessid)
RESPONSE: ...
Comment: sometimes you have to logout 2 times. It's a known Drupal Services bug.


User's statistics list:
REQUEST: mystat.myList(sessid, [uid])
RESPONSE: [
 {
  title: STRING, // Stats' name
  nid: INTEGER, // Node ID in Drupal
  latest: INTEGER, // Timestamp of the latest update
  count: INTEGER, // Total number of updates
  config: {
   interval: INTEGER // User settings: preferred update interval
  }
 },
 {
  ...
 },
 ...
]


Submit data:
REQUEST: mystat.submitData(sessid, nid, value, [timestamp], [comment])
RESPONSE: ...


Registering a new user:

REQUEST: mystat.userRegister(sessid, username, email, password)
RESPONSE: ok


Creating a new statistics:
REQUEST: mystat.addStat(sessid, title)
RESPONSE: 1


No comments:

Post a Comment