|
We've got a full API that gives you access to the chewy center (er, the data) of BlockChalk, in a variety of formats. This is our first release of the API and we'd love to hear your feedback.
Current API version: v0.68 (5/9/10)
Basic concepts
- You must either specify a custom user agent for all API requests OR include a consumer URL parameter. The user agent must be of the form blockchalk-*; that is, it must contain an application-specific identifier prefixed with the phrase blockchalk-. The consumer URL parameter value can be anything but should be as descriptive as possible.
- Please drop us a line and let us know your name, the name and purpose of your application, and the user agent you will be using.
- "User-specific" operations require a unique user ID code per user. You must request this code once per unique user of your application and then store and reuse it for all user-specific calls. Note that the "General" operations do not require this user ID code because they are not user-specific operations.
- All requests are in a simple HTTP GET or POST format. Data is by default returned in XML format but most requests can return JSON or RSS instead. RSS responses support GeoRSS where appropriate.
Usage guidelines
In general, do unto BlockChalk as you would have it do unto you. More specifically:
- Be honest: do not post chalks to locations where your user is not actually located.
- Play nice: do not spam people or places.
- Show mercy: do not make large numbers of simultaneous requests. Our bandwidth and CPU are not limitless.
- Kick ass: do build interesting things with these interfaces, and let us know how we can improve them.
Definition of terms (used in italics below)
- latitude: user's current latitude, to a max of 8 decimal places; please provide as much precision as possible.
- longitude: user's current longitude, to a max of 8 decimal places; please provide as much precision as possible.
- userId: 32-digit ID used to identify the user; you must request this code (via user/new, see below), cache it and reuse it in order to behave as the same user across sessions and access replies addressed to this user.
- message: contents of new chalk or reply, max of 256 characters.
- chalkId: 12-digit ID of a chalk (this can also be found in a given chalk's URL; e.g. http://blockchalk.com/6b6f068a603e).
- comment / chalkback: comments are public responses to chalks, connected to the original chalk and all its other comments via a threadId (see below). "Comment" is synonymous with "chalkback", but "chalkback" was deprecated in favor of "comment" when we added the threading feature.
- replyId: 12-digit ID of the chalk or reply being referenced by a private reply.
- place: an optional field the user can supply when authoring a chalk or reply. Can either indicate their exact coordinates at the time of authoring (with full accuracy), or it can be a valid street address. If this field is present and contains coordinates, you should consider it to be the definitive coordinates for the object in question. If this field is present and contains a street address, you should treat it as a secondary, user-specified location and display it as such.
- threadId: 12-digit ID of the conversation thread. Threads are are a flat chain of chalks in a conversaton. Chalks whose threadId matches their chalkId are the first (and possibly only) in the thread, while subequent comments in the thread will have new chalkIds but retain the same threadId.
- threadCount: the number of chalks in the thread. this value, when provided, is always at least 1.
- category: the category that the chalk belongs to. this is a string, such as "For Sale", and may also include multiple names concatenated by ">" to denote subcategories, such as "For Sale > Bikes". The current list of supported categories is available via the GET /categories call. Note that in XML response bodies, due to XML encoding, any subcategories will be delimited with ">" as opposed to ">" (hopefully your XML parser handles this automatically.) Also note that all chalks in a thread will always be of the same category. Since the launch of the categories feature, all historical chalks were retroactively assigned to the "Chatter" category.
Revision history
- 0.60 (8/30/09): Original release.
- 0.61 (8/31/09): Added support for GeoRSS. Added additional RSS call with different URL structure to support Google Maps mash-ups.
- 0.62 (9/8/09): Added "coordinates" field to reveal latitude and longitude in XML and JSON responses.
- 0.63 (9/21/09): Added "neighborhood" attribute to XML and JSON response for GET /chalks, to indicate name of the user's current neighborhood (when it is known).
- 0.64 (9/29/09): Added optional profanity filter to most calls that return chalks or replies.
- 0.65 (10/1/09): Added optional chalkbackTo parameter to POST /chalk, allowing for chalkbacks (public responses to chalks).
- 0.66 (2/22/10): A custom user agent is no longer required; API users can instead include a consumer URL parameter if desired.
- 0.67 (4/07/10): Addition of threadId and threadCount metadata to chalks on XML and JSON response bodies; GET /chalks call now accepts threadId parameter to query all chalks in a thread; POST chalk call now accepts a threadId parameter in favor over the chalkbackTo parameter; updated language regarding comments vs chalkbacks
- 0.68 (05/09/10): Addition of categories: category metadata added to chalks on XML and JSON response bodies, addition of GET /categories call, POST chalk call now accepts a category parameter which defaults to "chatter" when unspecified, all historical chalks without category assignments are retroactively assigned to "chatter"
Available calls
General operations:
User-specific operations:
GET /chalks - Get all chalks near a given location
Returns the latest chalks each from "right here", "this block", "within two blocks", and "in your neighborhood". Up to 100 results. Note that the "neighborhood" field/attribute refers not to the neighborhood of a specific chalk but rather to the user's current neighborhood (as determined from the latitude and longitude passed in with the request). This data is not always available but is returned when it is known. In the XML response this it takes the form of a single attribute on the top-level "chalk" tag. In the JSON response it is a field that recurs with each individual chalk; despite this, the field should not be confused as being related to a specific chalk. (This JSON format is admittedly a hack but it was done in order to allow providing this data without breaking backwards compatibility with the current API version. This will be improved in the next version of the API.)
Clients should preserve the order of chalks as provided in the response for end users, which should be considered relevance ranked by the server. Chalks are currently returned in reverse chronological order but this may change with new ranking implementations.
URL:
http://blockchalk.com/api/v0.6/chalks?lat=latitude&long=longitude
If you also provide the optional URL parameter user=userId the results will be filtered to omit any chalks that the given user has buried (see POST /chalk/chalkId/bury).
If you provide the optional URL parameter profanityFilter=true a profanity filter will be applied to the results.
If you provide the optional URL parameter threadId=threadId, results will include all chalks for the threadId and no others, regardless of the query's lat/long coordinates, which are still required. The order of chalks will always contain the first thread chalk as the first in the response, with subsequent comments then in reverse chronological order.
HTTP method:
GET
Formats:
By default results are returned as XML. You can request JSON or RSS by adding the optional &format=xml|json|rss parameter.
Note that threadId and threadCount properties are not returned on RSS format responses.
Response (success): HTTP 200
XML:
<chalks neighborhood="Inner Sunset">
<chalk>
<id>7b1ec33dc010</id>
<contents>Drinking at Gordon biersch</contents>
<datetime>2009-08-14 00:07:04 UTC</datetime>
<distance>right here</distance>
<coordinates lat="37.344" long="-121.888"/>
<place/>
<chalkbackTo>32a9f4ea86a2</chalkbackTo>
<threadId>32a9f4ea86a2</threadId>
<threadCount>2</threadCount>
<category>Chatter</category>
</chalk>
<chalk>
<id>36d9f2ea81a2</id>
<contents>I'm the froyo mayur</contents>
<datetime>2009-08-13 23:09:11 UTC</datetime>
<distance>within a few blocks</distance>
<coordinates lat="37.442" long="-122.159"/>
<place>123 Main St Anytown, CA</place>
<threadId>32a9f4ea86a2</threadId>
<threadCount>2</threadCount>
<category>Chatter</category>
</chalk>
</chalks>
JSON:
[{"contents": "Drinking at Gordon biersch", "neighborhood":"Inner Sunset","id": "7b1ec33dc010", "datetime": "2009-08-14 00:07:04 UTC", "distance": "right here", "chalkbackTo":"32a9f4ea86a2", "coordinates":{"lat":"37.344","long":"-121.888"}, "threadId": "32a9f4ea86a2", "threadCount": "2", "category": "Chatter"}, {"contents": "I'm the froyo mayur", "neighborhood":"Inner Sunset", "id": "36d9f2ea81a2", "datetime": "2009-08-13 23:09:11 UTC", "distance": "within a few blocks", "coordinates": {"lat":"37.443","long":"-122.159"}, "place": "123 Main St Anytown, CA", "threadId": "32a9f4ea86a2", "threadCount": "2", "category": "Chatter"}]
Response (failure): HTTP 400
XML:
<errors>
<error>no latitude</error>
<error>invalid longitude</error>
</errors>
JSON:
[{"error": "no latitude"}, {"error": "invalid longitude"}]
GET /chalks/latitude,longitude - Get all chalks near a given location in GeoRSS format
Returns the latest chalks near the indicated location. Up to 100 results. Results are returned in GeoRSS format. Note: the URL formatting for this call differs from others in the BlockChalk API because this call is intended to be used with services that support GeoRSS. Google Maps is a major target use case here, but it does not support URL parameters for this usage pattern. Please excuse the inconsistency.
URL:
http://blockchalk.com/api/v0.6/chalks/latitude,longitude
HTTP method:
GET
Formats:
Results are returned as RSS 2.0 with GeoRSS mark-up. This is the only format supported for this particular call.
Response (success): HTTP 200
Response (failure): HTTP 400
GET /chalk/chalkId - Get details for a specific chalk
Returns details for the chalk specified by chalkId.
URL:
http://blockchalk.com/api/v0.6/chalk/chalkId
If you provide the optional URL parameter profanityFilter=true a profanity filter will be applied to the results.
HTTP method:
GET
Formats:
By default results are returned as XML. You can request JSON by adding the optional &format=xml|json parameter. Note that this operation does not support RSS.
Response (success): HTTP 200
XML:
<chalk>
<id>7b1ec33dc010</id>
<contents>Drinking at Gordon biersch</contents>
<datetime>2009-08-14 00:07:04 UTC</datetime>
<coordinates lat="37.344" long="-121.888"/>
<place/>
<chalkbackTo>32a9f4ea86a2</chalkbackTo>
<threadId>32a9f4ea86a2</threadId>
<threadCount>2</threadCount>
<category>Chatter</category>
</chalk>
JSON:
{"contents": "Drinking at Gordon biersch", "id": 7b1ec33dc010, "datetime": "2009-08-14 00:07:04 UTC", "chalkbackTo":"32a9f4ea86a2", "coordinates":{"lat":"37.344","long":"-121.888"}, "threadId": "32a9f4ea86a2", "threadCount": "2", "category": "Chatter"}
Response (failure): HTTP 400
XML:
<errors>
<error>invalid chalkId</error>
</errors>
JSON:
[{"error": "invalid chalkId"}]
GET /user/new - Request a new user ID
Returns a new, unique user ID code. Only call this operation when you need to request an ID for a new user of your application. Store this ID and reuse it for all future requests made on a given user's behalf.
URL:
http://blockchalk.com/api/v0.6/user/new
HTTP method:
GET
Formats:
Plain text.
Response (success): HTTP 200
A successful response includes the new user ID in the message body; e.g.:
cf9305c326cc514d23144577275a23c6
Response (failure): HTTP 500
This call should only fail if there is a server problem, in which case an HTTP 500 will be returned. Please wait and try again later.
GET /categories - Get a list of supported categories
The list includes one category element per supported category, in no particular order. It also includes a timestamp so you can tell if the list has changed since your last fetch. It is advised that you refer to this list for category support as opposed to hard-coding a copy of it, because you should expect it will change as BlockChalk grows and responds to user needs.
Some notes regarding expected future changes to these categories:
- We will add unique category support for different geographies, though we do not do this today. However, this is why the lat/long coordinates are required.
- We will add more top level categories, as well as subcategories. Subcategories will be denoted in the category string with a ">" delimiter.
- We will be adding per-category fields, such as a "price" in the for sale category. The fields available for a category will be declared in the this call for each category element along with metadata such as their required/optional status, the expected data type, etc. This is why the category element is a container - expect more children elements to appear over time.
- If new categories are created but your implementation does not support them, you should ignore chalks from the new categories until your implementation supports those categories. (As opposed to recategorizing chalks into an old category list.)
URL:
http://blockchalk.com/api/v0.6/categories?lat=latitude&long=longitude
HTTP method:
GET
Formats:
By default results are returned as XML. You can request JSON by adding the optional &format=xml|json parameter. Note that this operation does not support RSS.
Response (success): HTTP 200
XML:
<last_modified>2010-05-02 20:48:12 UTC</last_modified>
<categories>
<category>
<name>Chatter</name>
</category>
<category>
<name>For Sale</name>
</category>
<category>
<name>Free</name>
</category>
<category>
<name>Lost & Found</name>
</category>
<category>
<name>News & Issues</name>
</category>
<category>
<name>Personals</name>
</category>
</categories>
JSON:
{"last_modified": "2010-05-02 20:48:12 UTC", "categories": [{"name": "Chatter"}, {"name": "For Sale"}, {"name": "Free"}, {"name": "Lost & Found"}, {"name": "News & Issues"}, {"name": "Personals"}]}
Response (failure): HTTP 400
XML:
<errors>
<error>invalid lat/long</error>
</errors>
JSON:
[{"error": "invalid lat/long"}]
GET /user/userId/chalks - Get recent chalks written by a given user
Returns the 20 most recent chalks written by the user indicated by userId.
URL:
http://blockchalk.com/api/v0.6/user/userId/chalks
If you provide the optional URL parameter profanityFilter=true a profanity filter will be applied to the results.
HTTP method:
GET
Formats:
By default results are returned as XML. You can request JSON or RSS by adding the optional &format=xml|json|rss parameter.
Response (success): HTTP 200
Successful responses for both XML and JSON are in the same format as described in GET chalks/.
Response (failure): HTTP 200
Failure responses for both XML and JSON will manifest as an HTTP 200 response with an empty response body. In this context "failure" means either that the supplied userId was invalid, or it was valid but there were no chalks to return.
GET /user/userId/replies - Get recent replies written to a given user
Returns the 20 most recent replies written to the user indicated by userId.
URL:
http://blockchalk.com/api/v0.6/user/userId/replies
If you provide the optional URL parameter profanityFilter=true a profanity filter will be applied to the results.
HTTP method:
GET
Formats:
By default results are returned as XML. You can request JSON or RSS by adding the optional &format=xml|json|rss parameter.
Response (success): HTTP 200
XML:
<replies>
<reply>
<id>6a1ca13fb012</id>
<contents>lol wut r u talking about man</contents>
<datetime>2009-08-20 10:13:00 UTC</datetime>
<place/>
</reply>
</replies>
JSON:
[{"contents": "lol wut r u talking about man", "id": 6a1ca13fb012, "datetime": "2009-08-20 10:13:00 UTC"}]
Response (failure): HTTP 200
Failure responses for both XML and JSON will manifest as an HTTP 200 response with an empty response body. In this context "failure" means either that the supplied userId was invalid, or it was valid but there were no replies to return.
POST /chalk - Create a new chalk
Creates a new chalk. Returns the full details of the newly-created chalk.
URL:
http://blockchalk.com/api/v0.6/chalk/
HTTP method:
POST
Request body:
msg=message&lat=latitude&long=longitude&user=userId&category=category
If you include the optional parameter threadId=threadId then this post will be considered a comment (a public response) to the thread referenced by threadId. A comment looks like any other post but in the future BlockChalk will provide additional differentiation in this regard. Only use this feature for comments to posts; you cannot create a comment that references a private reply.
The parameter chalkbackTo=chalkId is deprecated, but effectively the same as the threadId parameter. It differs only in semantics, not in practical results.
The parameter category is expected to be one of the strings defined by the GET /categories call. If unspecified, for backwards compatibility reasons, it defaults to "Chatter"
Formats:
By default results are returned as XML. You can request JSON by adding the optional &format=xml|json parameter. Note that RSS is not supported for this call.
Response (success): HTTP 200
XML:
<chalk>
<id>6a2ec13ea120</id>
<contents>this pothole is a menace!</contents>
<datetime>2009-08-24 19:20:31 UTC</datetime>
<coordinates lat="37.112" long="-122.416"/>
<place/>
<threadId>6a2ec13ea120</threadId>
<threadCount>1</threadCount>
<category>Chatter</category>
</chalk>
JSON:
[{"contents": "this pothole is a menace!", "id": "6a2ec13ea120", "datetime": "2009-08-24 19:20:31 UTC", "coordinates":{"lat":"37.112","long":"-122.416"}, "threadId": "6a2ec13ea120", "threadCount": "1", "category": "Chatter" }]
Response (failure): HTTP 400
XML:
<errors>
<error>no latitude</error>
<error>invalid longitude</error>
<error>message longer than 256 characters</error>
<error>invalid userId</error>
</errors>
JSON:
[{"error": "no latitude"}, {"error": "invalid longitude"}, {"error": "message longer than 256 characters"}, {"error": "invalid userId"}]
POST /reply - Send a reply
Sends a new reply. Returns the full details of the newly-created reply.
URL:
http://blockchalk.com/api/v0.6/reply/
HTTP method:
POST
Request body:
replyTo=replyId&msg=message&lat=latitude&long=longitude&user=userId
Formats:
By default results are returned as XML. You can request JSON by adding the optional &format=xml|json parameter. Note that RSS is not supported for this call.
Response (success): HTTP 200
XML:
<reply>
<id>6a1ca13fb012</id>
<contents>lol wut r u talking about man</contents>
<datetime>2009-08-20 10:13:00 UTC</datetime>
<coordinates>37.112,-122.416</coordinates>
<place/>
</reply>
JSON:
[{"contents": "this pothole is a menace!", "id": 6a2ec13ea120, "datetime": "2009-08-24 19:20:31 UTC", "coordinates": "37.112,-122.416"}]
Response (failure): HTTP 400
XML:
<errors>
<error>no latitude</error>
<error>invalid longitude</error>
<error>message longer than 256 characters</error>
<error>invalid or missing userId</error>
<error>invalid or missing replyId</error>
</errors>
JSON:
[{"error": "no latitude"}, {"error": "invalid longitude"}, {"error": "message longer than 256 characters"}, {"error": "invalid or missing userId"}, {"error": "invalid or missing replyId"}]
POST /chalk/chalkId/bury - Bury a chalk
Buries the specified chalk, which permanently hides it from this user's view.
URL:
http://blockchalk.com/api/v0.6/chalk/chalkId/bury
HTTP method:
POST
Request body:
user=userId
Formats:
Plain text.
Response (success): HTTP 200
Success results in an HTTP 200 with an empty message body.
Response (failure): HTTP 400
XML:
<errors>
<error>invalid or missing userId</error>
<error>invalid or missing chalkId</error>
</errors>
JSON:
[{"error": "invalid or missing userId"}, {"error": "invalid or missing chalkId"}]
[home]
|
|
|