API usage examples - PabloGallazzi/java-spring GitHub Wiki
Here are some curls you can use to test this API (assuming you are running this at port 8080):
Requests that doesn't need privileges:
- This curl is to test the connectivity to marvel's api (no authentication needed):
curl -vX GET 'http://localhost:8080/characters?limit=50&offset=0&name_starts_with=iron&sort=name&criteria=desc'
- To create a user:
curl -vX POST 'http://localhost:8080/users' -d '{"user_name":"Pablito","user_password":"Pablito123;"}' -H 'content-type:application/json'
- To get an access_token for a user:
curl -vX POST 'http://localhost:8080/users/authenticate' -d '{"user_name":"Pablito","user_password":"Pablito123;"}' -H 'content-type:application/json'
Requests that need user level privileges:
- Manage teams:
curl -vX POST 'http://localhost:8080/users/1/teams?access_token=TOKEN_DEL_USER' -d '{"team_name":"TACS UTN","members":[{"id":1, "name":"Pablito"}]}' -H 'content-type:application/json'
curl -vX POST 'http://localhost:8080/users/1/teams/1/characters?access_token=TOKEN_DEL_USER' -d '{"id":1,"name":"nombre"}' -H 'content-type:application/json'
curl -vX DELETE 'http://localhost:8080/users/1/teams/1/characters/1?access_token=TOKEN_DEL_USER'
curl -vX GET 'http://localhost:8080/users/1/teams/1?access_token=TOKEN_DEL_USER'
- Manage favorites:
curl -vX POST 'http://localhost:8080/users/1/characters/favorites?access_token=TOKEN_DEL_USER' -d '{"id":1}' -H 'content-type:application/json'
curl -vX DELETE 'http://localhost:8080/users/1/characters/favorites/1?access_token=TOKEN_DEL_USER'
curl -vX GET 'http://localhost:8080/users/1/characters/favorites?access_token=TOKEN_DEL_USER'
curl -vX GET 'http://localhost:8080/users/1/characters/favorites/123?access_token=TOKEN_DEL_USER'
Requests that need admin level privileges:
- To get all the info from a user:
curl -vX GET 'http://localhost:8080/users/1?access_token=TOKEN_DE_ADMIN'
- To get the intersection of teams:
curl -vX GET 'http://localhost:8080/teams/commons/2/1?access_token=TOKEN_DE_ADMIN'
- To get the ranking of favorites:
curl -vX GET 'http://localhost:8080/characters/ranking?access_token=TOKEN_DE_ADMIN&limit=1'