This part describes the working of the Symfony API available in /symfony
of this Github repository.
This API communicates with the Neo4j database. The following pattern is always returned.
With this Symfony API, you would be able to design your own application.
The API requires an API key to secure the access to it. Well, by default, the API key is a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
. You need to add it inside the header request with the key name x-api-key
.
Modify the API key under /symfony/src/ApiBundle/Controller/DefaultController.php
.
If you want to check is reachable, that you provided the right API key and that the connection with the database is successful, use the following route.
Endpoint | Method |
---|---|
/api |
GET |
In case of a success, you'll get the following answer :
{
"error": false,
"message": "Everything works.",
"details": []
}
The first time the user connects, he will have to choose the genres he likes. So we will be able to provide the user a first list of musics he's prone to like. This route is especially useful with the following route just below.
Endpoint | Method |
---|---|
/api/genres |
GET |
{
"error": false,
"message": "",
"details": [
{
"id": (int),
"name": (string)
},
{
"id": (int),
"name": (string)
},
[...]
]
}
ℹ️ Cypher command :
MATCH (g:Genre) RETURN g
Endpoint | Method |
---|---|
/api/user/genres |
POST |
Parameters to send :
user_id |
---|
(int) |
{
"error": false,
"message": "",
"details": [
{
"id": (int),
"name": (string)
},
{
"id": (int),
"name": (string)
},
[...]
]
}
ℹ️ Cypher command :
MATCH (u:User) WHERE ID(u)={user_id}
MATCH (u)-[:LIKES]->(g:Genre)
RETURN g
Endpoint | Method |
---|---|
/api/user/genres/add |
POST |
Parameters to send :
user_id | genre_id |
---|---|
(int) | (int) |
The genre set that the user likes is returned.
{
"error": false,
"message": "",
"details": [
{
"id": (int),
"name": (string)
}
]
}
ℹ️ Cypher command :
MATCH (g:Genre) WHERE ID(g)={genre_id}
MATCH (u:User) WHERE ID(u)={user_id}
MERGE (u)-[:LIKES]->(g)
Endpoint | Method |
---|---|
/api/user |
POST |
Parameters to send :
user_id |
---|
(int) |
{
"error": false,
"message": "",
"details": [
{
"id": (int),
"username": (string),
"email": (string)
}
]
}
Endpoint | Method |
---|---|
/api/users |
GET |
{
"error": false,
"message": "",
"details": [
{
"id": (int),
"username": (string),
"email": (string)
},
{
"id": (int),
"username": (string),
"email": (string)
},
[...]
]
}
ℹ️ Cypher command :
MATCH (u:User) RETURN u
Endpoint | Method |
---|---|
/api/user/create |
POST |
Parameters to send :
username | password | |
---|---|---|
(string) | (string) | (string) |
{
"error": false,
"message": "",
"details": [
{
"id": (int),
"username": (string),
"email": (string)
}
]
}
ℹ️ The clear password will be processed by Symfony to create a true secure password inside Neo4j.
Endpoint | Method |
---|---|
/api/user/auth |
POST |
Parameters to send :
username | password |
---|---|
(string) | (string) |
{
"error": false,
"message": "",
"details": [
{
"id": (int),
"username": (string),
"email": (string)
}
]
}
ℹ️ The clear password will be processed by Symfony to create a true secure password inside Neo4j.
Endpoint | Method |
---|---|
/api/artist |
POST |
Parameters to send :
artist_id |
---|
(string) |
{
"error": false,
"message": "",
"details": [
{
"artist_id": (string),
"name": (string)
}
]
}
ℹ️ Cypher command :
MATCH (a:Artist {artist_id: {artist_id}}) RETURN a
Endpoint | Method |
---|---|
/api/artist/genres |
POST |
Parameters to send :
artist_id |
---|
(string) |
{
"error": false,
"message": "",
"details": [
{
"id": (int),
"name": (string)
},
{
"id": (int),
"name": (string)
},
{
"id": (int),
"name": (string)
},
[...]
]
}
ℹ️ Cypher command :
MATCH (a:Artist {artist_id: {artist_id}})-[:HAS_GENRE]->(g:Genre) RETURN g
Endpoint | Method |
---|---|
/api/artist/musics |
POST |
Parameters to send :
artist_id |
---|
(string) |
{
"error": false,
"message": "",
"details": [
{
"id": (int),
"title": (string),
"duration": (float)
},
{
"id": (int),
"title": (string),
"duration": (float)
},
{
"id": (int),
"title": (string),
"duration": (float)
}
[...]
]
}
ℹ️ duration
in second.
ℹ️ Cypher command :
MATCH (a:Artist {artist_id: {artist_id}})-[:OWNS]->(m:Music) RETURN m
Endpoint | Method |
---|---|
/api/artist/albums |
POST |
Parameters to send :
artist_id |
---|
(string) |
{
"error": false,
"message": "",
"details": [
{
"id": (int),
"name": (string),
},
{
"id": (int),
"name": (string)
}
[...]
]
}
ℹ️ Cypher command :
MATCH (a:Artist {artist_id: {artist_id}})-[:CREATED]->(al:Album) RETURN al
Endpoint | Method |
---|---|
/api/music |
POST |
Parameters to send :
music_id |
---|
(int) |
Is returned the title of the music, its duration, id, release date and the number of time the music has been played.
{
"error": false,
"message": "",
"details": [
{
"id": (int),
"title": (string),
"duration": (float),
"released_in": (int),
"count": (int)
}
]
}
ℹ️ Cypher command :
MATCH (m:Music) WHERE ID(m)={music_id}
MATCH (m)-[:RELEASED_IN]->(y:Year)
MATCH (:User)-[li:LISTENED]->(m)
RETURN m,y,li.count
Endpoint | Method |
---|---|
/api/music/album |
POST |
Parameters to send :
music_id |
---|
(int) |
{
"error": false,
"message": "",
"details": [
{
"id": (int),
"name": (string),
}
]
}
ℹ️ Cypher command :
MATCH (m:Music) WHERE ID(m)={music_id}
MATCH (m)-[:IN]->(al:Album) RETURN m
Endpoint | Method |
---|---|
/api/music/genres |
POST |
Parameters to send :
music_id |
---|
(string) |
{
"error": false,
"message": "",
"details": [
{
"id": (int),
"name": (string)
},
{
"id": (int),
"name": (string)
},
{
"id": (int),
"name": (string)
}
[...]
]
}
ℹ️ Cypher command :
MATCH (m:Music) WHERE ID(m)={music_id}
MATCH (m)-[:HAS_GENRE]->(g:Genre) RETURN g
Endpoint | Method |
---|---|
/api/user/music/like |
POST |
Parameters to send :
user_id | music_id |
---|---|
(int) | (string) |
Returns the music liked.
{
"error": false,
"message": "",
"details": [
{
"id": (int),
"title": (string),
"duration": (float)
}
]
}
Endpoint | Method |
---|---|
/api/user/music/dislike |
POST |
Parameters to send :
user_id | music_id |
---|---|
(int) | (string) |
Returns the music disliked.
{
"error": false,
"message": "",
"details": [
{
"id": (int),
"title": (string),
"duration": (float)
}
]
}
Endpoint | Method |
---|---|
/api/user/music/similars |
POST |
Parameters to send :
user_id | limit |
---|---|
(int) | (int) |
{
"error": false,
"message": "",
"details": [
{
"id": (int),
"title": (string),
"duration": (float)
},
{
"id": (int),
"title": (string),
"duration": (float)
},
{
"id": (int),
"title": (string),
"duration": (float)
}
[...]
]
}
Endpoint | Method |
---|---|
/api/user/music/similars/genre |
POST |
Parameters to send :
user_id | genre_id | limit |
---|---|---|
(int) | (int) | (int) |
{
"error": false,
"message": "",
"details": [
{
"id": (int),
"title": (string),
"duration": (float)
},
{
"id": (int),
"title": (string),
"duration": (float)
},
{
"id": (int),
"title": (string),
"duration": (float)
}
[...]
]
}
Endpoint | Method |
---|---|
/api/user/music/listened |
POST |
Parameters to send :
user_id | music_id |
---|---|
(int) | (string) |
{
"error": false,
"message": "",
"details": [
{
"id": (int),
"title": (string),
"duration": (float),
"count": (int)
}
]
}
This way, the user can have himself if there are other users who have the same musical tastes as him.
Endpoint | Method |
---|---|
/api/user/similars |
POST |
Parameters to send :
user_id |
---|
(int) |
{
"error": false,
"message": "",
"details": [
{
"id": (int),
"username": (string),
"email": (string)
},
{
"id": (int),
"username": (string),
"email": (string)
}
[...]
]
}
Endpoint | Method |
---|---|
/api/artist/similars |
POST |
Parameters to send :
artist_id |
---|
(string) |
{
"error": false,
"message": "",
"details": [
{
"id": (int),
"name": (string)
},
{
"id": (int),
"name": (string)
}
[...]
]
}