Introducing the Webscript API (Beta)

Since our launch, a number of people have asked for a Webscript API so they can programmatically download or upload scripts. In response, we recently launched the first beta release of the Webscript API.

The API is based on HTTPS and JSON, with a shared key for authentication. Webscript users can find their API key on the settings page. For the full details of supported operations, read the Webscript API documentation.

This curl example shows how to list the subdomains for a given account. The email address (demo@example.com) is the email address used to log in to Webscript. The API key (b889a1c92c3a41758bcedc73b7355e49) comes from the user's settings page.

$ curl https://www.webscript.io/api/0.1/subdomains -u [email protected]:b889a1c92c3a41758bcedc73b7355e49
{
  "demo-krbnjo": {
    "expired": false,
    "expiration": "2012-12-07T20:51:32.479276",
    "scripts": [
      "/script"
    ]
  }
}

This example shows how to get the details of a single domain:

$ curl https://www.webscript.io/api/0.1/subdomain/demo-krbnjo -u [email protected]:b889a1c92c3a41758bcedc73b7355e49
{
  "expired": false,
  "expiration": "2012-12-07T20:51:32.479276",
  "scripts": [
    "/script"
  ]
}

This example shows how to retrieve the contents of a single script. (Note that this is just the standard demo script that gets created for new accounts.)

$ curl https://www.webscript.io/api/0.1/script/demo-krbnjo/script -u [email protected]:b889a1c92c3a41758bcedc73b7355e49
-- Here's a sample script to get you started:
return
        "I'm a webscript.io script. I was called with an HTTP "..
        request.method..
        " request, with the following headers:\n\n"..
        json.stringify(request.headers)

This example shows how to update the contents of a script, as verified by retrieving the script again:

$ curl https://www.webscript.io/api/0.1/script/demo-krbnjo/script -u [email protected]:b889a1c92c3a41758bcedc73b7355e49 -d "return 'hello world'"
$ curl https://www.webscript.io/api/0.1/script/demo-krbnjo/script -u [email protected]:b889a1c92c3a41758bcedc73b7355e49
return 'hello world'

What's next?

We've also heard a few requests for request logs to be made available via the API, so this will likely be the next API feature we introduce. Let us know what you build with the API and what other functionality you want to see. You can reach us at any time at team@webscript.io.