Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.
Jesus Ortega edited this page Jun 19, 2016 · 4 revisions

API

The API currently support the following methods. Please do have in mind that all requests made to the API must have a valid api_token in the url:

Example endpoint URL: http://logcentral.dev/api/logs/store?api_key=qwertyASD

Please note that all request must be POST and with a valid JSON body in order to be processed correctly, the response given by LogCentral will be a JSON response with a HTTP 200 code, that will look like this.

{
   "success": true,
   "message": "Log saved successfully"

}

Where:

Field Value
success Boolean
message String, give some insight about what was made

Logs

URL: api/logs

The following actions are valid for:

Store /store

This method will allow you to save logs into the database, by using this request schema:

{
	"action": "User log in",
	"date": "2016-06-10 11:05:00",
	"have_diff": false

}

Response:

{
	"success": true,
	"message": "Log successfully saved"
}

If you choose to send a log with have_diff: true then you can add the diffs like this:

{
	"action": "User log in",
	"date": "2016-06-10 11:05:00",
	"have_diff": true,
	"diffs": [{
		"field": "name",
		"old_value": "Jhon doe",
		"new_value": "Jon snow"
	}, {
		"field": "direction",
		"old_value": "North",
		"new_value": "West?"
	}]

}

Reponse:

{
	"success": true,
	"message": "Log successfully saved with diffs"
}

Recents /recents

This will return the 100 most recent logs order by date, this request does not need a body

Response:

{
	"success": true,
	"logs": [{
		"id": 93,
		"message": "Vel velit eos officia voluptates dicta et dolorum labore.",
		"date": "2015-05-18 02:04:29",
		"level": 2,
		"stream_id": 1,
		"raw_input": "",
		"have_diff": 0
	}, {
		"id": 23,
		"message": "Debitis ullam mollitia qui.",
		"date": "2015-05-20 02:26:49",
		"level": 2,
		"stream_id": 3,
		"raw_input": "",
		"have_diff": 0
	}]
}
Field Value
success Boolean
logs array of logs
logs@id Log ID
log@message Action
log@date DateTime
log@stream_id Stream ID
log@raw_input Raw Input (not in use at the moment)
log@have_diff Boolean

Diffs /diffs

This will return the diffs for a given log_id, passed in the request's body.

Requests:

{
    "log_id": 100
}

Response:

{
	"response": true,
	"diffs": [{
		"field": "kings_hand",
		"old_value": "Jaime",
		"new_value": "The other guy",
		"created_at": "2015-05-20 02:26:49"
	}, {
		"field": "num_people",
		"old_value": "5",
		"new_value": "4",
		"created_at": "2015-05-20 02:26:49"
	}]
}
Clone this wiki locally