User Tools

Site Tools


v0.3

ChastiKey API (v0.3)

ChastiKey API URL ID’s & Parameters

Version 0.3 of the ChastiKey API has the following two URLs available:

https://api.chastikey.com/v0.3/listlocks.php
https://api.chastikey.com/v0.3/checklock.php

listlocks.php

This script returns a list of locks that are active for a specific user id or username. The following parameter is required:

userid or username
https://api.chastikey.com/v0.3/listlocks.php?userid=xxxxx-xxxxx-xxxxx-xxxxx
https://api.chastikey.com/v0.3/listlocks.php?username=xxxxxxxxxx

The user id can be found from within the app. The user id contains 4 sets of 5 random letters and numbers, each set separated by a hyphen i.e.: A1B2C-3D4E5-F6G7H-8I9J0

The username can be found from within the app. It will be on the profile screen. If you haven't set a username it will be a default CKUXXXX one.

Here’s an example of the data returned in JSON

{
    "response" : [
        {
            "status" : 200, 
            "message" : "Success", 
            "timestampGenerated" : 1541539882
        }
    ], 
    "locks" : [
        {
            "lockID" : 1537997743, 
            "lockedBy" : "Zoe",
            "lockFrozen" : 0,
            "timestampLocked" : 1537997743, 
            "timestampUnlocked" : 0, 
            "status" : "Locked",
            "combination" : ""
        }, 
        {
            "lockID" : 1539201053, 
            "lockedBy" : "",
            "lockFrozen" : 0,
            "timestampLocked" : 1539201053, 
            "timestampUnlocked" : 1539287453, 
            "status" : "UnlockedFake",
            "combination" : "48238191"
        }, 
        {
            "lockID" : 1539201053, 
            "lockedBy" : "",
            "lockFrozen" : 0,
            "timestampLocked" : 1539201053, 
            "timestampUnlocked" : 1539287453, 
            "status" : "UnlockedReal",
            "combination" : "22029321"
        }
    ]
}

response – status & message See status codes returned below.

response – timestampGenerated This shows the time the JSON data was generated.

locks – combination This shows the combination attached to the lock, but only if the lock status (see below) is flagged as UnlockedReal or UnlockedFake. Will return blank if not yet unlocked.

locks – lockID This shows the lock IDs that you will also see at the top right of each lock in the app. You may notice that some locks in the list share the same ID, this happens when a lock was created with a number of fake locks. To hide which one is the real one and which are the fakes they all share the same ID.

locks – lockedBy This shows the username of the keyholder if the lock is controlled by a keyholder or bot. If not it will be blank.

locks – lockFrozen This shows the whether or not the lock is frozen. Will return 1 if frozen, and 0 if not frozen.

locks – status This returns one of 4 values, Locked, ReadyToUnlock, UnlockedReal, UnlockedFake. The real and fake unlocked values show whether or not it was a real or fake lock that unlocked.

locks – timestampLocked This returns the timestamp when the lock was first locked.

locks – timestampUnlocked This returns the timestamp when the lock was unlocked. Will return 0 if not yet unlocked.

checklock.php

This script returns the status of a particular lock, or set of locks based on a single lock ID. The following parameters are required:

userid or username
lockid
https://api.chastikey.com/v0.3/checklock.php?userid=xxxxx-xxxxx-xxxxx-xxxxx&lockid=xxx
https://api.chastikey.com/v0.3/checklock.php?username=xxxxxxxxxx&lockid=xxx

The user id can be found from within the app. The user id contains 4 sets of 5 random letters and numbers, each set separated by a hyphen i.e.: A1B2C-3D4E5-F6G7H-8I9J0

The username can be found from within the app. It will be on the profile screen. If you haven't set a username it will be a default CKUXXXX one.

The lock id can be found at the top right of each lock in the list of locks shown in the app. As mentioned above if the lock was created with fake copies then all locks from that set will share the same lock id and all of them will be returned in the JSON data from this script.

Here’s an example of the data returned in JSON

{
    "response" : [
        {
            "status" : 200, 
            "message" : "Success", 
            "timestampGenerated" : 1541541818
        }
    ], 
    "locks" : [
        {
            "lockID" : 1537997743, 
            "lockedBy", "Zoe",
            "lockFrozen", 0,
            "timestampLocked" : 1537997743, 
            "timestampUnlocked" : 0, 
            "status" : "Locked",
            "combination" : ""
        }
    ]
}

response – status & message See status codes returned below.

response – timestampGenerated This shows the time the JSON data was generated.

locks – combination This shows the combination attached to the lock, but only if the lock status (see below) is flagged as UnlockedReal or UnlockedFake. Will return blank if not yet unlocked.

locks – lockID This shows the lock IDs that you will also see at the top right of each lock in the app. You may notice that some locks in the list share the same ID, this happens when a lock was created with a number of fake locks. To hide which one is the real one and which are the fakes they all share the same ID.

locks – lockedBy This shows the username of the keyholder if the lock is controlled by a keyholder or bot. If not it will be blank.

locks – lockFrozen This shows the whether or not the lock is frozen. Will return 1 if frozen, and 0 if not frozen.

locks – status This returns one of 3 values, Locked, ReadyToUnlock, UnlockedReal, UnlockedFake. The real and fake unlocked values show whether or not it was a real or fake lock that unlocked.

locks – timestampLocked This returns the timestamp when the lock was first locked.

locks – timestampUnlocked This returns the timestamp when the lock was unlocked. Will return 0 if not yet unlocked.

Status Codes

ChastiKey API uses the following response status codes:

200 – Success, the request succeeded.
204 – No content, the request succeeded but there was no data to return.
400 – Bad Request. This might be an invalid, unrecognised or missing parameter. The message variable will contain more information.

Rate Limiting / Cache

The data returned is cached for 60 seconds to reduce the amount of database requests. If your program polls for the lock status more frequently than 60 seconds it will sometimes return cached data.

v0.3.txt · Last modified: 2019/02/12 20:09 by kevincross