All non-ASCII characters are escaped, i.e. ą is replaced with \u0105.
All of the responses are not pretty-printed in the production environment.
At first we declare some primitive types:
{
"name": <string>,
"symbol": <string>,
"value": <float>
}name: name of the currency
symbol: three letter symbol of the currency
value: value of the currency
{
"name": "Harna\u015b",
"symbol": "HAR",
"value": 1.0
}{
"amount": <int>,
"currency": <Currency>
}amount: amount of the given currency
currency: currency that the amount is in
{
"amount": 4,
"currency": {
"name": "Harna\u015b",
"symbol": "HAR",
"value": 1
}
}{
"accepted_currencies": [
<Currency>,
<Currency>
],
"name": <string>,
"uid": <string>
}accepted_currencies: currencies accepted by the user
name: user-readable name of the user
uid: unique id of the user
{
"accepted_currencies": [
{
"name": "Harna\u015b",
"symbol": "HAR",
"value": 1.0
}
],
"name": "Karol",
"uid": "KyumBFaY66ZdS3oG7fPZQZycKyC2"
}{
"created_at": <string>,
"description": <string>,
"id": <int>,
"images": <array[<Image>]>,
"price": <array[<Price>]>,
"seller_id": <string>,
"title": <string>,
"location": <string>
}created_at: date and time of the offer creation
description: description of the offer
id: unique id of the offer
images: array of the offer images
price: price of the offer
seller_id: id of the user that created the offer
title: title of the offer
location: location of the offer (textual)
{
"created_at": "2022-10-31T18:32:19",
"description": "Bardzo ładna półeczka we wspaniałym stanie",
"images": [
{
"image_id": 1,
"original": "http://localhost:8080/images/cb1a6d25-403d-4b96-aef2-29eef9d84c60_original.jpg",
"preview": "http://localhost:8080/images/cb1a6d25-403d-4b96-aef2-29eef9d84c60_preview.jpg",
"thumbnail": "http://localhost:8080/images/cb1a6d25-403d-4b96-aef2-29eef9d84c60_thumbnail.jpg"
},
{
"image_id": 3,
"original": "http://localhost:8080/images/cb1a6d25-403d-4b96-aef2-29eef9d84c60_original.jpg",
"preview": "http://localhost:8080/images/cb1a6d25-403d-4b96-aef2-29eef9d84c60_preview.jpg",
"thumbnail": "http://localhost:8080/images/cb1a6d25-403d-4b96-aef2-29eef9d84c60_thumbnail.jpg"
},
],
"location": "Kraków",
"offer_id": 1,
"price": [
{
"amount": 4.0,
"currency": {
"name": "Harnaś",
"symbol": "HAR",
"value": 1.0
}
},
{
"amount": 2.0,
"currency": {
"name": "Tyskie",
"symbol": "TYS",
"value": 1.9
}
}
],
"seller_id": "KyumBFaY66ZdS3oG7fPZQZycKyC2",
"title": "Półeczka"
}{
"content": <string>,
"is_sent": <bool,
"message_id": <int>,
"receiver": <User>,
"sender": <User>,
"sent_at": <string>
}content: content of the message
message_id: unique id of the message
receiver_id: id of the user that received the message
sender_id: id of the user that sent the message
sent_at: date and time of the message creation
{
"content": "Hello",
"message_id": 1,
"receiver_id": "iELOTJC3k6VMCrrtamFq7907REz1",
"sender_id": "KyumBFaY66ZdS3oG7fPZQZycKyC2",
"sent_at": "2022-11-09T16:58:44.039167"
}{
"image_id": <int>,
"original": <string>,
"preview": <string>,
"thumbnail": <string>
}image_id: unique id of the image
original: URL of the original image
preview: URL of the image scaled to 200x113px
thumbnail: URL of the image scaled to 96x96px
{
"image_id": 13,
"original": "https://cdn.piwegro.lol/images/13/original.png",
"preview": "https://cdn.piwegro.lol/images/13/preview.png",
"thumbnail": "https://cdn.piwegro.lol/images/13/thumbnail.png"
}{
"error": <string>
}error: user-readable error message
{
"error": "User with given email already exists"
}All dates and times are formatted in the ISO 8601 format, e.g. 2019-05-18T15:17:00+00:00.
For the endpoints that require authorization, the Authorization header needs to be provided with the value
of Bearer <token>, where <token> is the token obtained from the Google Firebase Auth API.
Those responses might be returned by any endpoint (are not specific to any endpoint).
Might be returned if the server is unable to process the request because of an internal issue and not because of the request itself.
<Error>
{
"error": "The database cannot be accessed"
}Is returned when the authentication token is missing or invalid.
<Error>
{
"error": "The 'Authorization' header is missing"
}Is returned when the user is not authorized to perform the requested action.
<Error>
{
"error": "You are not authorized to perform this action"
}The responses in case of 5XX errors are not guaranteed.
Returns offer with given id.
id: id of the offer
None
The offer with a given id was found.
<Offer>
{
"created_at": "2022-10-31T18:32:19",
"description": "Bardzo ładna półeczka we wspaniałym stanie",
"images": [
{
"image_id": 1,
"original": "http://localhost:8080/images/cb1a6d25-403d-4b96-aef2-29eef9d84c60_original.jpg",
"preview": "http://localhost:8080/images/cb1a6d25-403d-4b96-aef2-29eef9d84c60_preview.jpg",
"thumbnail": "http://localhost:8080/images/cb1a6d25-403d-4b96-aef2-29eef9d84c60_thumbnail.jpg"
},
{
"image_id": 3,
"original": "http://localhost:8080/images/cb1a6d25-403d-4b96-aef2-29eef9d84c60_original.jpg",
"preview": "http://localhost:8080/images/cb1a6d25-403d-4b96-aef2-29eef9d84c60_preview.jpg",
"thumbnail": "http://localhost:8080/images/cb1a6d25-403d-4b96-aef2-29eef9d84c60_thumbnail.jpg"
},
{
"image_id": 2,
"original": "http://localhost:8080/images/cb1a6d25-403d-4b96-aef2-29eef9d84c60_original.jpg",
"preview": "http://localhost:8080/images/cb1a6d25-403d-4b96-aef2-29eef9d84c60_preview.jpg",
"thumbnail": "http://localhost:8080/images/cb1a6d25-403d-4b96-aef2-29eef9d84c60_thumbnail.jpg"
}
],
"location": "Kraków",
"offer_id": 1,
"price": [
{
"amount": 4.0,
"currency": {
"name": "Harnaś",
"symbol": "HAR",
"value": 1.0
}
},
{
"amount": 2.0,
"currency": {
"name": "Tyskie",
"symbol": "TYS",
"value": 1.9
}
}
],
"seller_id": "KyumBFaY66ZdS3oG7fPZQZycKyC2",
"title": "Półeczka"
}The offer with a given id was not found.
<Error>
Returns offers matching given query. Page with id 0 is the page with the most fitting offers.
query: query to search for
page: page of the results, 0 is always valid
None
[
<Offer>,
<Offer>,
...
]| Header | Description |
|---|---|
X-Total-Pages |
Total number of pages |
The page number is invalid.
<Error>
Returns offers from given page. Page with id 0 is the newest page and is always valid.
page: page of the results, 0 is always valid
None
[
<Offer>,
<Offer>,
...
]
| Header | Description |
|---|---|
X-Total-Pages |
Total number of pages |
The page id is invalid.
<Error>
Returns offers from given user.
id: id of the user
None
The user with a given id was found.
[
<Offer>,
<Offer>,
...
]
The user id is invalid.
<Error>
Creates new offer.
Needs to be authorized as any user.
{
"seller_id": <string>,
"currency": <string>,
"price": <int>,
"title": <string>,
"description": <string>,
"location": <string>,
"images": <array[<int>]>
}seller_id: unique ID of the seller
currency: symbol of the currency
price: amount of the currency
title: title of the offer
description: description
location: location of the offer (optional) \
images: array of the ids of images
{
"seller_id": "KyumBFaY66ZdS3oG7fPZQZycKyC2",
"currency": "HAR",
"price": 10,
"title": "Test ze zdjęciem",
"description": "Test ze zdjęciem",
"images": [16, 17]
}<Offer>
{
"created_at": "2023-01-08T17:36:48.316588",
"description": "Test ze zdjęciem",
"images": [
{
"image_id": 16,
"original": "http://localhost:8080/images/cb1a6d25-403d-4b96-aef2-29eef9d84c60_original.jpg",
"preview": "http://localhost:8080/images/cb1a6d25-403d-4b96-aef2-29eef9d84c60_preview.jpg",
"thumbnail": "http://localhost:8080/images/cb1a6d25-403d-4b96-aef2-29eef9d84c60_thumbnail.jpg"
},
{
"image_id": 17,
"original": "http://localhost:8080/images/cb1a6d25-403d-4b96-aef2-29eef9d84c60_original.jpg",
"preview": "http://localhost:8080/images/cb1a6d25-403d-4b96-aef2-29eef9d84c60_preview.jpg",
"thumbnail": "http://localhost:8080/images/cb1a6d25-403d-4b96-aef2-29eef9d84c60_thumbnail.jpg"
}
],
"location": null,
"offer_id": 6,
"price": {
"amount": 10,
"currency": {
"name": "Harnaś",
"symbol": "HAR",
"value": 1.0
}
},
"seller": {
"accepted_currencies": [
{
"name": "Harnaś",
"symbol": "HAR"
},
{
"name": "Tyskie",
"symbol": "TYS"
}
],
"name": "Karol",
"uid": "KyumBFaY66ZdS3oG7fPZQZycKyC2"
},
"title": "Test ze zdjęciem"
}Probable causes
- invalid seller id
- invalid currency
- currency not accepted by the seller
- invalid price
- invalid image id
<Error>
Uploads new image.
Needs to be authorized as any user.
Image file in the body of the request as base64 encoded string.
Accepted file types:
- image/jpeg
- image/png
- image/gif
- image/heic, image/heif
<Image>
File type is not supported.
<Error>
Returns user with given id.
id: id of the user
None
The user with a given id was found.
<User>
{
"accepted_currencies": [
{
"name": "Harnaś",
"symbol": "HAR",
"value": 1.0
},
{
"name": "Tyskie",
"symbol": "TYS",
"value": 1.9
}
],
"name": "Karol",
"uid": "KyumBFaY66ZdS3oG7fPZQZycKyC2"
}The user with a given id does not exist.
<Error>
Puts the user with given id. Should be called after the user is created.
id: id of the user
None
The user with a given id was created in the internal database.
<User>
{
"accepted_currencies": [
{
"name": "Harnaś",
"symbol": "HAR",
"value": 1.0
},
{
"name": "Tyskie",
"symbol": "TYS",
"value": 1.9
}
],
"name": "Karol",
"uid": "KyumBFaY66ZdS3oG7fPZQZycKyC2"
}The user with a given id does not exist in the Firebase Auth database.
<Error>
The user with a given id already exists in the internal database.
<Error>
Updates the user with given id.
id: id of the user
Needs to be authorized as the user with given id.
{
"name": <string>,
"currency": [
<string>,
<string>,
...
]
}name: new name of the user (optional)
currency: list of accepted currency symbols (optional)
If the field is not present, it will not be updated.
The currency field, if present, must contain at least one currency symbol.
{
"name": "Karol",
"currency": ["HAR", "TYS"]
}The user with a given id was updated.
<User>
The user with a given id does not exist.
<Error>
At least one of the currencies is invalid.
<Error>
Returns conversations for a given user.
id: id of the user
[
<Message>,
<Message>
]The user id is invalid.
<Error>
Returns conversations between two users.
id1: id of the first user
id2: id of the second user
[
<Message>,
<Message>
]The user id is invalid.
<Error>
Creates and send a new message.
Needs to be authorized as a sender.
{
"sender_id": <string>,
"receiver_id": <string>,
"content": <string>
}sender_id: unique ID of the sender
conversation_id: unique ID of the conversation
content: content of the message
{
"sender_id": "KyumBFaY66ZdS3oG7fPZQZycKyC2",
"receiver_id": "iELOTJC3k6VMCrrtamFq7907REz1",
"content": "Test 12345"
}When the message was created and sent.
<Message>
{
"content": "Hello",
"message_id": 1,
"receiver_id": "iELOTJC3k6VMCrrtamFq7907REz1",
"sender_id": "KyumBFaY66ZdS3oG7fPZQZycKyC2",
"sent_at": "2022-11-09T16:58:44.039167"
}The sender or receiver id is invalid or one of the fields is missing
<Error>
Returns all currencies.
None
[
<Currency>,
<Currency>
][
{
"name": "Harna\u015b",
"symbol": "HAR",
"value": 1.0
}
]Returns health status of the server.
None
The server is healthy.
{
"healthy": true,
"message": null
}The server is unhealthy.
{
"healthy": false,
"message": <string>
}{
"healthy": false,
"message": "Database is not available"
}Or no response at all if the server is down.
- User is created using the appropriate client side Google Firebase Auth method.
- A call to the internal API is made by the client to create an entry in the database by
using the PUT method on the
/user/<id>endpoint.
- Once the user has started uploading images, the client calls the POST method on the
/imageendpoint. - After all the images are successfully uploaded, the client calls the POST method on the
/offerendpoint.