Rest API Clients Traffic - datawizio/pythonAPI GitHub Wiki
- Clients Traffic. With the help of
/people-traffic/
you can get access to the clients traffic at shop and also to add new traffic.
Field name | Field type | Size | Required | Read only | Remark |
---|---|---|---|---|---|
url |
URL | no | yes | url of this object | |
traffic_id |
line | 100 | yes | no | clients traffic identifier |
shop_id |
line | 100 | yes | no | shop identifier |
date |
line | yes | no | date and time of shop visiting |
To manage the /people-traffic/
resource, the following commands are used:
-
GET
- to receive one page on a collection -
POST
- to load documents to relocate products -
DELETE
- delete traffic -
OPTIONS
- meta information about an object structure -
HEAD
- similar toGET
, but you receive only a heading of a response
Command type: GET http://api.datawiz.io/api/v1/people-traffic/
-
.json
- to receive a response from a server in JSON format -
.api
- to receive a response from a server in HTML format (test platform)
-
Format = json | api
- similar to the stated above suffixes -
Page_size = nn
- to establish a page size equal tonn
objects -
Page = n
- to load a pagen
-
Ordering = url | date | order_id
- to sort fields alphabetically (ascending) -
Ordering = -url | -date | order_id
- to sort fields in the reverse order
The "collection" object consists of four fields (count
, next
, previous
, results
).
An example of an empty collection returned by server:
GET http://api.datawiz.io/api/v1/people-traffic/
{
"count": 0,
"next": null,
"previous": null,
"results": []
}
Example of a 2-element collection:
GET http://api.datawiz.io/api/v1/people-traffic/?format=json&page_size=2
:
HTTP 200 OK
Allow: GET, POST, DELETE, OPTIONS
Content-Type: application/json
Vary: Accept
{
"count": 3,
"next": null,
"previous": null,
"results": [
{
"url": "https://api.datawiz.io/api/v1/people-traffic/123/",
"traffic_id": "123",
"shop_id": "157",
"shop_url": "https://api.datawiz.io/api/v1/shops/157/",
"date": "2018-04-11T01:00:00"
},
{
"url": "https://api.datawiz.io/api/v1/people-traffic/124/",
"traffic_id": "124",
"shop_id": "157",
"shop_url": "https://api.datawiz.io/api/v1/shops/157/",
"date": "2018-04-11T01:00:00"
},
{
"url": "https://api.datawiz.io/api/v1/people-traffic/125/",
"traffic_id": "125",
"shop_id": "157",
"shop_url": "https://api.datawiz.io/api/v1/shops/157/",
"date": "2018-04-11T01:00:00"
}
]
}
In case of an error, server returns a response with a corresponding status and an error report in detail
:
HTTP 404 NOT FOUND
Content-Type: application/json
Vary: Accept
Allow: GET, PUT, DELETE, HEAD, OPTIONS, PATCH
{
"detail": "Not found"
}
Command type: POST http://api.datawiz.io/api/v1/people-traffic/?format=json
-
.json
- to receive a response from a server in JSON format -
.api
- to receive a response from a server in HTML format (test platform)
-
Format = json
- to receive a response from a server in JSON format -
Format = api
- to receive a response from a server in HTML format (test platform)
A request contains a JSON-object that describing the traffic. Important three fields: traffic_id
, shop_id
,date
.
Example of request to add new traffic:
POST http://api.datawiz.io/api/v1/people-traffic/?format=json
{
"traffic_id": "124",
"shop_id": "157",
"date": "2018-04-11T01:00:00"
}
At a particular request processing the server returns 201 status code and object creation details.
Example of a server's response:
HTTP 201 CREATED
Content-Type: application / json
Vary: Accept
Location: http://api.datawiz.io/api/v1/people-traffic/
Allow: GET, POST, HEAD, OPTIONS
{
"created": 1,
"updated": 0
}
If an objects with traffic_id
, shop_id
already exists on the server, the request will replace the object on server without notification.
In case of an error, server returns a response with a corresponding status and an error report next to the field, related to that error. If an error is not only about one field, but the whole object, the report will appear next to the key non_field_errors
.
Example of server's response with an error (traffic_id
field is empty):
HTTP 400 BAD REQUEST
Content-Type: application/json
Vary: Accept
Allow: GET, POST, HEAD, OPTIONS
{
"traffic_id": [
"This field is required."
]
}
The following JSON structure returns at this command:
OPTIONS /api/v1/people-traffic/
HTTP 200 OK
Allow: GET, PUT, PATCH, DELETE, OPTIONS
Content-Type: application/json
Vary: Accept
{
"name": "People Traffic Instance",
"description": "",
"renders": [
"application/json",
"text/html"
],
"parses": [
"application/json",
"application/x-www-form-urlencoded",
"multipart/form-data"
],
"actions": {
"PUT": {
"url": {
"type": "string",
"required": false,
"read_only": true,
"label": "Url"
},
"traffic_id": {
"type": "string",
"required": true,
"read_only": false,
"label": "Traffic id"
},
"shop_id": {
"type": "integer",
"required": true,
"read_only": false,
"label": "Shop id"
},
"shop_url": {
"type": "integer",
"required": false,
"read_only": true,
"label": "Shop url"
},
"date": {
"type": "datetime",
"required": true,
"read_only": false,
"label": "Date"
}
}
}
}