Skip to content
shz edited this page Sep 16, 2011 · 8 revisions

Internal Rest API

This API is used in various places for anything needs a REST api, file uploads, social integration, etc. The various urls and such are listed below. REST may be an overstatement in places.

Important Note: Every resource in this API has two ways of returning its results. The standard way is through a typical HTTP response. The second, opt-in method is to redirect to a specific URL, which will then have a query parameter added depending on the result; failure messages (4xx/5xx) use error, success messages use success. This redirect URL must be absolute, and is specified by settings the return query parameter on the initial request. This return URL may itself have query parameters specified, and they'll be handled gracefully.

That's all rather complicated, so here's an example:

The call:
/foo?return=http://shazam.com/?bar=baz # Pretend that URL is escaped

Resulting redirect:
http://shazam.com/?bar=baz&success=yay

CORS is supported on all resources, but the only allowed origin is the client url. Note that this isn't enforced on the server, so if you're making a cross-origin request on via some non-browser means you won't have to worry about it.

Authentication

/iapi/auth

get Arguments: email [password]

Checks authentication status for the given email address.

Returns:

400 - Missing email in query
500 - Wild and crazy db error
404 - Specified email not registered
200 - Email registered and passwords match
403 - Email registered, passwords don't match

signup

post Body: plaintext email address to sign up

Attempts to sign up a user.

Returns

201 - User signed up successfully; response contains hashed password
409 - User with that email already exists

Listing Resources

listing

post Body: multipart/form-data

Fields:

email
password
description
latitude
longitude
price

Files:

photo

Returns:

201 - Created successfully.  Returned content is the listing ID
400 - Missing a field
403 - Bad login credentials
500 - Server error

Social Resources

See Social Integration. All the same IAPI magic is there, but it deserved its own section, and it got one.

Clone this wiki locally