To run this project Java JDK 1.8 or higher is required.
Checkout the project and create a custom-application.conf
git clone https://github.com/neeedo/neeedo-api.git
cd api
cp conf/custom-application-dummy.conf conf/custom-application.conf
If you want to use your own shop, copy your credentials to your custom-application.conf
.
You can find them in your SPHERE.IO backend account under "Developers -> API Clients"
Note that it's currently mandatory to provide an own SPHERE.IO-shop
###How to run (Windows) Make sure you have sbt intalled on your local maschine
sbt
run -Dhttps.port=9443
###How to run (Unix)
./sbt
run -Dhttps.port=9443
###Access The Live Api is accessable under
https://api.neeedo.com/
If you run the application on your local machine access it under
https://localhost:9443/
- Common Errors
- Status (unsecured)
- Matching
- Tag Suggester
- Messages
- Favorites
- Demands
- Offers
- Users
- Images
Each POST or PUT request sent to this api will respond with these error codes when the body is incorrect:
If you send a json object that can't be parsed and is not as expected you will get:
400 BadRequest
{"error":"Invalid json body"}
If you dont send any json body at all you will get:
400 BadRequest
{"error":"Missing body json object"}
The status will be reported under /status
.
Currently responds 200 OK if application is online.
GET /matching/demand/{from}/{pageSize}
Name | Mandatory | Value Type | Description |
---|---|---|---|
from | Mandatory | Integer | Offset value for paging(not yet implemented just pass a number) |
pageSize | Mandatory | Integer | Page size for paging (not yet implemented just pass a number) |
The request body must contain a valid Demand json object
{
"id":"984730ec-2778-4c5d-ab71-19128c738729",
"version":1,
"user": {
"id":"f8b3dddf-1943-4371-aaa4-2be98fe4ee54",
"name":"neu"
},
"mustTags":["rahmen"],
"shouldTags":[],
"location": {
"lat":52.4907453,
"lon":13.5210239
},
"distance":30,
"price": {
"min":0,
"max":50
}
}
200 Ok
curl -XPOST -H "Content-Type: application/json" -d '{"mustTags":["rahmen"],"shouldTags":[],"location": {"lat":52.4907453,"lon":13.5210239},"distance":30,"price": {"min":0,"max":50},"id":"984730ec-2778-4c5d-ab71-19128c738729","version":1,"user": {"id":"f8b3dddf-1943-4371-aaa4-2be98fe4ee54","name":"neu"}}' https://localhost:9443/matching/demand/0/0 -v
GET /completion/suggest/{phrase}
Name | Mandatory | Value Type |
---|---|---|
phrase | Mandatory | url encoded phrase string ("tag1,tag2,tag3") |
200 Ok
{
"suggestedTags":[
"Rahmen",
"Radkappe"
]
}
GET /completion/tag/{tag}
Name | Mandatory | Value Type |
---|---|---|
tag | Mandatory | url encoded tag string |
200 Ok
{
"completedTags":[
"Rahmen",
"Radkappe"
]
}
POST /messages
The request body must contain a valid message draft json object
{
"senderId":"56530372-aa7f-41d7-b1b0-c09931fdbc08",
"recipientId": "98d40e3e-1c50-43f3-9ba5-58497b417d01",
"body": "hey there"
}
200 Ok
{
"message": {
"id": "509cfcc8-3a1f-450b-a088-fad8cd3d6032",
"sender": {
"id": "56530372-aa7f-41d7-b1b0-c09931fdbc08",
"name": "Test"
},
"recipient": {
"id": "98d40e3e-1c50-43f3-9ba5-58497b417d01",
"name": "Blub"
},
"body": "hey there",
"timestamp": 1434802592926,
"read": false
}
}
GET /messages/{userId1}/{userId2}
Name | Mandatory | Value Type |
---|---|---|
userId1 | Mandatory | alphanumeric |
userId2 | Mandatory | alphanumeric |
200 Ok
{
"messages": [
{
"id": "2bf41679-e3c4-45fb-89df-a1ff6bad4b2d",
"sender": {
"id": "98d40e3e-1c50-43f3-9ba5-58497b417d01",
"name": "Blub"
},
"recipient": {
"id": "3000dfdd-9acf-42c8-9768-f4f6b3fd221d",
"name": "Test"
},
"body": "hey there yourself",
"timestamp": 1434463375027,
"read": false
},
{
"id": "24c5e9ff-eed3-4b15-b6d6-4cee5d8f1616",
"sender": {
"id": "98d40e3e-1c50-43f3-9ba5-58497b417d01",
"name": "Blub"
},
"recipient": {
"id": "3000dfdd-9acf-42c8-9768-f4f6b3fd221d",
"name": "Test"
},
"body": "hey there",
"timestamp": 1434463368196,
"read": false
},
{
"id": "73340fa6-faa9-4c49-8bf7-f9e85ad941a4",
"sender": {
"id": "3000dfdd-9acf-42c8-9768-f4f6b3fd221d",
"name": "Test"
},
"recipient": {
"id": "98d40e3e-1c50-43f3-9ba5-58497b417d01",
"name": "Blub"
},
"body": "hey there",
"timestamp": 1434463349075,
"read": false
}
]
}
PUT /messages/{messageId}
Name | Mandatory | Value Type |
---|---|---|
messageId | Mandatory | alphanumeric |
{
"messageId": "73340fa6-faa9-4c49-8bf7-f9e85ad941a4"
}
Get all userIds that have a dialogue with a specific user with unread/read messages
GET /conversations/{userId}?read={read}
Name | Mandatory | Value Type |
---|---|---|
userId | Mandatory | alphanumeric |
read | Mandatory | boolean |
{
"users": [
{
"id": "98d40e3e-1c50-43f3-9ba5-58497b417d01",
"name": "Blub"
}
]
}
POST /favorites
The request body must contain a valid Favorite json object
{
"userId":"09d31dae-51b1-45e5-a343-56a3462e4053",
"offerId": "9dfa3c90-85c8-46ce-b50c-3ecde596bc90"
}
201 Created
{
"userId":"09d31dae-51b1-45e5-a343-56a3462e4053",
"offerId": "9dfa3c90-85c8-46ce-b50c-3ecde596bc90"
}
GET /favorites/{userId}
Name | Mandatory | Value Type |
---|---|---|
userId | Mandatory | alphanumeric |
200 Ok
"favorites": [
{
"id":"9dfa3c90-85c8-46ce-b50c-3ecde596bc90",
"version": 1,
"user": {
"id":"09d31dae-51b1-45e5-a343-56a3462e4053",
"name":"Stefan"
},
"tags":["socken", "bekleidung", "wolle"],
"location":{
"lat":13.534212,
"lon":52.468562
},
"price":25.0
},
...
]
DELETE /favorites/:userId/:offerId
Name | Mandatory | Value Type |
---|---|---|
userId | Mandatory | alphanumeric |
offerId | Mandatory | alphanumeric |
200 Ok
{
"userId":"09d31dae-51b1-45e5-a343-56a3462e4053",
"offerId": "9dfa3c90-85c8-46ce-b50c-3ecde596bc90"
}
GET /demands/{id}
Name | Mandatory | Value Type |
---|---|---|
id | Mandatory | alphanumeric |
200 Ok
{
"demand":{
"id":"9dfa3c90-85c8-46ce-b50c-3ecde596bc90",
"version": 1,
"user" : {
"id":"1",
"name":"Stefan"
},
"mustTags":["socken", "bekleidung", "wolle"],
"shouldTags":["rot", "weich", "warm"],
"location":{
"lat":13.534212,
"lon":52.468562
},
"distance":30,
"price":{
"min":25.0,
"max":77.0
}
}
}
404 - Not Found
GET /demands/users/{userId}
Name | Mandatory | Value Type |
---|---|---|
userId | Mandatory | alphanumeric |
200 Ok
{
"demands": [
{...},
{...}
]
}
GET /demands
200 Ok
{
"demands": [
{...},
{...}
]
}
POST /demands
The request body must contain a valid DemandDraft json object
{
"userId":"1",
"mustTags":["socken", "bekleidung", "wolle"],
"shouldTags":["rot", "weich", "warm"],
"location":{
"lat":13.534212,
"lon":52.468562
},
"distance":30,
"price":{
"min":25.0,
"max":77.0
}
}
201 Created
{
"demand": {
"id": "9dfa3c90-85c8-46ce-b50c-3ecde596bc90",
"version": 1,
"user" : {
"id": "1",
"name": "Stefan"
},
"mustTags":["socken", "bekleidung", "wolle"],
"shouldTags":["rot", "weich", "warm"],
"location": {
"lat":13.534212,
"lon":52.468562
},
"distance": 30,
"price": {
"min":25.0,
"max":77.0
}
}
}
400 Bad Request - Empty Body
400 Bad Request - Invalid Json
curl -XPOST -H "Content-Type: application/json" -d '{"userId":"1","mustTags":["socken","bekleidung","wolle"],"shouldTags":["rot","weich","warm"],"location":{"lat":13.534212,"lon":52.468562},"distance":30,"price":{"min":25.0,"max":77.0}}' https://localhost:9443/demands -v
PUT /demands/{id}/{version}
Name | Mandatory | Value Type |
---|---|---|
id | Mandatory | alphanumeric |
version | Mandatory | numeric |
The request body must contain a valid DemandDraft json object
{
"userId":"1",
"mustTags":["socken", "bekleidung", "wolle"],
"shouldTags":["rot", "weich", "warm"],
"location":{
"lat":13.534212,
"lon":52.468562
},
"distance":30,
"price":{
"min":25.0,
"max":77.0
}
}
200 Ok
{
"demand": {
"id": "9dfa3c90-85c8-46ce-b50c-3ecde596bc90",
"version": 2,
"user": {
"id": "1",
"name": "1"
},
"mustTags":["socken", "bekleidung", "wolle"],
"shouldTags":["rot", "weich", "warm"],
"location": {
"lat":13.534212,
"lon":52.468562
},
"distance": 30,
"price": {
"min":25.0,
"max":77.0
}
}
}
400 Bad Request - Missing body
400 Bad Request - Cannot parse json
404 Not Found - Entity was not found
curl -XPUT -H "Content-Type: application/json" -d '{"userId":"1","mustTags":["socken","bekleidung","wolle"], "shouldTags":["rot","weich","warm"],"location":{"lat":13.534212,"lon":52.468562},"distance":30,"price":{"min":25.0,"max":77.0}}' https://localhost:9443/demands/1/1 -v
DELETE /demands/{id}/{version}
Name | Mandatory | Value Type |
---|---|---|
id | Mandatory | alphanumeric |
version | Mandatory | numeric |
200 Ok
404 Not Found - Entity was not found
curl -XDELETE https://localhost:9443/demands/9dfa3c90-85c8-46ce-b50c-3ecde596bc90/2 -v
GET /offers/{id}
Name | Mandatory | Value Type |
---|---|---|
id | Mandatory | alphanumeric |
###Response 200 Ok
{
"offer":{
"id":"9dfa3c90-85c8-46ce-b50c-3ecde596bc90",
"version": 1,
"user": {
"id":"1",
"name":"Stefan"
},
"tags":["socken", "bekleidung", "wolle"],
"location":{
"lat":13.534212,
"lon":52.468562
},
"price":25.0
}
}
404 - Not Found
GET /offers/users/{userId}
Name | Mandatory | Value Type |
---|---|---|
userId | Mandatory | alphanumeric |
200 Ok
{
"offers": [
{...},
{...}
]
}
GET /offers
200 Ok
{
"offers": [
{...},
{...}
]
}
POST /offers
The request body must contain a valid OfferDraft json object
{
"userId":"1",
"tags":["socken", "bekleidung", "wolle"],
"location":{
"lat":13.534212,
"lon":52.468562
},
"price":25.0,
"images":["test.jpg", "blub.jpg"]
}
The images array can be empty. If you add imagenames make sure that you have uploaded the pictures and use the correct name that is returned by the api.
201 Created
{
"offer": {
"id": "9dfa3c90-85c8-46ce-b50c-3ecde596bc90",
"version": 1,
"user": {
"id": "1",
"name": "Stefan",
},
"tags":["socken", "bekleidung", "wolle"],
"location": {
"lat":13.534212,
"lon":52.468562
},
"price":25.0
}
}
400 Bad Request - Empty Body
400 Bad Request - Invalid Json
curl -XPOST -H "Content-Type: application/json" -d '{"userId":"1","tags":["socken","bekleidung","wolle"],"location":{"lat":13.534212,"lon":52.468562},"price":25.0}' https://localhost:9443/offers -v
PUT /offers/{id}/{version}
Name | Mandatory | Value Type |
---|---|---|
id | Mandatory | alphanumeric |
version | Mandatory | numeric |
The request body must contain a valid OfferDraft json object
{
"userId":"1",
"tags":["socken", "bekleidung", "wolle"],
"location":{
"lat":13.534212,
"lon":52.468562
},
"price":25.0
}
200 Ok
{
"offer": {
"id": "9dfa3c90-85c8-46ce-b50c-3ecde596bc90",
"version": 2,
"user": {
"id": "1",
"name": "1",
},
"tags":["socken", "bekleidung", "wolle"],
"location": {
"lat":13.534212,
"lon":52.468562
},
"price":25.0
}
}
400 Bad Request - Missing body
400 Bad Request - Cannot parse json
404 Not Found - Entity was not found
curl -XPUT -H "Content-Type: application/json" -d '{"userId":"1","tags":["socken","bekleidung","wolle"],"location":{"lat":13.534212,"lon":52.468562},"price":25.0}' https://localhost:9443/offers/1/1 -v
DELETE /offers/{id}/{version}
Name | Mandatory | Value Type |
---|---|---|
id | Mandatory | alphanumeric |
version | Mandatory | numeric |
200 Ok
404 Not Found - Entity was not found
curl -XDELETE https://localhost:9443/offers/9dfa3c90-85c8-46ce-b50c-3ecde596bc90/2 -v
GET /users/mail/{mail}
Name | Mandatory | Value Type |
---|---|---|
Mandatory | alphanumeric |
###Response 200 Ok
{
"user":{
"id":"9dfa3c90-85c8-46ce-b50c-3ecde596bc90",
"version": 1,
"name":"test",
"email":"[email protected]"
}
}
404 - Not Found
POST /users
The request body must contain a valid UserDraft json object
{
"name":"Test",
"email":"[email protected]",
"password":"12345"
}
201 Created
{
"user": {
"id": "9dfa3c90-85c8-46ce-b50c-3ecde596bc90",
"version": 1,
"name":"Test",
"email":"[email protected]"
}
}
400 Bad Request
{
"error" : "A user with this email address already exists"
}
curl -XPOST -H "Content-Type: application/json" -d '{"username":"Test", "email":"[email protected]", "password":"test"}' https://localhost:9443/users -v
DELETE /usersd/{id}/{version}
Name | Mandatory | Value Type |
---|---|---|
id | Mandatory | alphanumeric |
version | Mandatory | numeric |
200 Ok
404 Not Found - Entity was not found
curl -XDELETE https://localhost:9443/users/9dfa3c90-85c8-46ce-b50c-3ecde596bc90/2 -v
POST /images
The image must be sent in the body multipart/form-data encoded.
201 Created
{
"image" : "10e5b696-2e21-488e-9857-29d94da95ee3.jpg"
}
GET /images/{filename}
Name | Mandatory | Value Type |
---|---|---|
filename | Mandatory | example.jpg |
Response of the action is a chunked http stream that returns the image with the correct mimetype. This means you can use these url's as source in img tags for example.