mirror of https://github.com/statping/statping
Updated API (markdown)
parent
523c887872
commit
eb865c3ceb
265
API.md
265
API.md
|
@ -1,266 +1,5 @@
|
|||
Statping includes a RESTFUL API so you can view, update, and edit your services with easy to use routes. You can currently view, update and delete services, view, create, update users, and get detailed information about the Statping instance. To make life easy, try out a Postman or Swagger JSON file and use it on your Statping Server.
|
||||
Statping includes a RESTFUL API so you can view, update, and edit your services with easy to use routes. You can currently view, update and delete services, view, create, update users, and get detailed information about the Statping instance. To make life easy, try out Postman or Swagger JSON file and use it on your Statping Server.
|
||||
|
||||
<p align="center">
|
||||
<a href="https://documenter.getpostman.com/view/1898229/RzfiJUd6">Postman</a> | <a href="https://github.com/statping/statping/blob/master/source/tmpl/postman.json">Postman JSON Export</a>
|
||||
<a href="https://documenter.getpostman.com/view/1898229/RzfiJUd6">Postman API Documentation</a>
|
||||
</p>
|
||||
|
||||
## Authentication
|
||||
Authentication uses the Statping API Secret to accept remote requests. You can find the API Secret in the Settings page of your Statping server. To send requests to your Statping API, include a Authorization Header when you send the request. The API will accept any one of the headers below.
|
||||
|
||||
- HTTP Header: `Authorization: API SECRET HERE`
|
||||
- HTTP Header: `Authorization: Bearer API SECRET HERE`
|
||||
|
||||
## Main Route `/api`
|
||||
The main API route will show you all services and failures along with them.
|
||||
|
||||
## Services
|
||||
The services API endpoint will show you detailed information about services and will allow you to edit/delete services with POST/DELETE http methods.
|
||||
|
||||
### Viewing All Services
|
||||
- Endpoint: `/api/services`
|
||||
- Method: `GET`
|
||||
- Response: Array of [Services](https://github.com/statping/statping/wiki/API#service-response)
|
||||
- Response Type: `application/json`
|
||||
- Request Type: `application/json`
|
||||
|
||||
### Viewing Service
|
||||
- Endpoint: `/api/services/{id}`
|
||||
- Method: `GET`
|
||||
- Response: [Service](https://github.com/statping/statping/wiki/API#service-response)
|
||||
- Response Type: `application/json`
|
||||
- Request Type: `application/json`
|
||||
|
||||
### Updating Service
|
||||
- Endpoint: `/api/services/{id}`
|
||||
- Method: `POST`
|
||||
- Response: [Service](https://github.com/statping/statping/wiki/API#service-response)
|
||||
- Response Type: `application/json`
|
||||
- Request Type: `application/json`
|
||||
|
||||
POST Data:
|
||||
```json
|
||||
{
|
||||
"name": "Updated Service",
|
||||
"domain": "https://google.com",
|
||||
"expected": "",
|
||||
"expected_status": 200,
|
||||
"check_interval": 15,
|
||||
"type": "http",
|
||||
"method": "GET",
|
||||
"post_data": "",
|
||||
"port": 0,
|
||||
"timeout": 10,
|
||||
"order_id": 0
|
||||
}
|
||||
```
|
||||
|
||||
### Create New Service
|
||||
- Endpoint: `/api/services`
|
||||
- Method: `POST`
|
||||
- Response: [Service](https://github.com/statping/statping/wiki/API#service-response)
|
||||
- Response Type: `application/json`
|
||||
- Request Type: `application/json`
|
||||
|
||||
POST Data:
|
||||
```json
|
||||
{
|
||||
"name": "Create New Service",
|
||||
"domain": "https://www.coogger.com",
|
||||
"expected": "",
|
||||
"expected_status": 200,
|
||||
"check_interval": 15,
|
||||
"type": "http",
|
||||
"method": "GET",
|
||||
"post_data": "",
|
||||
"port": 0,
|
||||
"timeout": 10,
|
||||
"order_id": 0
|
||||
}
|
||||
```
|
||||
|
||||
### Deleting Service
|
||||
- Endpoint: `/api/services/{id}`
|
||||
- Method: `DELETE`
|
||||
- Response: [Object Response](https://github.com/statping/statping/wiki/API#object-response)
|
||||
- Response Type: `application/json`
|
||||
- Request Type: `application/json`
|
||||
|
||||
Response:
|
||||
```json
|
||||
{
|
||||
"status": "success",
|
||||
"id": 4,
|
||||
"type": "service",
|
||||
"method": "delete"
|
||||
}
|
||||
```
|
||||
|
||||
## Users
|
||||
The users API endpoint will show you users that are registered inside your Statping instance.
|
||||
|
||||
### View All Users
|
||||
- Endpoint: `/api/users`
|
||||
- Method: `GET`
|
||||
- Response: Array of [Users](https://github.com/statping/statping/wiki/API#user-response)
|
||||
- Response Type: `application/json`
|
||||
- Request Type: `application/json`
|
||||
|
||||
### Viewing User
|
||||
- Endpoint: `/api/users/{id}`
|
||||
- Method: `GET`
|
||||
- Response: [User](https://github.com/statping/statping/wiki/API#user-response)
|
||||
- Response Type: `application/json`
|
||||
- Request Type: `application/json`
|
||||
|
||||
### Creating New User
|
||||
- Endpoint: `/api/users`
|
||||
- Method: `POST`
|
||||
- Response: [User](https://github.com/statping/statping/wiki/API#user-response)
|
||||
- Response Type: `application/json`
|
||||
- Request Type: `application/json`
|
||||
|
||||
POST Data:
|
||||
```json
|
||||
{
|
||||
"username": "newadmin",
|
||||
"email": "info@email.com",
|
||||
"password": "password123",
|
||||
"admin": true
|
||||
}
|
||||
```
|
||||
|
||||
### Updating User
|
||||
- Endpoint: `/api/users/{id}`
|
||||
- Method: `POST`
|
||||
- Response: [User](https://github.com/statping/statping/wiki/API#user-response)
|
||||
- Response Type: `application/json`
|
||||
- Request Type: `application/json`
|
||||
|
||||
POST Data:
|
||||
```json
|
||||
{
|
||||
"username": "updatedadmin",
|
||||
"email": "info@email.com",
|
||||
"password": "password123",
|
||||
"admin": true
|
||||
}
|
||||
```
|
||||
|
||||
### Deleting User
|
||||
- Endpoint: `/api/services/{id}`
|
||||
- Method: `DELETE`
|
||||
- Response: [Object Response](https://github.com/statping/statping/wiki/API#object-response)
|
||||
- Response Type: `application/json`
|
||||
- Request Type: `application/json`
|
||||
|
||||
Response:
|
||||
```json
|
||||
{
|
||||
"status": "success",
|
||||
"id": 3,
|
||||
"type": "user",
|
||||
"method": "delete"
|
||||
}
|
||||
```
|
||||
|
||||
# Service Response
|
||||
```json
|
||||
{
|
||||
"id": 8,
|
||||
"name": "Test Service 0",
|
||||
"domain": "https://status.coinapp.io",
|
||||
"expected": "",
|
||||
"expected_status": 200,
|
||||
"check_interval": 1,
|
||||
"type": "http",
|
||||
"method": "GET",
|
||||
"post_data": "",
|
||||
"port": 0,
|
||||
"timeout": 30,
|
||||
"order_id": 0,
|
||||
"created_at": "2018-09-12T09:07:03.045832088-07:00",
|
||||
"updated_at": "2018-09-12T09:07:03.046114305-07:00",
|
||||
"online": false,
|
||||
"latency": 0.031411064,
|
||||
"24_hours_online": 0,
|
||||
"avg_response": "",
|
||||
"status_code": 502,
|
||||
"last_online": "0001-01-01T00:00:00Z",
|
||||
"dns_lookup_time": 0.001727175,
|
||||
"failures": [
|
||||
{
|
||||
"id": 5187,
|
||||
"issue": "HTTP Status Code 502 did not match 200",
|
||||
"created_at": "2018-09-12T10:41:46.292277471-07:00"
|
||||
},
|
||||
{
|
||||
"id": 5188,
|
||||
"issue": "HTTP Status Code 502 did not match 200",
|
||||
"created_at": "2018-09-12T10:41:47.337659862-07:00"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
# User Response
|
||||
```json
|
||||
{
|
||||
"id": 1,
|
||||
"username": "admin",
|
||||
"api_key": "02f324450a631980121e8fd6ea7dfe4a7c685a2f",
|
||||
"admin": true,
|
||||
"created_at": "2018-09-12T09:06:53.906398511-07:00",
|
||||
"updated_at": "2018-09-12T09:06:54.972440207-07:00"
|
||||
}
|
||||
```
|
||||
|
||||
# Object Response
|
||||
```json
|
||||
{
|
||||
"type": "service",
|
||||
"id": 19,
|
||||
"method": "delete",
|
||||
"status": "success"
|
||||
}
|
||||
```
|
||||
|
||||
# Main API Response
|
||||
```json
|
||||
{
|
||||
"name": "Awesome Status",
|
||||
"description": "An awesome status page by Statping",
|
||||
"footer": "This is my custom footer",
|
||||
"domain": "https://demo.statping.com",
|
||||
"version": "v0.56",
|
||||
"migration_id": 1536768413,
|
||||
"created_at": "2018-09-12T09:06:53.905374829-07:00",
|
||||
"updated_at": "2018-09-12T09:07:01.654201225-07:00",
|
||||
"database": "sqlite",
|
||||
"started_on": "2018-09-12T10:43:07.760729349-07:00",
|
||||
"services": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Google",
|
||||
"domain": "https://google.com",
|
||||
"expected": "",
|
||||
"expected_status": 200,
|
||||
"check_interval": 10,
|
||||
"type": "http",
|
||||
"method": "GET",
|
||||
"post_data": "",
|
||||
"port": 0,
|
||||
"timeout": 10,
|
||||
"order_id": 0,
|
||||
"created_at": "2018-09-12T09:06:54.97549122-07:00",
|
||||
"updated_at": "2018-09-12T09:06:54.975624103-07:00",
|
||||
"online": true,
|
||||
"latency": 0.09080986,
|
||||
"24_hours_online": 0,
|
||||
"avg_response": "",
|
||||
"status_code": 200,
|
||||
"last_online": "2018-09-12T10:44:07.931990439-07:00",
|
||||
"dns_lookup_time": 0.005543935
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue