-
Notifications
You must be signed in to change notification settings - Fork 81
Projects API
This document outlines the API design for organization projects. The concept is based on the projects [user flow] (https://drive.google.com/file/d/0BzpiEtMtHC3rM0RlaGt2UVFPMDA/view) and [project wireframes] (https://drive.google.com/file/d/0BzpiEtMtHC3reU94eGlrNmlialU/view) that the platform is going to support initially
GET /organizations/{organisation-slug}/projects/
Accept: application/json
Content-Type: application/json
Authorization: Token 1398dojk9sd8jf9hsd89hd
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"id": "0asjij9asjd8jh8ghashgd7",
"name": "Region 3 Vineyards",
"organization": "Habitat for Humanity",
"country": "Uganda"
"description: "The FAO, in collaboration with the Ministry, Kasese
District and the Makerere University, and with finacial support from
the UK Department for international development, has documented property
rights using the OpenTenure tool, in order to issue Customary
Certificate of Occupancy",
"logo": {
"mime_type": "image/png",
"url": "some/url/on/s3"
},
"archived": false,
"urls": ["http://exmaple.com"],
"contacts": [ // following http://microformats.org/wiki/h-card
{
"type": ["hcard"],
"properties": {
"name": ["John Doe"],
"email": ["mailto:d.john@example.com"]
}
}
]
},
{
"id": "0asjij9asjd8jh8ghashgd7",
"name": "Mapping property rights in Colombia",
"organization": "Habitat for Humanity",
"country": "Kenya"
"description: "Project to map property rights in Colombia",
"logo": {
"mime_type": "image/png",
"url": "some/url/on/s3"
},
"archived": false,
"urls": ["http://exmaple.com"],
"contacts": [ // following http://microformats.org/wiki/h-card
{
"type": ["hcard"],
"properties": {
"name": ["John Doe"],
"email": ["mailto:d.john@example.com"]
}
}
]
},
]
Providing a query for parameter search will return a list of projects where name, organization or description match the provided query.
GET /organizations/{organisation-slug}/projects/?search=habitat
Orders the response according to name.
GET /organizations/{organisation-slug}/projects/?ordering=name
For descending ordering add add a dash to the ordering attribute
GET /organizations/{organisation-slug}/projects/?ordering=-name
[
{
"id": "0asjij9asjd8jh8ghashgd7",
"name": "Region 3 Vineyards",
"organization": "Habitat for Humanity",
"country": "Uganda"
"description: "The FAO, in collaboration with the Ministry, Kasese
District and the Makerere University, and with finacial support from
the UK Department for international development, has documented property
rights using the OpenTenure tool, in order to issue Customary
Certificate of Occupancy",
"logo": {
"mime_type": "image/png",
"url": "some/url/on/s3"
},
"archived": false,
"urls": ["http://exmaple.com"],
"contacts": [ // following http://microformats.org/wiki/h-card
{
"type": ["hcard"],
"properties": {
"name": ["John Doe"],
"email": ["mailto:d.john@example.com"]
}
}
]
}
]
When the request content contains invalid data
HTTP/1.1 400 Bad request
Content-Type: application/json
{
"name": "This field is required"
}
When the request is not signed with a auth token
HTTP/1.1 401 Unauthorized
Content-Type: application/json
{
"error": "Please sign in."
}
The request Content-Type
must be multipart/formdata
to allow
uploading files together with other form data.
POST /organizations/{organisation-slug}/projects/
Content-Type: multipart/formdata
Authorization: Token 1398dojk9sd8jf9hsd89hd
---separator---
Content-Disposition: form-data; name="name"
Mapping land rights in Philippines
---separator---
Content-Disposition: form-data; name="description"
Recording property rights in the Philippines
---separator---
Content-Disposition: form-data; name="organization"
Habitat for Humanity
---separator---
Content-Disposition: form-data; name="country"
Philippines
---separator---
Content-Disposition: form-data; name="url"
http://www.habitat.org/
---separator---
Content-Disposition: form-data; name="logo"; filename="logo.png"
Content-Type: image/png
---separator---
Content-Disposition: form-data; name="contacts"
[ // following http://microformats.org/wiki/h-card
{
"type": ["hcard"],
"properties": {
"name": ["John Doe"],
"email": ["mailto:d.john@example.com"]
}
}
]
---separator---
HTTP/1.1 201 Created
Content-Type: application/json
{
"id": "7etrtjkhgfd4567uhjgfe456h",
"name": "Mapping land rights in Philippines",
"country": "Philippines"
"description: "Recording property rights in the Philippines",
"logo": "some/url/on/s3",
"archived": false,
"contacts": [ // following http://microformats.org/wiki/h-card
{
"type": ["hcard"],
"properties": {
"name": ["Nicole Smith"],
"email": ["mailto:n.smith@example.com"]
}
}
],
"users": []
}
GET /organizations/{organisation-slug}/projects/{project-slug}/
Accept: application/json
Content-Type: application/json
Authorization: Token 1398dojk9sd8jf9hsd89hd
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"id": "0asjij9asjd8jh8ghashgd7",
"name": "Region 3 Vineyards",
"organization": "Habitat for Humanity",
"country": "Uganda"
"description: "The FAO, in collaboration with the Ministry, Kasese
District and the Makerere University, and with finacial support from
the UK Department for international development, has documented property
rights using the OpenTenure tool, in order to issue Customary
Certificate of Occupancy",
"logo": {
"mime_type": "image/png",
"url": "some/url/on/s3"
},
"archived": false,
"urls": ["http://exmaple.com"],
"contacts": [ // following http://microformats.org/wiki/h-card
{
"type": ["hcard"],
"properties": {
"name": ["John Doe"],
"email": ["mailto:d.john@example.com"]
}
}
]
}
]
Project not found
HTTP/1.1 404 Not found
Content-Type: application/json
{
"error": "Project does not exist"
}
GET /organizations/{organisation-slug}/projects/{project-slug}
Authorization: Token 1398dojk9sd8jf9hsd89hd
HTTP/1.1 200 OK
[
{
"username": "d_john,
"first_name": "John",
"last_name": "Doe",
"email": "d.john@example.com",
"email_verified": true
}
]
When the request is not signed with a auth token
HTTP/1.1 401 Unauthorized
Content-Type: application/json
{
"error": "Please sign in."
}
When the user is not authorised to see project users
HTTP/1.1 403 Forbidden
Content-Type: application/json
{
"error": "You are not allowed to access users of this project."
}
Project not found
HTTP/1.1 404 Not found
Content-Type: application/json
{
"error": "Project does not exist"
}
For security reasons, the existence of entities should not be revealed when the user does not have permissions to access the entity, hence 404 Not found should be returned.
POST /organizations/{organisation-slug}/projects/{project-slug/}users/
Content-Type: application/json
Authorization: Token 1398dojk9sd8jf9hsd89hd
{ "username": "some-user" }
HTTP/1.1 201 Created
When the request is not signed with a auth token
HTTP/1.1 401 Unauthorized
Content-Type: application/json
{
"error": "Please sign in."
}
When the user is not authorised to add users to a project
HTTP/1.1 403 Forbidden
Content-Type: application/json
{
"error": "You are not allowed to add users to the project."
}
Project not found
HTTP/1.1 404 Not found
Content-Type: application/json
{
"error": "Project does not exist"
}
For security reasons, the existence of entities should not be revealed when the user does not have permissions to access the entity, hence 404 Not found should be returned.
DELETE /organizations/{organisation-slug}/projects/{project-slug}/users/{username}/
Authorization: Token 1398dojk9sd8jf9hsd89hd
HTTP/1.1 204 No Content
When the request is not signed with a auth token
HTTP/1.1 401 Unauthorized
Content-Type: application/json
{
"error": "Please sign in."
}
When the user is not authorised to remove users from the project
HTTP/1.1 403 Forbidden
Content-Type: application/json
{
"error": "You are not allowed to remove users from the project."
}
Project not found
HTTP/1.1 404 Not found
Content-Type: application/json
{
"error": "Project does not exist"
}
For security reasons, the existence of entities should not be revealed when the user does not have permissions to access the entity, hence 404 Not found should be returned.
Visit our User Documentation to learn more about using the Cadasta Platform.
If you'd like to contribute to the Cadasta Platform, start with our Contributing Guidelines.
Cadasta Wiki Home | Developer Setup Guide
Cadasta.org | About Cadasta | YouTube | Twitter | Facebook
- Installing & Running
- Contributing
- Planning & Sprints
- Platform Development
- Testing
- Utilities
- Outreachy
- Platform Site Map
- User Flows and Wireframes
- Other
- Quick Start Guide
- Glossary
- Questionnaire Guide