Skip to content

GoteoFoundation/goteo-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GOTEO API

Build Status Code Climate Test Coverage

This is the code for the goteo api.

Please refer to the INSTALL.md file for info about installing this API.

Full documentation to use the official api can be found here: https://developers.goteo.org/doc/

Easy install using Vagrant:

The included Vagrantfile is ready to provision a ready-to-go system with a test database and all the required dependencies installed:

vagrant up
vagrant ssh
./run

Install/update dependencies:

./deployer

Run a test server on localhost:

./run

Flask command line order:

Cache clearing:

./console clearcache

Cache renewing:

./console renewcache

Crontab install for automatic cache renew:

./console crontab -i

Remove crontab install:

./console crontab -r

Running tests:

NOTE: Testing with the argument --reset-database will remove all tables in the test database!

Configure a proper config_test.py before testing

First time you may want to reset the test database:

./run-tests --reset-database

All tests at once (verbose):

./run-tests -v

Specific tests: (verbose, with echoes):

./run-tests goteoapi -v -s goteoapi/tests/testprojects.py

Running code coverage tests:

./run-tests --cover-html --with-coverage

Running code coverage tests with all packages:

./run-tests --cover-html --with-coverage --cover-package=goteoapi_reports --cover-package=goteoapi_digests

Tests uses nosetests. Same nosetests command arguments applies to run-tests script

Extending the API

To run the API with extra packages you must configure the variable MODULES int the file config.py (extra packages such as: goteoapi_reports, goteoapi_digests)

...

MODULES = {
    # reports endpoints
    'goteoapi_reports.controllers',
    # digests endpoints
    'goteoapi_digests.controllers'
}

...

Examples

Obtain a list of active projects:

curl -i --user "goteo:goteo" http://0.0.0.0:5000/projects

Getting details for a custom project:

curl -i --user "goteo:goteo" http://0.0.0.0:5000/projects/project-id

Filtering some data, in this case, all projectes published starting in october 2015:

curl --user "goteo:goteo" -i -X GET -H "Content-Type: application/json" -d '{"from_date":"2015-10-01"}' http://localhost:5000/projects/

Obtaining an error message:

curl -i --user "goteo:goteo" -X GET -H "Content-Type: application/json" http://0.0.0.0:5000/projects/

Response:

HTTP/1.0 400 BAD REQUEST
Content-Type: application/json
Content-Length: 53
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: POST, OPTIONS, GET
Access-Control-Allow-Headers: Authorization
Access-Control-Max-Age: 1
Server: Werkzeug/0.10.4 Python/2.7.6
Date: Mon, 01 Feb 2016 13:36:53 GMT

{
    "message": "Bad Request",
    "status": 400
}

Check the full documentation here: https://developers.goteo.org/doc/

License

The code licensed here under the GNU Affero General Public License, version 3 AGPL-3.0 has been developed by the Goteo team led by Platoniq and subseque ntly transferred to the Fundación Goteo, as detailed in http://www.goteo.org/about#info6

This is a web tool that allows the receipt, review and publishing of collective campaigns for their collective funding and the receiving of collaborations a s well as the dynamic visualization of the support received, classification of initiatives and campaign tracking. The system also permits secure and distrib uted communication with users and between users, administration of highlighted projects on the home page and the creation of periodical publications such as blogs, a FAQ section and static pages.