Silk API





Our API

Please remember that our API is in beta. Although it is versioned, things can change, for example in the structure of documents. We will try to update this documentation as soon as things change. If you have any question, please send an email to support@silk.co so one of our developers can help you out.

We changed domains: please change any mentions of silkapp.com in the code examples to silk.co.

If you understand how the API works, here is a complete overview of all API paths. 

See this gist about all the things you can do with the *importer* API.

Introduction

Silk has a REST based API for reading and writing. This is the basic documentation (for version 1.4.0 of the API) with the most important concepts and logic. Silk itself runs on its own API. So everything you can do on Silk, you can do with the API.

These entities within Silk are important:

» Also take a look at our FAQ

Versioning

To minimize breaking existing projects, Silk uses a layered API with a custom versioning scheme. Read more about it here.

First steps

We explain the API by a few examples in which we show some basic operations. In these examples Curl is used. Curl is a (multi-platform) command line tool for transferring data with URL syntax. It is transparent what request is sent to the API. We will add libraries for multiple languages in the future.

Get a page

Let's first get a page. We want to get the Ghana page from the public site world.silk.co. It is done like this.

This is an HTTP GET to the API. The response is XML representing the page. You can also point your browser to this url.

» Read more about Silk pages



Information about a site

To get information about a site, for example world.silk.co go to

Another GET to the API which gives you information about the site (name, description) as well as the access levels for the current user (canRead, canWrite, isAdmin).

» Read more about Silk sites



Signing in and authentication 

To sign in you must POST XML to /user/signin like this

The response (in case of a successful login) is XML with information about the logged-in user. The -i parameter was added because it outputs the header, in this header a cookie is sent: silk_sid, it must be used to authenticate the user in subsequent requests.

» Read more about authentication

Get information about the current user

In the previous step we logged in and got a cookie (silk_sid). We use this cookie in subsequent requests to authenticate. For information about the current user do

The first call gives back information aabout the current user, the second call returns a list of the sites you have access to (read and write).

» Read more about users

Create a page

To create a page, we simply post a page (valid! XML) to the API url like this:

There is no difference between creating a new page and updating an existing page. Because Silk holds all the versions of a page, an update to a page can always be reversed.



» Read more about Silk pages

Get site structure 



The semantic structure (information about all the tags) of a site is stored in the taglist. 

The taglist contains all information that Silk has about the structure (the tags and categories) of a page.

» Read more about site structure



Do a simple query



We can search through tags and categories within a Silk site. Silk uses a custom query language (explained here) for this. With this query language we can do a query on e.g. world.silk.co (a Silk site about countries). We want to know the countries that have negative population growth:

The response is a table containing the results of this query.

» Read more about queries