Abuse Registration API Example
This API uses JWT for authentication and authorization. Data is stored in memory.
Terminal workflows
These examples are terminal only. You can translate it to postman if you want to.
Linux / curl
Reader user — filtered reads
READER_TOKEN=$(curl -s -X POST http://localhost:8080/login \
-H 'Content-Type: application/json' \
-d '{"user_name":"reader","password":"reader-password"}' \
| sed -n 's/.*"token":"\([^"]*\)".*/\1/p')
curl -s 'http://localhost:8080/api/v1/registrations?location=Tórshavn&limit=5' \
-H "Authorization: $READER_TOKEN"
curl -s 'http://localhost:8080/api/v1/registrations?gender=female&abuse_type=psychological&status=open&limit=10' \
-H "Authorization: $READER_TOKEN"
curl -s 'http://localhost:8080/api/v1/registrations?from=1989-01-01&to=1990-01-01&offset=20&limit=10' \
-H "Authorization: $READER_TOKEN"
curl -s 'http://localhost:8080/api/v1/locations' \
-H "Authorization: $READER_TOKEN"
CRUD user — create, update, delete
ADMIN_TOKEN=$(curl -s -X POST http://localhost:8080/login \
-H 'Content-Type: application/json' \
-d '{"user_name":"admin","password":"admin-password"}' \
| sed -n 's/.*"token":"\([^"]*\)".*/\1/p')
CREATED_ID=$(curl -s -X POST http://localhost:8080/api/v1/registrations \
-H "Authorization: $ADMIN_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"gender":"unknown","location":"Tórshavn","abuse_type":"psychological","status":"new"}' \
| sed -n 's/.*"id":"\([^"]*\)".*/\1/p')
curl -s -X PUT "http://localhost:8080/api/v1/registrations/$CREATED_ID" \
-H "Authorization: $ADMIN_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"gender":"female","location":"Skopun","abuse_type":"digital","status":"referred"}'
curl -s -X DELETE "http://localhost:8080/api/v1/registrations/$CREATED_ID" \
-H "Authorization: $ADMIN_TOKEN"
Windows / PowerShell
Reader user — filtered reads
$reader = Invoke-RestMethod `
-Method Post `
-Uri "http://localhost:8080/login" `
-ContentType "application/json" `
-Body '{"user_name":"reader","password":"reader-password"}'
$READER_TOKEN = $reader.token
Invoke-RestMethod `
-Uri "http://localhost:8080/api/v1/registrations?location=Tórshavn&limit=5" `
-Headers @{Authorization=$READER_TOKEN}
Invoke-RestMethod `
-Uri "http://localhost:8080/api/v1/registrations?gender=female&abuse_type=psychological&status=open&limit=10" `
-Headers @{Authorization=$READER_TOKEN}
Invoke-RestMethod `
-Uri "http://localhost:8080/api/v1/registrations?from=1989-01-01&to=1990-01-01&offset=20&limit=10" `
-Headers @{Authorization=$READER_TOKEN}
Invoke-RestMethod `
-Uri "http://localhost:8080/api/v1/locations" `
-Headers @{Authorization=$READER_TOKEN}
CRUD user — create, update, delete
$admin = Invoke-RestMethod `
-Method Post `
-Uri "http://localhost:8080/login" `
-ContentType "application/json" `
-Body '{"user_name":"admin","password":"admin-password"}'
$ADMIN_TOKEN = $admin.token
$created = Invoke-RestMethod `
-Method Post `
-Uri "http://localhost:8080/api/v1/registrations" `
-Headers @{Authorization=$ADMIN_TOKEN} `
-ContentType "application/json" `
-Body '{"gender":"unknown","location":"Tórshavn","abuse_type":"psychological","status":"new"}'
$CREATED_ID = $created.id
Invoke-RestMethod `
-Method Put `
-Uri "http://localhost:8080/api/v1/registrations/$CREATED_ID" `
-Headers @{Authorization=$ADMIN_TOKEN} `
-ContentType "application/json" `
-Body '{"gender":"female","location":"Skopun","abuse_type":"digital","status":"referred"}'
Invoke-RestMethod `
-Method Delete `
-Uri "http://localhost:8080/api/v1/registrations/$CREATED_ID" `
-Headers @{Authorization=$ADMIN_TOKEN}
Current JSON data
This viewer loads a public demo snapshot. The actual API routes under /api/v1 still require a JWT.
Loading data…
[]