Skip to content


Subversion checkout URL

You can clone with
Download ZIP

API: login

buddydvd edited this page · 6 revisions

Use a POST to /api/login/USERNAME to authenticate with reddit, where USERNAME is the name to authenticate as. Several parameters must be sent along with the post:

field sample value explanation
user example The username to authenticate as. This is redundant, but required.
passwd hunter2 The plain-text password for the account.
api_type json Must be json for the style of auth used in this documentation.

Login now supports SSL, use a POST to:

POST Example

POST /api/login/example HTTP/1.1
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Content-Length: 41



The HTTP status code of the response will always be a 200 (OK), and the contents of the body will be a JSON object, regardless of authentication success. To determine the result of the operation, look at the contents of the JSON payload.

The top level object has a single attribute, json, which maps to an object with all the relevant data in it. To determine success, check the size of the json.errors array.


A successful authentication attempt will have a zero-length json.errors array, and a data attribute containing the user's cookie and modhash (see glossary on the API page).

{"json": {"errors": [], "data": {"modhash": "u4abc21302316ad40013feb16cfccb0b11b786596e5194de14", "cookie": "1234567,2011-07-12T14:53:59,0200b365fa02c61f9532ab244b214bd481941492"}}}

The cookie and modhash can be treated as lasting forever at the moment.


After an invalid login attempt, the json.errors array will have entries, and no other attributes will be present.

{"json": {"errors": [["WRONG_PASSWORD", "invalid password"]]}}
Something went wrong with that request. Please try again.