updated readme

This commit is contained in:
Felipe M 2022-08-09 17:39:37 +02:00
parent ba4be3f48f
commit 065a570525
Signed by: fmartingr
GPG Key ID: 716BC147715E716F
1 changed files with 39 additions and 14 deletions

View File

@ -2,35 +2,60 @@
A service/library to extract product information from URLs.
## Configuration
| Variable name | Default | Description |
| -------------- | ------- | ------------------------------ |
| `HTTP_ENABLED` | `true` | Enable/Disable the HTTP server |
| `HTTP_PORT` | `8080` | Port to serve the HTTP in |
## Servers
### HTTP
- `POST /item`
Parameters:
- **url**: The URL to extract information from
Responses:
- `200`: Information extracted
- `400`: Shop not supported, missing parameters
- `500`: Internal error, check logs
- `GET /liveness`
Responses:
- `200`: Server running
## Data model
Currently, this information is extracted from the site (if possbile):
``` js
{
"image_url": "<url>", // (string) URL to an image file
"in_stock": false, // (bool) If the item is currently available for purchase
"name": "<name>", // (string) The name of the product as it appears on the site
"price": 14.21, // (optional, float) The price of the product [parsed by the library]
"price_text": "14,21 €", // (optional, string) The price of the product as it appears on the site (with currency)
"release_date": "2021-03-22T00:00:00Z", // (optional, string RFC3339) the release date of the item
"url": "<url>" // (string) The URL of the item
"description": "...",
"image_url": "https://...",
"in_stock": false,
"name": "...",
"price": 0.0,
"price_text": "0,0 €",
"release_date": "2019-03-08T00:00:00Z",
"url": "https://..."
}
```
[pkg/models/product.go](./pkg/models/product.go)
## Supported sites
Support is handled in a _best effort_ basis. Some sites do not provided all exposed fields.
- [Amazon.es](https://amazon.es)
- [Amazon.com](https://amazon.com)
- [Akira Comics](https://www.akiracomics.com)
- [AkiraComics](https://www.akiracomics.com)
- [Casa del libro](https://www.casadellibro.com)
- [Heroes De Papel](https://heroesdepapel.es)
- [Steam](https://store.steampowered.com)
## Running
```
go run cmd/server/main.go
```