Skip to content
xhr edited this page Jul 18, 2011 · 1 revision

The application at http://theartaround.us has an API that allow clients or third-party applications to add new "arts" to the website. The API tries to be as RESTful as possible and accepts only JSON requests (they must have the Content-Type header set to application/json, otherwise the calls will not go through).

The Android client was build around that API, so looking into the Android code might offer some insight.

The current API has the following endpoints available:

Get a list of existing arts

To get a list of arts, simply run a GET request to /api/v1/arts.json.

Create a new art:

Issue a POST on /api/v1/arts.json with the following data:

  • location as an array of [latitude, longitude]
  • category required, you can get the list of categories by issuing a GET request to /api/v1/categories.json
  • title
  • artist
  • year
  • neighborhood required, you can get the list of categories by issuing a GET request to /api/v1/neighborhoods.json
  • ward
  • location_description

The response will be the JSON hash {"success":"$art_slug"} and the HTTP code 200. Invalid requests will have the HTTP status code 400 and it will send back the validation errors in JSON format.

Update an existing art

In order to update an art, you need to issue a PUT request on the endpoint /api/v1/arts/$art_slug.json. You can use the same parameters as the ones in the create call to update the art. For example, to add just a location description add just the location_description parameter.

If the request is successful, the JSON {"success":true} is returned. Otherwise the response will have a 400 status code with the body {"success":false}. Also, if the art is not found, a 404 response is issued.

Upload a photo for an existing art

In order to add photos, you need to have the art slug of an existing art. If you are uploading a new art with photos, yo need to create the art first and then upload photos. The application will automatically process the photos and upload them to the ArtAround Flickr account.

To upload a new photo issue a POST request to /api/v1/arts/$art_slug/photos.json. If the slug is invalid (i.e. there is no art with that slug) you will get a 404 error. You need to send the image file as a file parameter.

Add a comment for an existing art

Using the slug of an existing art, you can upload a new comment by sending a POST request to /api/v1/arts/$art_slug/comments.json. You need to provide the following parameters:

  • name
  • email
  • url
  • text

The email and the URL are validated using a regular expression, so URLs like "example" will not work.

A successful request will yield a response with the JSON hash {"success":true} otherwise you will get a {"success":false}. If you try to send comments to a slug that does not exist, you will get a 404 error.