You are on page 1of 10

Expense Tracker API

Please use the implementation API when developing/testing the application from a
client.

BASE URL: https://expense-api.fundall.io

Authentication
The API uses oAuth2 for authentication, this means that all API calls should contain
and authorization that looks like this;

Request
Headers
Authorization: Bearer 'API_TOKEN'

Headers
Make sure you have the following content type headers are set on every request:

Headers
Accept: application/json
Content-Type: application/json
Authorization: Bearer 'API_TOKEN'

Responses
The API uses conventional HTTP response codes to indicate the success or failure of
an API request. The table below contains a summary of the typical response codes:

Everything is ok
Response 200
{
"success": {
"message": "message.",
"status": "SUCCESS"
}
}
Valid data was given but the request has failed.
Response 400
{
"error": {
"message": "message.",
"status": "ERROR"
}
}

No valid API Key was given.


Response 401
{
"error": "There was an error authenticating your request",
"code": "BAD_AUTH"
}

Register User

Method: Post
Endpoint: https://expense-api.fundall.io/api/v1/register

Header:
Accept: application/json
Payload
{
"firstname": “Test",
"lastname": “Test",
"email": “test@gmail.com",
"password": "123456",
"password_confirmation": “123456",
}
Response
Failure
{
"error": {
"message": "The firstname field is required."
}
}

Success
{
"success": {
"message": "Registration successfull.",
}
}

Authenticate User

Method: Post
Endpoint: https://expense-api.fundall.io/api/v1/login
Header:
Accept: application/json
Payload
{
"email": "test@gmail.com",
"password": “123456"
}

Response
Failure
{
"error": {
"message": "The email or password you have entered is incorrect.",
"code": "AUTHENTICATION_ERROR",
"status": "ERROR"
}
}
Success
{
"success": {
"user": {
"id": 37,
"firstname": “test",
"lastname": "test",
"email": "ajobiewefemi@gmail.com",
"avatar":
"https://res.cloudinary.com/fundall/image/upload/v1565173587\/899cc47f-397f-487b-
87e1-38ea702c336d.png",
"monthly_target": 0,
"created_at": "2019-02-27 11:04:11",
"updated_at": "2019-02-27 17:49:03",
"access_token":
"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImM0OTNiNTgxMTNmNDBkNTlk
MDFjNWM5MWViMDY2YmZlNWFmMGYxYTUyM2Q1NTU2ZmM4OTFkODZkOTQ4OD
dhODA5Nzg2MjYwYjAxZjJjMTZmIn0.eyJhdWQiOiIzIiwianRpIjoiYzQ5M2I1ODExM2Y0",
"token_type": "Bearer",
"expires_at": "2020-02-27 18:55:05"
},
"status": "SUCCESS"
}
}

Get User Data

Method: Get
Endpoint: https://expense-api.fundall.io/api/v1/base/profile

Header:
Accept: application/json
Authorization: Bearer
eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjAxNDI5ZDNjMmFjODRlYTAzY2Yz
MmE4MDZlM2ZhMjdiZjA3ZDhkYTg0YzQ2ZGI4ODVkZjU1MjAwZjQzYjI2NDUyMTFmYj
Q0MGQwMmMwededZTJmIn0.eyJhdWQiOiIzIiwianRpIjoiMDE0MjlkM2MyYWM4NGVh
MDNjZjMyYTgwNmUzZmEyN2JmMDdkOGRhODRjNDZkYjg4NWRmNTUyMDBmNDNi
MjY0NTIxMWZiNDQwZDAyYzBlMmYiLCJpYXQiOjE1NDc5ODk2OTUsIm5iZiI6MTU0Nz
k4OTY5NSwiZXhwIjoxNTc5NTI1Njk1LCJzdWIiOiIyNSIsInNjb3BlcyI6W119.at26f8JzCiv1
QgItlEwrC8qZHWsWhzk4OpBf3g2tJT6c9ORbTnYaF9WOmiqPPaqdqdZmb1DsKFejCJi

Response
Failure
{
"error": "There was an error authenticating your request",
"code": "BAD_AUTH"
}

Success
{
"success": {
“Status”: “SUCCESS”,
"data": {
"id": 37,
"firstname": “test",
"lastname": "test",
"email": "ajobiewefemi@gmail.com",
"avatar":
"https://res.cloudinary.com/fundall/image/upload/v1565173587\/899cc47f-397f-487b-
87e1-38ea702c336d.png",
"monthly_target": 0,
}
}
}

Add Expense

Method: Post
Endpoint: https://expense-api.fundall.io/api/v1/base/expense

Header:
Accept: application/json
Authorization: Bearer
eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjAxNDI5ZDNjMmFjODRlYTAzY2Yz
MmE4MDZlM2ZhMjdiZjA3ZDhkYTg0YzQ2ZGI4ODVkZjU1MjAwZjQzYjI2NDUyMTFmYj
Q0MGQwMmMwZTJmIn0.eyJhdWQiOiIzIiwianRpIjoiMDE0MjlkM2MyYWM4NGVhMDNj
ZjMyYTgwNmUzZmEyN2JmMDdkOGRhODRjNDZkYjg4NWRmNTUyMDBmNDNiMjY0
NTIxMWZiNDQwZDAyYzBlMmYi
Payload
{
"date": “23/07/1989", //dd/mm/yyyy
"amount": “30000",
}

Response

Failure
{
"error": {
"message": "The firstname field is required.",
“status”: “ERROR”
}
}

{
"error": {
"message": "Invalid date.",
“status”: “ERROR”
}
}

Success
{
"success": {
"status": "SUCCESS",
"message": "Expense added successfully."
}
}
Get all Expenses

Method: Get
Endpoint: https://expense-api.fundall.io/api/v1/base/expenses

Header:
Accept: application/json
Authorization: Bearer
eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjAxNDI5ZDNjMmFjODRlYTAzY2Yz
MmE4MDZlM2ZhMjdiZjA3ZDhkYTg0YzQ2ZGI4ODVkZjU1MjAwZjQzYjI2NDUyMTFmYj
Q0MGQwMmMwZTJmIn0.eyJhdWQiOiIzIiwianRpIjoiMDE0MjlkM2MyYWM4NGVhMDNj
ZjMyYTgwNmUzZmEyN2JmMDdkOGRhODRjNDZkYjg4NWRmNTUyMDBmNDNiMjY0
NTIxMWZiNDQwZDAyYzBlMmYi

Response

Success
{
"success": {
"current_page": 1,
"data": [
{
"id": 4,
"date": "1235-11-12 12:14:55",
"price": "2,000"
},
{
"id": 3,
"date": "1235-11-12 12:14:21",
"price": "2"
},
{
"id": 2,
"date": "1235-11-12 12:14:07",
"price": "2,000"
}
],
"first_page_url": "http:\/\/localhost:8033\/api\/v1\/base\/expenses?page=1",
"from": 1,
"last_page": 2,
"last_page_url": "http:\/\/localhost:8033\/api\/v1\/base\/expenses?page=2",
"next_page_url": "http:\/\/localhost:8033\/api\/v1\/base\/expenses?page=2",
"path": "http:\/\/localhost:8033\/api\/v1\/base\/expenses",
"per_page": 3,
"prev_page_url": null,
"to": 3,
"total": 4
}
}

Update Avatar

Method: Post
Endpoint: https://expense-api.fundall.io/api/v1/base/avatar

Header:
Content-Type: multipart/form-data
Authorization: Bearer
eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjAxNDI5ZDNjMmFjODRlYTAzY2Yz
MmE4MDZlM2ZhMjdiZjA3ZDhkYTg0YzQ2ZGI4ODVkZjU1MjAwZjQzYjI2NDUyMTFmYj
Q0MGQwMmMwZTJmIn0.eyJhdWQiOiIzIiwianRpIjoiMDE0MjlkM2MyYWM4NGVhMDNj
ZjMyYTgwNmUzZmEyN2JmMDdkOGRhODRjNDZkYjg4NWRmNTUyMDBmNDNiMjY0
NTIxMWZiNDQwZDAyYzBlMmYi
Payload

{
“avatar”: {},
}
Response
Failure
{
"error": {
"message": "The avatar field is required.",
"code": "VALIDATION_ERROR",
"status": "ERROR"
}
}

Success
{
"success": {
"status": "SUCCESS",
"message": "Avatar uploaded successfully!"
}
}

Update Monthly Target


Method: Post
Endpoint: https://expense-api.fundall.io/api/v1/base/monthly-target

Header:
Accept: application/json
Authorization: Bearer
eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjAxNDI5ZDNjMmFjODRlYTAzY2Yz
MmE4MDZlM2ZhMjdiZjA3ZDhkYTg0YzQ2ZGI4ODVkZjU1MjAwZjQzYjI2NDUyMTFmYj
Q0MGQwMmMwZTJmIn0.eyJhdWQiOiIzIiwianRpIjoiMDE0MjlkM2MyYWM4NGVhMDNj
ZjMyYTgwNmUzZmEyN2JmMDdkOGRhODRjNDZkYjg4NWRmNTUyMDBmNDNiMjY0
NTIxMWZiNDQwZDAyYzBlMmYi

Payload
{
"monthly_target": “200000",
}
Response
Failure
{
"error": {
"message": "The monthly target field is required."
}
}

Success
{
"success": {
"status": "SUCCESS",
"message": "Monthly target successfully updated!",
}
}

You might also like