Quickstart
Create API token
User must be the owner of the lock or been added as admin of it.
curl -X POST -d '{"email":"admin@example.com", "device_id":"api-token123", "device_desc":"API key for integration 1" }' https://api.nearkey.io/login
Note
You can put anything on "device_desc"
but make sure "device_id"
starts with api-
Will return a JSON with the API token:
{
"result": {
"token": "xxxxxxxxxxxxxxxxxx"
}
}
Now you must press the button on the received email to validate this token.
Check the “Settings” section on the app or admin web (https://admin.nearkey.io) to see this token.
List locks
To list all locks this user can manage:
curl -X GET -H "Authorization: TOKEN xxxxxxxxxxxxxxxxxx" https://api.nearkey.io/locks?summary=true
Note
You can remove ?summary=true
from the URL to get full data (query will be slower)
List keys on a lock
To list all keys for a lock with id ABC123:
curl -X GET -H "Authorization: TOKEN xxxxxxxxxxxxxxxxxx" https://api.nearkey.io/locks/ABC123/acl
Warning
Lock id must be URL encoded
Note
You can remove ?summary=true
from the URL to get full data (query will be slower)
Create/modify keys
To create (or modify) a key for a user on lock ABC123:
curl -X POST -H "Authorization: TOKEN xxxxxxxxxxxxxxxxxx" -d '{"email":"user@example.com", "name":"User Name", "permissions":["a0"], "start":"2020-01-01T04:05:06", "end":"2031-01-01T04:05:06"}' https://api.nearkey.io/locks/ABC123/acl
Warning
Lock id must be URL encoded
Delete key
To delete a key for user@example.com on lock ABC123:
curl -X DELETE -H "Authorization: TOKEN xxxxxxxxxxxxxxxxxx" https://api.nearkey.io/locks/ABC123/acl/user%40example.com
Warning
Lock id & email must be URL encoded