The Account API is called on account.php. This is located at http://api.synccit.com/account.php. If not using synccit.com, this should be shown on devices page.
Basic idea. When someone clicks on a link on reddit, the ID of link clicked is sent here. When someone clicks on a comment thread, the number of comments that thead has and it's ID is sent here. So when looking at reddit later, no matter what device, the link will show up read and if there are any new comments.
The API includes 2 variables. The API version and revision. The version is only changed when major changes to the API occur and will break older uses of it. The revision is for smaller changes. This usually means adding features or small changes that don't break any older use of the API.
To determine the version and revision of the API being used, check the headers sent by api.php. curl -I http://api.synccit.com/account.php
gives me X-API: 1
and X-Revision: 1
. To see how revisions change, you can check the account.php history.
Login code and passwords
For added security, instead of using the account password for each call, it uses an login code. These are created and returned by doing a login call. This is similar to the auth code of the standard API, but is longer and the user never interacts with it.
username
- synccit username
login
- login code returned by login command
- Like auth code in standard API, but much longer and user never interacts with it
- Note: not needed for create and login calls
dev
- Your developer name
- Name you want to appear as, such as synccit-userscript or iReddit
devauth
- developer authentication
- Note: Not implemented yet. This will allow you to ensure only you can use your developer name
mode
- Action you're taking.
create
- create new accountlogin
- check username/password and get login codedelete
- delete auth codehistory
- returns last 20 links visiteddevices
- returns list of devices with auth codesaddauth
- add new device/auth codeapi
- API version you're using (not required)
- Current version is
1
auth
- The auth code of the device
- Usually a 6 character string
device
- Device name
- The device name the user entered while setting up the auth codes
created
- Unix timestamp of when the device was added
id
- Reddit link id (see above)
lastvisit
- Unix time stamp of when link was last visited
- Defaults to
0
if link has never been visited comments
- Number of comments read
- Defaults to
0
if comments have never been viewed commentvisit
- Unix time stamp of when comments were last viewed
- Defaults to
0
if comments have never been viewed
password
- Password for account
email
- Email to be associated with account (create account only)
- Not required
JSON data is sent of POST variable data
The GET or POST variable type
should be json (though not required)
{
"username" : "james",
"auth" : "9m89x0",
"dev" : "synccit json",
"mode" : "update",
"links" : [
{
"id" : "111111"
},
{
"id" : "222222",
"comments" : "132"
},
{
"id" : "333333",
"comments" : "313",
"both" : true
},
{
"id" : "444444"
}
]
}
synccit username is james
. Auth code is 9m89x0
. The developer is synccit json
. Mode is update
This will update 4 links.
111111
- Link marked as read at current time222222
- 132 comments marked as read. Link still unread333333
- Link marked as read at current time. 313 comments marked as read444444
- Link marked as read at current time
Returns
Success
{
"success" : "4 links updated"
}
Error
{
"error" : "ERROR_CODE"
}
{
"username" : "james",
"auth" : "9m89x0",
"dev" : "synccit json",
"mode" : "read",
"links" : [
{
"id" : "111111"
},
{
"id" : "222222"
},
{
"id" : "333333"
},
{
"id" : "555555"
}
]
}
Nearly same as update call. Mode is now read
instead of update
4 links are checked. Only need id
Returns
[
{
"id" : "111111",
"lastvisit" : "1357891889",
"comments" : "0",
"commentvisit" : "0"
},
{
"id" : "222222",
"lastvisit" : "0",
"comments" : "132",
"commentvisit" : "1357891889"
},
{
"id" : "333333",
"lastvisit" : "1357891889",
"comments" : "313",
"commentvisit" : "1357891889"
}
]
3 links are returned.
111111
- Link visited at1357891889
. Comments never viewed222222
- 132 comments read. Link never visited333333
- Link visited at1357891889
. 313 comments read
Link 555555
not returned since it was never updated.
{
"username" : "newuser",
"password" : "thebestpasswordever",
"dev" : "synccit demo",
"email" : "[email protected]",
"mode" : "create"
}
Creates new user with username newuser
and password thebestpasswordever
. And an email of [email protected]
, though email is not required. Mode is create
Returns
Success
{
"success" : "account created"
}
Error
{
"error" : "ERROR_CODE"
}
{
"username" : "newuser",
"password" : "thebestpasswordever",
"dev" : "synccit demo",
"device" : "developer API device",
"mode" : "addauth"
}
Creates a new auth code for the user newuser
with password thebestpasswordever
. Device name is developer API device
. Mode is addauth
Returns
Success
{
"success" : "device key added",
"device" : "developer API device",
"auth" : "409ssj"
}
New device key added with auth code of 409ssj
. Device name is also returned back
Error
{
"error" : "ERROR_CODE"
}
XML data is sent on POST variable data.
The GET or POST variable type
has to be set to xml or, as of API revision 10, the first 4 charaters of POST data are <?xml
<?xml version="1.0"?>
<synccit>
<username>james</username>
<auth>9m89x0</auth>
<dev>synccit xml</dev>
<mode>update</mode>
<links>
<link>
<id>111111</id>
</link>
<link>
<id>222222</id>
<comments>132</comments>
</link>
<link>
<id>333333</id>
<comments>313</comments>
<both>true</both>
</link>
<link>
<id>444444</id>
</link>
</links>
</synccit>
synccit username is james
. Auth code is 9m89x0
. The developer is synccit xml
. Mode is update
This will update 4 links.
111111
- Link marked as read at current time222222
- 132 comments marked as read. Link still unread333333
- Link marked as read at current time. 313 comments marked as read444444
- Link marked as read at current time
Returns
Success
<?xml version="1.0"?>
<synccit>
<success>4 links updated</success>
</synccit>
Error
<?xml version="1.0"?>
<synccit>
<error>ERROR_CODE</error>
</synccit>
<?xml version="1.0"?>
<synccit>
<username>james</username>
<auth>9m89x0</auth>
<dev>synccit xml</dev>
<mode>read</mode>
<links>
<link>
<id>11111</id>
</link>
<link>
<id>222222</id>
</link>
<link>
<id>333333</id>
</link>
<link>
<id>555555</id>
</link>
</links>
</synccit>
Nearly same as update call. Mode is now read
instead of update
4 links are checked. Only need id
Returns
<?xml version="1.0"?>
<synccit>
<links>
<link>
<id>111111</id>
<lastvisit>1357881500</lastvisit>
<comments>0</comments>
<commentvisit>0</commentvisit>
</link>
<link>
<id>222222</id>
<lastvisit>0</lastvisit>
<comments>132</comments>
<commentvisit>1357881500</commentvisit>
</link>
<link>
<id>333333</id>
<lastvisit>1357881500</lastvisit>
<comments>313</comments>
<commentvisit>1357881500</commentvisit>
</link>
</links>
</synccit>
3 links are returned.
111111
- Link visited at1357881500
. Comments never viewed222222
- 132 comments read. Link never visited333333
- Link visited at1357891889
. 313 comments read
Link 555555
not returned since it was never updated.
<?xml version="1.0"?>
<synccit>
<username>newuser</username>
<password>thebestpasswordever</password>
<dev>synccit demo</dev>
<email>[email protected]</email>
<mode>create</mode>
</synccit>
Creates the user newuser
with a password of thebestpasswordever
. And an email of [email protected]
, though email is not required. Mode is create
Returns
Success
<?xml version="1.0"?>
<synccit>
<success>account created</success>
</synccit>
Error
<?xml version="1.0"?>
<synccit>
<error>ERROR_CODE</error>
</synccit>
<?xml version="1.0"?>
<synccit>
<username>newuser</username>
<password>thebestpasswordever</password>
<dev>synccit demo</dev>
<device>developer API device</device>
<mode>addauth</mode>
</synccit>
Creates a new auth code for the user newuser
with password thebestpasswordever
. Device name is developer API device
. Mode is addauth
Returns
Success
<?xml version="1.0"?>
<synccit>
<success>device key added</success>
<device>developer API device</device>
<auth>303b09</auth>
</synccit>
Returns auth code under auth
. Use this for future API calls for this user.
Error
<?xml version="1.0"?>
<synccit>
<error>ERROR_CODE</error>
</synccit>
Data just sent as POST variables
username=james&auth=9m89x0&dev=stext&mode=update&links=111111,333333,444444&comments=222222:132,333333:313
synccit username is james
. Auth code is 9m89x0
. The developer is stext
. Mode is update
This will update 4 links.
111111
- Link marked as read at current time222222
- 132 comments marked as read. Link still unread333333
- Link marked as read at current time. 313 comments marked as read444444
- Link marked as read at current time
Returns
Success
success: 4 links updated
Error
error: ERROR_CODE
username=james&auth=9m89x0&dev=stext&mode=read&links=111111,222222,333333,555555
Nearly same as update call. Mode is now read
instead of update
4 links are checked. Only need links
variable. Comments are automatically checked
Returns
111111:1356731259;0:0,
222222:0;132:1356731259,
333333:1356731259;313:1356731259,
Format is:
link_id:link_visited_time;comment_count:comment_visited_time,
3 links are returned.
111111
- Link visited at1356731259
. Comments never viewed222222
- 132 comments read. Link never visited333333
- Link visited at1356731259
. 313 comments read
Link 555555
not returned since it was never updated.
no post data
- No post data sent or at least none that we know what to do with
not authorized
- Username and auth code combination doesn't work
no links requested
- No links submitted to be checked
no links found
- None of links requested have history (only in plain text mode)
database error
- Error executing query. Likely something on our end
username or password wrong
- That username and password combination isn't valid
Create account errors
email not valid
- Not valid email given. Only checks it '@' exists
username needs to be at least 3 characters long
password needs to be at least 6 characters long
username must consist of letters, numbers, or underscores
username already exists
- Username is taken. Try something else