-
-
Notifications
You must be signed in to change notification settings - Fork 15
API
If you want to create an mobile client (or web based app BTW) that consumes the doesangue data, you can to integrate to our platform via API. Follow the steps above to know how to do that easilly.
To make sure you are using the correct endpoint (api routes) check them out.
-
POST:
/v1/auth/register
Sign up a new user
Params:
-
first_name
: User first name (string) -
last_name
: User last name (string) -
email
: User e-mail (string) -
username
: Username (indentifier) (string) -
password
: User password (string) -
phone
: User phone number (number) [optional] -
bio
: User biography (longtext) [optional] -
birthdate
: User birthdate (date, format:Y-m-d
)
Output
{
"data": {
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjgsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODAwMC92MS9hdXRoL3JlZ2lzdGVyIiwiaWF0IjoxNTA2NDI3MTIxLCJleHAiOjE1MDY0MzA3MjEsIm5iZiI6MTUwNjQyNzEyMSwianRpIjoiWFc2SXRpRGhHUDhqbGJvciJ9.4aBnEQ-rxqlkDy2PcRPaPvOol_TSQCHNx1hut8OcBRo",
"token_type": "Bearer"
}
}
-
POST:
/v1/auth/login
Create the Authorization token
Params:
-
email
- The user email (type: string) -
password
User password (type: string)
Example:
curl -X POST \
https://doesangueapi.herokuapp.com/v1/auth/login \
-H "Content-Type:application/json" \
-F email=USER_EMAIL \
-F password=USER_PASSWORD
- Output
{
"data": {
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjEsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODAwMC92MS9hdXRoL2xvZ2luIiwiaWF0IjoxNTA2NDIyOTEwLCJleHAiOjE1MDY0MjY1MTAsIm5iZiI6MTUwNjQyMjkxMCwianRpIjoiMDlESU81aTVVcFY1RnQ5eSJ9.Zv9Fl1CMgObNdVqFYU231umygPNGhkB4SIKkKVOOGBE",
"token_type": "bearer"
}
}
-
GET:
/v1/auth/me
Check who are you (authenticated User)
Params:
- Header
-
"Content-Type: application/json"
- Type/structure of data you are sending -
"Authorization: Bearer token"
- Authentication token
-
Example:
curl -X POST \
https://doesangueapi.herokuapp.com/v1/auth/me \
-H "Content-Type:application/json" \
-H "Authorization: Bearer YOUR_LONG_TOKEN"
- Output
{
"data": {
"first_name": "Test",
"last_name": "User",
"username": "testuser"
}
}
-
GET:
/v1/campaigns
Get all available campaigns
Example:
curl https://doesangueapi.herokuapp.com/v1/campaigns
- Output
"current_page": 1,
"data": [
{
"id": 1,
"title": "Test publication",
"description": "This a test publication i have created to see how it works!",
"image": "",
"expires": "2017-12-31 00:00:00",
"owner": {
"first_name": "Test",
"last_name": "User",
"username": "testuser",
"bio": "I have no bio because i'm a test user!",
},
"comments": [
{
"id": 1,
"comment": "this is a comment on publication #1"
}
...
]
},
...
],
"from": 1,
"last_page": 1,
"next_page_url": null,
"path": "https://doesangueapi.herokuapp.com/v1/campaigns",
"per_page": "12",
"prev_page_url": null,
"to": 5,
"total": 5
}
-
GET:
/v1/campaigns/{id}
Get the campaign details by id
Params:
-
id
- The campign id (type: integer)
Example:
curl https://doesangueapi.herokuapp.com/v1/campaigns/1
- Output
{
"data": {
"title": "Test publication",
"owner": {
"first_name": "Test",
"last_name": "User",
"username": "testuser"
},
"dates": {
"start_at": "2017-08-29 06:08:39",
"finish_at": "2017-12-31 23:59:59"
}
}
}
-
POST:
/v1/campaigns
Add a new campaign
Params:
-
title
- The campign title (type: string) -
description
- The campign description (type: text) -
image
- The campign image (type: string) -
expires
- Expiration date for your campign (type: datetime, format:Y-m-d H:m:s
) -
Header
-
"Content-Type: application/json"
- Type/structure of data you are sending -
"Authorization: Bearer token"
- Authentication token
Example:
-
curl https://doesangueapi.herokuapp.com/v1/campaigns/ -d '{"title: "Other test publication", "description": "Because we are always testing this, i have created just a basic campaign!", "image": "https://assets.doesangue.me/images/campaigns/test.png", "expires": "20190405 20:30:00"}' \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_LONG_TOKEN_HERE"
- Output
{
"status_code": 201,
"message": "Campaign added!"
}
-
GET:
/v1/donors
Get all available donors
Example:
curl https://doesangueapi.herokuapp.com/v1/donors
- Output
[
{
"id": 1,
"user": {
"first_name": "Test",
"last_name": "User",
"username": "testuser",
"email": "testuser@domain.com",
"birthdate": "1998-01-04",
"bio": null
}
},
{
"id": 2,
"user": {
"first_name": "Other anon",
"last_name": "User",
"username": "anon.user",
"email": "anon.user@domain.com",
"birthdate": "1999-01-04",
"bio": null
}
}
...
]