-
Notifications
You must be signed in to change notification settings - Fork 0
REST API
4poc edited this page Apr 22, 2013
·
13 revisions
This documents the dedicated REST API of the anpaste project and specifically, the web service available at paste.geekosphere.org. The API does not require authentication or an API Key. It will always return a valid JSON object.
Returns an array of Paste objects.
| Query Parameter | Type | |
|---|---|---|
start |
numeric | Optional. Starting point when paging through a list of results. |
max |
numeric | Optional. Maximum number of results with a hardlimit. |
Returns a Paste object of the paste specified by id {ID}.
| Attribute | Type | |
|---|---|---|
id |
string | Alphanumerical random identifier for this paste. |
summary |
string | Optional. Short abstract of this paste. |
content |
string | The content of this paste. |
language |
string | Short identifier of the language and highlighter used. |
created |
datetime | Timestamp when this paste was originally created. |
expire |
datetime | Optional. Timestamp of a date in the future when this paste will be deleted. |
Create a new paste.
| Query Parameter | Type | |
|---|---|---|
summary |
string | Optional. Short abstract of this paste. |
content |
string | The content of this paste. |
language |
string | Optional. Short identifier of the language and highlighter used. |
expire |
integer | Optional. Number of seconds in the future when the paste should expire. |
private |
boolean | Optional. If the paste should be publicly listed. |
announce |
boolean | Optional. Should the paste be announced in IRC. |
This returns a Hash with the following values:
| Return Variable | Type | |
|---|---|---|
id |
string | The generated ID this paste can be identified with. |
secret |
string | The secret token that can be used to update or delete this paste. |
url |
string | Fully qualified URI of the created paste. |
Updates an existing paste, specified by the id {ID}.
| Query Parameter | Type | |
|---|---|---|
secret |
string | The secret token used to authenticate the owner. |
summary |
string | Optional. Short abstract of this paste. |
content |
string | Optional. The content of this paste. |
language |
string | Optional. Short identifier of the language and highlighter used. |
This returns a Hash with the following values:
| Return Variable | Type | |
|---|---|---|
id |
string | The ID the updated paste can be identified with. |
url |
string | Fully qualified URI of the updated paste. |
Deletes an existing paste, specified by the id {ID}.
| Query Parameter | Type | |
|---|---|---|
secret |
string | The secret token used to authenticate the owner. |
This returns a Hash with the following values:
| Return Variable | Type | |
|---|---|---|
id |
string | The ID of the deleted paste. |
To create:
% echo "<b>This is a (api) test.</b>" > testfile
% curl -F "content=@testfile" -F "language=xml" http://paste.geekosphere.org/api/1/paste
{
"id": "G",
"secret": "cN5Bd9ScAXXdhjdx",
"url": "http://paste.geekosphere.org/G"
}
To view:
% curl http://paste.geekosphere.org/api/1/paste/G
{
"id": "G",
"summary": "testfile",
"content": "<b>This is a (api) test.</b>\n",
"language": "xml",
"created": "2013-04-21T20:17:43.815Z",
"expire": null
}
To update:
% echo "<b>This is another (api) test.</b>" >> testfile
% curl -X PUT -F "secret=cN5Bd9ScAXXdhjdx" -F "content=@testfile" http://paste.geekosphere.org/api/1/paste/G
{
"id": "G",
"secret": "cN5Bd9ScAXXdhjdx",
"url": "http://paste.geekosphere.org/G"
}
% curl http://paste.geekosphere.org/api/1/paste/G
{
"id": "G",
"summary": "testfile",
"content": "<b>This is a (api) test.</b>\n<b>This is another (api) test.</b>\n",
"language": "plain",
"created": "2013-04-21T20:17:43.815Z",
"expire": null
}
To delete:
% curl -X DELETE -d "secret=cN5Bd9ScAXXdhjdx" http://paste.geekosphere.org/api/1/paste/G
{
"id": "G"
}
- 22-04-2013 full url is now included in the create/update response