Skip to content
ElectricDynamite edited this page May 30, 2012 · 3 revisions

Version 1

State: stable, obsolete
API version 1. Intial version full of flaws and with a bad design. You should not use this version anymore.

General

Besides a call to create a user, which is protected by an API key, all calls must be authenticated. This can happen in one of two ways:

1.) Sending username & password via HTTP Headers:
X-Pasty-User
X-Pasty-Password
(Note: This is likely to change to HTTP Basic Auth with API version 2)

2.) Calling /v1/user/token with X-Pasty-User & X-Pasty-Password HTTP Headers set. This will return a token that can be used instead of the credentials. You will then need to set X-Pasty-Token as HTTP header instead of X-Pasty-User and X-Pasty-Password.

Clipboard

The Clipboard consists of a collection of Items. It can be accessed using HTTP GET on
GET /v1/clipboard/list
optionally you can specify a format using the file extension. Currently only JSON is supported:
GET /v1/clipboard/list.json
In time, at least XML will also be offered.

Sample output:

{
  "success":true,
  "items":[
     {"item":"sdsfd","_id":"4fa4ee1b7cdd42230e000003"},
     {"item":"asdasd","_id":"4fa4ee197cdd42230e000002"},
     {"item":"1","_id":"4f927e924bf6e71b170001f0"},
     {"item":"2","_id":"4f927e914bf6e71b170001ed"},
     {"item":"3","_id":"4f927e914bf6e71b170001ec"},
     {"item":"4","_id":"4f927e914bf6e71b170001ea"}
  ]
}

##Items Items can be accessed as a subcategory of the Clipboard.

To get an Item:
GET /v1/clipboard/item/{id}
{id} being the Object Id of the Item (Obtained by getting the Clipboard)

Sample output:

{
  "success":true,
  "item":
     {"item":"ä","_id":"4f927e914bf6e71b170001ea"}
}

To create a new Item:
POST /v1/clipboard/item/
You need to supply the Item content using a HTTP body with JSON:
{ "item": "thestringtoadd" }

Sample output:
{"success":true}

To delete an Item:
DELETE /v1/clipboard/item/{id}
{id} being the Object Id of the Item (Obtained by getting the Clipboard)

Sample output:
{"success":true}

Users

Creating users is currently only allowed for certain clients, to enforce acceptance of ToS and Privacy Policy. Once I figured out how to solve this problem, it might become public.
However, updating and deleting users is allowed under the limitations and conditions below.

All writing user related actions need to be authenticated using the username & password method. A token will not be enough here.

Requesting a Token to replace the users credentials:
GET /v1/user/token
This will also return some information about the user.

Sample output:

{
  "success":true,
  "tokeninfo":
  {
     "token":"b229454a89ab6366cee93ad9838d8412bf54aa057de48c2cfb8be88c8051ae3160e8f802db2530d865e5f3972dad754db423ea3892458b32513f73564026f800",
     "user":"test",
     "uid":"4f8dasgc2305893a0e000001",
     "expires":1336254017135
  }
}

To create a new user:
POST /v1/user/create/
sending username and password as JSON HTTP body:
{ "user": "yourusername", "password": "yourpassword" }

Sample output:

{
  "success":false,
  "error":
  {
    "code":401,
    "message":"API key is invalid"
   }
}

To update a user (password only):
PUT /v1/user/{id}
{id} being the users id (returned when requesting a token). Send the new password as JSON HTTP body:
{ "newPassword": "yournewpassword" }

Sample output:
{"success":true}

To delete a user:
DELETE /v1/user/{id}
{id} being the users id (returned when requesting a token).

Sample output:
{"success":true}

Clone this wiki locally