Share Snipplr

del.icio.us Digg Furl Reddit

Snipplr API

Published in: API, Development, NewsPosted by Tyler on 07/06/06

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

Server: http://snipplr.com
End Point: /xml-rpc.php
Full URL: http://snipplr.com/xml-rpc.php


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.

Note: 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:

  • id
  • user_id
  • username
  • title
  • language
  • comment
  • created (datetime when snippet was created)
  • source
  • 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.

  • language: Optional. The language to mark the snippet as. Use the language name found in Snipplr’s URLs. For example, “javascript” or “c-plus-plus”.


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 urlname and 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.


RSS Icon Subscribe to comments
Posted By: Inside Snipplr.com » Blog Archive » Updated Snipplr API on September 20th, 2006

[...] Based on visitor feedback (thanks, Hernán!) I updated the Snipplr API this morning. The snippet.get method now returns a list of the snippet’s tags. Also, I added a much needed snippet.delete method that (you guessed it) lets you delete snippets from your account. Click here for the API documentation. [...]

Posted By: Inside Snipplr.com » Blog Archive » Snipplr API Updated on January 31st, 2007

[...] You can view the API reference here. [...]

Posted By: Avinash on May 14th, 2007

Really, you’re going to make me do that much Math just to post a comment?

Anyway, I’ve got problems accessing the API–I keep getting a 301 Protocol Error (“Moved Permanently”). Any ideas?

Posted By: Tyler on May 14th, 2007

No idea. I ran a quick test of the API and received a 200 OK response. Are you connecting to “http://snipplr.com/xml-rpc.php”?

Posted By: Oliver Nautsch on May 28th, 2007

I’m building a plugin for eclipse (http://sourceforge.net/projects/snipplr4e) and I have small wishes for the xml-rpc-api :)

1.) The api doesn’t allow to remove a snippet from my favorite list. I think “snippet.delete” with the id of a favorite should remove the favorite from my list.

2.) Please indicate the type of the snippet (own or favorite) in the result from “snippet.list”.

Posted By: Carlos Frias on July 1st, 2007

Would you be providing a query invocation?

Posted By: Tyler on July 1st, 2007

@Carlos – What specifically do you want?

Posted By: Ian Lewis on July 2nd, 2007

I’m making a Snipplr plugin for the jEdit text editor. Is there a reason why the snippet.list sends an error response when there are no snippets returned by the query? It’s hard to tell on the client side the difference between a real XML-RPC error and an error resulting from a query that has no results.

Posted By: Tyler on July 2nd, 2007

@ Ian Lews – It shouldn’t be too hard to detect the error. The API returns a faultCode of “1″ and a faultString that says ” No snippets found with tags = ””. Other error codes are:

1 – No snippets found
2 – No snippet found (when search for snippet by ID)
3 – Incorrect API key
4 – Requested method name not found

Posted By: Ian Lewis on July 15th, 2007

@ Tyler

Perfect. That’s exactly the info I was looking for. Thanks.

Posted By: maid450 on September 10th, 2007

something I think would be great is a “tags.list” or something method that returns a list of all different tags of your snippets

Posted By: bela on October 23rd, 2007

snippet.delete appears to return 0 whether or not the snippet was actually deleted.

That is, when a snippet is successfully deleted (no longer appears with snippet.list) the response is 0.
If snippet.delete is then called on the same snippet_id, the response is the same.

Posted By: Tenzer on March 10th, 2008

I think I found the cause of the issue Avinash described almost a year ago, since I also have experienced the same issue.

The error message comes when the URL for the server is sent as “http://snipplr.com:80/xml-rpc.php”, which includes the port number. Then a 301 HTTP error message is sent back redirecting to “http://snipplr.com/xml-rpc.php”.

Unfortunately it seems that some XML-RPC libraries always includes the port number in the URL, which makes them unusable together with your API.

Could the redirect system maybe be blacklisted from the xml-rpc.php file?

Posted By: Tenzer on March 10th, 2008

A little more testing shows that if you just use the HTTP 1.1 standard instead of HTTP 1.0, there is no problems with the 301 error.

Posted By: Jason Tan on May 1st, 2008

@bela – I just fixed the snippet.delete method to return the correct code (1 on successful deletion, 0 otherwise)

Posted By: Matt Hobbs (1man) on May 19th, 2008

Hi Tyler,
Is the server capable of outputting in JSON? Or would it be able to add the function?

Posted By: Ian Lewis on August 8th, 2008

snippet.list started returning multiple results for a single snippet.

For instance I searched my own snippets for one matching “mail” and got 7 results for only 2 matched snippets. 3 are for one snippet and 4 for another.

check_email_address() email validator
check_email_address() email validator
check_email_address() email validator
Send multi-part encoded mail with attachments
Send multi-part encoded mail with attachments
Send multi-part encoded mail with attachments
Send multi-part encoded mail with attachments

Posted By: rolandog on October 12th, 2008

Is there a possibility of replacing a snippet with a local file?

Posted By: Recent Links Tagged With "josh" - JabberTags on December 26th, 2008

[...] public links >> josh Yes, We Get the Times Here Saved by PrincessSarah on Sun 14-12-2008 Snipplr API – Blog Archive – Inside Snipplr.com Saved by Ilovemovielogos on Thu 11-12-2008 Prince Charles says GE crops the biggest environmental [...]

Posted By: Snippet: Accessing SNIPPLR with Groovy and XML-RPC on December 26th, 2009

[...] Take a look at the API documentation at snipplr.com [...]

Posted By: Beau on July 28th, 2011

Hi, I’m working on a visual studio plugin for snipplr and it seems that I can retrieve a non private snippet but i can’t retrieve a private snippet even though i can see the snippet in a search result. Also I cannot seem to figure out how to submit a private snippet. This is a pretty important thing. Can anyone help?

Leave a Reply

You may use Markdown to format your comment.
HTML renders as source code.