Skip to content
Steven edited this page Feb 24, 2014 · 1 revision

This is a guide to cover the 4 basic operations of a paest (create, read, update, delete) using javascript. The usage is very similar to that of the CLI.

The main differences are:

  1. append '.json' to the urls
  2. send json objects (the normal thing to do in posts in js anyway)

Note: For the examples, I'm using jquery. This is just for convenience, angular, raw XMLHttpRequests, etc work too.

Create a paest

// Simple paest creation.
$.post("http://a.pae.st/.json", {'d':'content'}, function(response){
});

You can also pass in requested paest ids

// Simple paest creation.
$.post("http://a.pae.st/PaestIdIWant.json", {'d':'content'}, function(response){
});

The responses you get will be in the form

Object {
  web_pub: "http://pae.st/XXX", 
  web_pri: "http://pae.st/XXX/YYYY",
  cli_pub: "http://a.pae.st/XXX", 
  cli_pri: "http://a.pae.st/XXX/YYYY"
}

Reading a paest

$.get("http://a.pae.st/XXX.json", function(response){
});

The responses will be either of:

{d:'paest data'}  // Found
{e:'paest not found'} //Not found

Updating a paest

Works the same as creating a paest except the url contains the private key too

// Simple paest update.
$.post("http://a.pae.st/XXX/YYYY.json", {'d':'new content'}, function(response){
});

Deleting a paest

Simply update with empty content

// Simple paest update.
$.post("http://a.pae.st/XXX/YYYY.json", {'d':''}, function(response){
});
Clone this wiki locally