Tonight I’m releasing an offical Snipplr API which will allow anyone to write their own plugins to communicate with Snipplr. You can use the API to talk to Snipplr from other websites, your favorite text editor, or any desktop app. It’s up to you. You’re in control now.
The Snipplr API uses the standard XML-RPC protocol and offers the following methods.
snippet.list– Returns a list of snippets based on the search criteria you provide.
snippet.get– Retrieves the details (including source code) for a given snippet.
snippet.post– Allows you to store a new snippet into Snipplr.
snippet.delete– Allows you to delete a snippet.
user.checkkey– Validates a user’s API key.
languages.list– Returns a list of available languages.
I’d appreciate feedback letting me know about any problems you run into or features you’d like added.
Also, for all the TextMate hackers out there, I’ve got an offer for you. I’d like to replace the current TextMate Snipplr bundle with a more maintainable Ruby version. (The current one is a mess that uses shell scripting.) I only know a little Ruby, so along with their name on Snipplr and my eternal thanks, the first person to send in a good, working Snipplr plugin for TextMate gets a free Snipplr t-shirt In fact, if you want to write a plugin for another editor (BBEdit!), and I approve it, I’ll send you a Snipplr t-shirt as well.
Using the API
snippet.list returns an XML formatted list of snippets matching the specified criteria. Takes two parameters (must be passed in this order):
api_key: Required. The API key of the Snipplr user. Snipplr returns all of this user’s snippets. An error message will be returned if the API key is invalid.
tags: Optional. A space delimited list of tags (keywords) to filter the results by. Snipplr returns snippets which contain at least one of the keywords in the snippet’s title or that match one of the snippet’s tags.
sort: Optional. Can be one of these three values: “title”, “date”, “random”.
limit: Optional. The number of snippets to return.
snippet.list only returns snippets owned by the user or marked as favorites of the user. It does not search all of the snippets on Snipplr.
snippet.get returns a snippet’s details. Takes one parameter:
- snippet_id: Required. The ID of the snippet to fetch. An error message will be returned if the ID is invalid.
snippet.get currently returns the following snippet properties:
- created (datetime when snippet was created)
- snipplr_url (url to view snippet)
- tags (space delimited list of the snippet’s tags)
snippet.post stores a new snippet into Snipplr. Takes four parameters (must be passed in this order):
api_key: Required. The API key of the Snipplr user to which the snippet will belong. An error message will be returned if the API key is invalid.
title: Required. The title of the snippet.
code: Required. The snippet’s source code.
tags: Optional. A space delimited list of keywords to tag the snippet with.
snippet.delete deletes a snippet from your Snipplr account. Returns 1 on success, 0 if the snippet could not be deleted. Takes two parameters (must be passed in this order):
api_key: Required. The API key of the Snipplr user that created the snippet you are deleting. An error message will be returned if the API key is invalid.
snippet_id: Required. The ID of the snippet you are deleting.
user.checkkey validates a user’s API key. Returns 1 if the key is valid. 0 if not valid. Takes one parameter.
- api_key: The API key to validate.
languages.list returns a list of supported languages in Snipplr. It returns their
pretty name. The
urlname is the value you pass into the
snippet.post method. The
pretty name is a nicely formatted version of
urlname. It’s just there for your reference. This method takes no parameters.