Files
api2/README.md
T

52 lines
1.9 KiB
Markdown

# Photowall API 2
Provides a REST API to Photowall database.
## Installation
Make sure that your system has Python version 3.4 installed. If you dont have it here is how you install it on Ubuntu 12.04:
```
$ sudo add-apt-repository ppa:fkrull/deadsnakes
$ sudo apt-get update
$ sudo apt-get install python3.4 python3.4-dev build-essential libpq-dev
```
Next its recommended that you create a [virtualenv](http://docs.python-guide.org/en/latest/dev/virtualenvs/) of python 3.4 and install all packages in it.
To do that execute the following commands in your project folder:
```
$ virtualenv -p /usr/bin/python3.4 venv
$ source venv/bin/activate
$ pip install -r requirements.txt
```
## Configuration
First copy config.sample.py to config.py. This file will be read by the application on startup.
List of available configuration options:
| Name | Description |
| ---- | ----------- |
| `SQLALCHEMY_DATABASE_URI` | Database connection string. e.g: `postgresql://user:password@localhost/photowall` |
| `DEBUG` | Enable/disable debug mode |
| `API_KEYS` | A list of api keys that are used to authenticate to the API |
| `ESALES_URL` | URL to the eSales server. If its a cloud cluster it has the format `username:password` |
| `ESALES_IMPORT_DIR` | XML-files that should be imported to eSales are temporarily stored in this directory. e.g: `/tmp/esales`
## Authentication
Authentication to the API is performed via HTTP Basic Auth. The user should provide her API key as the basic auth username parameter. An example request in cURL looks like this (adding a colon after the username prevents cURL from asking for a password):
```
$ curl http://localhost:5000/designers/ -u mykey:
```
API keys should be added to the `API_KEYS` configuration option
## Getting started
Starting the application:
`$ python manage.py runserver`
Running the eSales import
`$ python manage.py run_esales_import`