Skip to content
michaelkringelhede edited this page Oct 31, 2021 · 11 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": [
        {
            "position": 1,
            "userid": "cf4ac6ff-c49e-4a12-84b0-0a255fde6e90",
            "name": "Anker Monrad",
            "jids": 5,
            "countries": 3,
            "latest": "2019-10-18T16:35:26+02:00",
            "change": {
                "jids": 3,
                "countries": 1,
                "position": 1
            }
        },
        {
            "position": 2,
            "userid": "50a59d04-c3ce-47ef-8246-3db11f93f05d",
            "name": "Hilmar Kampmann",
            "jids": 3,
            "countries": 2,
            "latest": "2019-10-18T16:37:20+02:00",
            "change": {
                "jids": 1,
                "countries": 1,
                "position": -1
            }
        },
        {
            "position": 3,
            "userid": "4a66ba4a-f03f-4cf9-8bff-724551139e01",
            "name": "Ove Sehested",
            "jids": 2,
            "countries": 1,
            "latest": "2019-10-18T15:15:15+02:00",
            "change": {
                "jids": 0,
                "countries": 0,
                "position": 0
            }
        }
    ],
    "countries": [
        {
            "position": 1,
            "country": "dk",
            "countryName": "Denmark",
            "jids": 4,
            "created": "2019-10-18T16:26:30+02:00",
            "change": {
                "jids": 0,
                "position": 0
            }
        },
        {
            "position": 2,
            "country": "se",
            "countryName": "Sweden",
            "jids": 3,
            "created": "2019-10-18T16:11:21+02:00",
            "change": {
                "jids": 2,
                "position": 1
            }
        },
        {
            "position": 2,
            "country": "no",
            "countryName": "Norway",
            "jids": 1,
            "created": "2019-10-18T16:26:50+02:00",
            "change": {
                "jids": 0,
                "position": -1
            }
        }
    ],
    "totals": {
        "jids": 10,
        "unique": 7,
        "countries": 3,
        "change": {
            "jids": 4,
            "unique": 1,
            "countries": 0
        }
    },
    "error": null,
    "errorCode": null
}

Admins

Admins can be created using the API:

POST /admins
{
	"name": "Zaphod Beeblebrox",
	"email": "[email protected]",
	"password": "Pan-Galactic Gargle Blaster",
	"phone": "+44 1978 1980"
}

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