Skip to main content

y.api

About y-api service

The service provides domain categorization services and can be used both locally and in a distributed system. In the latter case, the speed of receiving a response decreases due to network delays.

A stable connection to the Internet is required for the uninterrupted operation of the service:

  • loading the database and updating it
  • sending counter_cat and counter_unknown_cat values
  • sending additional information about the instance with the container

Stats are sent every 5 minutes.


Using y-api service

Starting the service

1. Install docker.
2. Load the archive with the container image with sudo docker load -i y_api.tar.gz 3. Run the image in the docker subnet.
    3.1 Alternatively, create a separate subnet
          sudo docker network create --driver=bridge --subnet=193.33.33.0/24 y-api-net
          and run the container
          sudo docker run -it -d --net y-api-net --ip 193.33.33.33 y-api:1

4. Check the service with curl http://193.33.33.33/qwerty.com

193.33.33.33 is an example, you can use any other network.

Service response: {"category": [36, 49], "bad": false, "category_name": ["Education", "Computers & Internet"]}

ATTENTION! The request counter is sent every 5 minutes. Check time must be shorter so the data is not sent to the statistics server for billing.

Logging is done to stdout and stderr.

The supported request is GET.


Request examples

Request

Answer

curl -v http://193.33.33.33/qwerty.com

< HTTP/1.1 200 OK

< Content-type: application/json

< Connection: keep-alive

* no chunk, no close, no size. Assume close to signal end

<

* Closing connection 0

{"category": [36, 49], "bad": false, "category_name": ["Education", "Computers & Internet"]}

curl -v  http://193.33.33.33/foo

< HTTP/1.1 404 Not Found

< Connection: keep-alive

* Connection #0 to host 193.33.33.33 left intact

curl -v  http://193.33.33.33/stat/

< HTTP/1.1 200 OK

< Content-type: application/json

< Connection: close

<

* Closing connection 0

{"counter_cat": [150002], "counter_unknown_cat": [0]}

curl -v -X POST http://193.33.33.33/qwerty.com

< HTTP/1.1 405 Method Not Allowed

< Content-Type: text/html

< Allow: GET

< Connection: close

* Closing connection 0

If there is no connection with the statistics server or any response from it other than "200 OK".


curl -v  http://193.33.33.33/qwerty.com

< HTTP/1.1 503 Service Unavailable

< Content-type: application/json

< Connection: close

<

* Closing connection 0

{"details": "billing failure"}