-
Notifications
You must be signed in to change notification settings - Fork 2
Clipster's API support both XML and JSON. API functions include create, list, view, and search. HTTP status codes should always be checked when using the API.
- clip
- The main contents of the clip.
- This is the only required attribute.
- expires
- When the clip should expire.
- Default is 'Forever' if left empty.
- language
- If you want syntax highlighting, you must specify the language of the clip.
- Default is 'text' if left empty.
- private
- To keep clips out of the recent clips or feed, mark them as private.
- Can be either true or false.
- Default is public if left empty.
- title
- A sort name for the clip.
- Default is 'Untitled' if left empty.
POST http://host-app.tld/clipster/create.xml
A minimal clip
<?xml version="1.0" encoding="UTF-8"?>
<clip>
<clip>Hello World</clip>
</clip>
Basic clip with syntax highlighting
<?xml version="1.0" encoding="UTF-8"?>
<clip>
<clip>puts 'Hello World!'</clip>
<clip>ruby</clip>
</clip>
POST http://host-app.tld/clipster/create.json
A minimal clip
{"clip":{
"clip": "hello"
}}
Basic clip with syntax highlighting
{"clip":{
"clip": "puts 'Hello World!'",
"language": "ruby"
}}
Search results can be retrieved in either xml or json format. Just specify the format in the GET url along with the search term:
GET http://host-app.tld/clipster/search.xml?search_term=test
Search results are limited to 25 per query. If your search returns more then 25 results, you will need to specify the page number to view:
GET http://host-app.tld/clipster/search.json?page=2&search_term=test
To view a specific clip, you will need the clip ID. The clip ID can be found in the clip's url. In the example http://host-app.tld/clipster/dd2lgoiew7, the clip's ID is dd2lgoiew7. IDs for public clips can either be retrieved from the clip feed, or from the recent clips view. If you want to retrieve this clip in XML, simply tack on the .xml:
GET http://host-app.tld/clipster/dd2lgoiew7.xml
To retrieve a private clip, you will have to know the ID in advanced. If it is a clip you just created via the API, then the ID of the Clip will have been returned to you upon successful creation.
To look through public clips, other then using search or Atom feed, you can look at the recent clips page in either XML or JSON format.
GET http://localhost:3000/clipster/clips.xml
Just like search, if there is more than 25 public posts, you'll have to define the page number in the URL.
GET http://localhost:3000/clipster/clips.xml?page=2
Results can also be limited by language type:
GET http://localhost:3000/clipster/clips.xml?lang=ruby