Skip to content
Michael Kringelhede edited this page May 18, 2020 · 6 revisions

The jid-server API has 4 endpoints for now:

Fetch stats

Fetching stats from the jid-server requires no login and takes no parameters:

GET /stats

The response will be similar to:

{
    "users": [
        {
            "name": "Anker Monrad",
            "jids": 5,
            "countries": 3
        },
        {
            "name": "Hilmar Kampmann",
            "jids": 3,
            "countries": 2
        },
        {
            "name": "Ove Sehested",
            "jids": 2,
            "countries": 1
        }
    ],
    "countries": [
        {
            "country": "dk",
            "countryName": "Denmark",
            "jids": 4,
            "created": "2019-10-18T16:26:30+02:00"
        },
        {
            "country": "se",
            "countryName": "Sweden",
            "jids": 3,
            "created": "2019-10-18T16:11:21+02:00"
        },
        {
            "country": "no",
            "countryName": "Norway",
            "jids": 1,
            "created": "2019-10-18T16:26:50+02:00"
        }
    ],
    "totals": {
        "jids": 10,
        "unique": 7,
        "countries": 3
    },
    "error": null,
    "errorCode": null
}

Users

Users can be created using the API:

POST /createUser
{
	"name": "Arthur Dent",
	"username": "adent",
	"password": "THGTTG-42"
}

Response will be similar to:

{
    "id": "13b579ee-fcb8-409b-83f3-e1ce96935276",
    "created": true,
    "token": "eyJhbGciOiJ...zdOUex7uEFQjf-Kw",
    "error": null,
    "errorCode": null
}

Once the user is create you can use the token returned from createUser or you can fetch a new token like this:

POST /login
{
	"username": "adent",
	"password": "THGTTG-42"
}

Response will be similar to:

{
    "successful": true,
    "token": "eyJhbGciOiJ...zdOUex7uEFQjf-Kw",
    "errorCode": null,
    "error": null
}

Send JID code

Users can send JID codes to the server by using the jid endpoint. The login token should be sent as value to the authorization header.

POST /jid
Authorization: eyJhbGciOiJ...zdOUex7uEFQjf-Kw
{
    "jid": "5dk17j"
}

Response will be similar to:

{
    "saved": true,
    "code": {
        "userid": "13b579ee-fcb8-409b-83f3-e1ce96935276",
        "jid": "5dk17j",
        "country": "dk",
        "created": "2019-10-18T16:26:50+02:00"
    },
    "errorCode": null,
    "error": null
}
Clone this wiki locally