API === There is an API available to manage your content. The python examples here use the "requests" library which you'll need to install. Installing and setting up python and requests is outside the scope of this document. The curl examples should work from any terminal if you install cURL for your operating system. ..note: The API is a work in progress and should be considered Alpha quality. No long-term support or endpoint guarantees are provided. I'd really like to hear how other people are using the API, so drop me a line if you are using it. That being said, the alpha endpoints are in use extensively, and power the CLI. I've got a lot invested in making them good. I want to solve pagination in the short term. I also want everything that you can do from any interface to be available in the API. We're pretty close to that, but not everything is stable enough or tested enough to even be documented here. Please reach out to me directly if you've got any questions --Issac Logging In ++++++++++ Use your email and password and HTTP Basic Auth to log in. If you would like application-specific or special-case users created, please contact support. Examples ~~~~~~~~ Python ------ .. code-block:: python > import requests > resp = requests.get('https://www.example.com.sites.glass/siteapi/pages.json', auth=('sandra@example.com', 'g3n$eattDKLLd') > print resp.content [ { "last_edit_by":"1966d686-f98f-476e-981e-13824f884f85", "parent":null, "created":"2015-12-11T00:32:43.410609+00:00*",* **"template_name":"base.html", "site_id":"9ac0b943-5c8c-4da0-b4dd-3588f916b9cc", "modified":"2015-12-11T00:32:43.410630+00:00", "template_id":"9cbf6c5c-b70b-4640-9de9-403712f0f5cf", "content":{}, "children":[], "template":{ "last_edit_by":"1966d686-f98f-476e-981e-13824f884f85", "admin_fields":null, "sha":"976e4949736bf58eb059b0c9b84e6679617a90b0", "path":"fireflies.html", "id":"9cbf6c5c-b70b-4640-9de9-403712f0f5cf", "last_edit_by_email":"sandra@example.com" }, "published":null, "path":"fireflies", "id":"57c7b6be-20db-4583-93d2-f1e7ae0dd09f", "last_edit_by_email":"sandra@example.com" } ] curl ---- .. code-block:: bash $ curl --user sandra@example.com:g3n$eattDKLLd http://www.example.com.sites.glass/siteapi/pages.json [ { "last_edit_by":"1966d686-f98f-476e-981e-13824f884f85", "parent":null, "created":"2015-12-11T00:32:43.410609+00:00", "template_name":"base.html", "site_id":"9ac0b943-5c8c-4da0-b4dd-3588f916b9cc", "modified":"2015-12-11T00:32:43.410630+00:00", "template_id":"9cbf6c5c-b70b-4640-9de9-403712f0f5cf", "content":{}, "children":[], "template":{ "last_edit_by":"1966d686-f98f-476e-981e-13824f884f85", "admin_fields":null, "sha":"976e4949736bf58eb059b0c9b84e6679617a90b0", "path":"fireflies.html", "id":"9cbf6c5c-b70b-4640-9de9-403712f0f5cf", "last_edit_by_email":"sandra@example.com" }, "published":null, "path":"fireflies", "id":"57c7b6be-20db-4583-93d2-f1e7ae0dd09f", "last_edit_by_email":"sandra@example.com" } ] Pages +++++ List Pages ~~~~~~~~~~ Endpoint: /siteapi/pages.json Examples are the same as login examples, Create a new Page ~~~~~~~~~~~~~~~~~ Endpoint: /siteapi/new_page Send a POST request Optional Parameters: * **path**: Defaults to "/" which is the homepage * **title**: Auto-populates content.title * **template**: defaults to "templates/index.html" * **parent**: Defaults to None/null, no parent * **content**: Accepts stringified JSON, defaults to empty content * **published**: Accepts ISO9801 Datetime string (e.g. 2008-11-14T12:00:00) * **created**: Accepts ISO9801 Datetime string (e.g. 2008-11-14T12:00:00) * **redirect**: If this field is populated, this will setup a redirect from the given `path` to the URL provided. It can be a local URL (beginning with /) or an absolute URL (http://zooborns.com) Examples -------- Python ****** .. code-block:: python import requests me = ('sandra@example.com', 'g3n$eattDKLLd') url = 'http://www.example.com.sites.glass/siteapi/new_page' resp = request.post(url, auth=me, data={ path: "/contact", title: "Get in touch", }) Curl **** .. code-block:: bash curl -v --user sandra@example.com:g3n$eattDKLLd --data path=/contact --data title="Get in touch" http://www.example.com.sites.glass/siteapi/pages Get a Page ~~~~~~~~~~ Send a GET request to `/.json` curl -v --user sandra@example.com:g3n$eattDKLLd http://www.example.com.sites.glass/path/to/page.json Update a Page ~~~~~~~~~~~~~ Send a POST request to `/.json` with the contents of the page update. The easiest thing to do is edit the contents of a previous `GET` request to the same URL. curl -v --user sandra@example.com:g3n$eattDKLLd http://www.example.com.sites.glass/path/to/page.json --data '{"content": {"title": "How to use a teeter totter", "main_text": "Carefully"}}' Templates, CSS, JavaScript, Images and Files ++++++++++++++++++++++++++++++++++++++++++++ List Files ~~~~~~~~~~ Endpoint: /siteapi/files.json Send a GET request Examples -------- Python ****** .. code-block:: python import requests resp = requests.get('http://www.example.com.sites.glass/siteapi/files.json', auth=('sandra@example.com', 'g3n$eattDKLLd') print resp.content curl **** .. code-block:: bash curl --user sandra@example.com:g3n$eattDKLLd http://www.example.com.sites.glass/siteapi/files.json Upload a File ~~~~~~~~~~~~~ This endpoint will create a new file or update the existing file with the same path. Endpoint: /siteapi/upload Send a POST request required parms: * **file**: the file being uploaded * **path**: Examples -------- Python ****** .. code-block:: python local_file = 'css/all.css' with open(local_file) as fb: resp = requests.post( "http://www.example.com.sites.glass/siteapi/upload" files=[ ('file', ("all.css", fb, "text/css"), ], data={ "path": local_file }, auth=me ) Data ++++ Query Data ~~~~~~~~~~ Endpoint: /siteapi/data/query Send a GET request. Query Params * category - optional, filter for data with this category. * bucket - optional, filter for data with this bucket. * record - optional, filter for data with this record. * order_by - optional, default=-created, options are created, modified, record, bucket, category and ? Forms +++++ Get Form Submissions ~~~~~~~~~~~~~~~~~~~~ Forms are a special type of Data. Query for forms with category= and bucket=form. Examples -------- Python ****** .. code-block:: python resp = requests.get("http://www.example.com.sites.glass/siteapi/data/query", {"bucket": "form"}, auth=me) Navigation ++++++++++ Get Navigation Trees ~~~~~~~~~~~~~~~~~~~~ Navigation Trees are a special type of Data. Query for forms with category=nav Examples -------- Python ****** .. code-block:: python resp = requests.get("http://www.example.com.sites.glass/siteapi/data/query", {"category": "nav"}, auth=me)