Main API v3.1

General

The Main API functions are intended to be used by clubs and organizations to manage their administrative work and information services.

An API authorization key is required prior to accessing the API methods. Club/organization administrators can create their own API keys by selecting ADMIN > System settings > Authorization > API access in the meny after logging in.

The Main API has been built up during a number of years, step by step. Because of this, the structure is not optimal. This has been corrected in version 4.

API Call Address

API v3.1 is accessed via https://api.myweblog.se/api_main.php

Active version(s)

Current version is API v4

API v3.1 is still operational but no longer supported.

API Methods

All methods are called via HEADER and POST (form) data. Method selection is made by using any of the method names below as qtype header.

A valid administrator account is required. Username and API key are submitted as headers username and authtoken respectively.

To summarize, all calls must include (in addition to method specific inputs) the mandatory HEADERS below.

Header Format Mandatory Comment
qtype string Y
username string Y
authtoken string Y

get_user_list

This method returns a simple user list ordered by surname (ASC), first name (ASC).

Token module access requirement
Users (read)
Output Format Comment
username string
fornamn string First name
efternamn string Surname

getExtendedUserList

Like get_user_list but with more extensive information.

Token module access requirement
Users (read)
Output Format Comment
User data including name(s), email, phone etc.

get_invalidemail_list

This method returns a list of users with an invalid email address.

Token module access requirement
Users (read)
Output Format Comment
fornamn string First name
efternamn string Surname
email_invalid_reason string Invalid reason

insert_user

The method inserts a user as specified.

Token module access requirement
Users (read/write)
Input Format Mandatory Comment
mwl_iu_username string Y
mwl_fornamn string Y
mwl_efternamn string Y
mwl_efternamn_partikel string
mwl_mtype string Y Name of membership
mwl_password string Y Can not be same as username.
mwl_address string
mwl_address2 string
mwl_postnr string
mwl_postort string
mwl_land string
mwl_email string
mwl_mobil_countrycode string
mwl_mobil_riktnr string
mwl_mobil string
mwl_mnr string
mwl_admin bool 0|1
mwl_locked bool 0|1
mwl_jourbokn bool 0|1

update_user

Theis method updates user details as specified.

Token module access requirement
Users (read/write)
Input Format Mandatory Comment
mwl_iu_username string Y
mwl_fornamn string
mwl_efternamn string
mwl_efternamn_partikel string
mwl_mtype string Name of membership
mwl_password string Can not be same as username.
mwl_address string
mwl_address2 string
mwl_postnr string
mwl_postort string
mwl_land string
mwl_email string
mwl_mobil_countrycode string
mwl_mobil_riktnr string
mwl_mobil string
mwl_mnr string
mwl_admin bool 0|1
mwl_locked bool 0|1
mwl_jourbokn bool 0|1
mwl_pnrDate string
mwl_pnrLastFour string

delete_user

Deletes the specified user.

Token module access requirement
Users (read/write)
Input Format Mandatory Comment
mwl_du string Y Username

simpleLoginCheck

This method can be used to validate a user login on an external service based on myWebLog user credentials.

Token module access requirement
Login Check (read)
Input Format Mandatory Comment
username string Y Username
password string Y Password
Output Format Comment
Basic user data (name, user id, organisation id and email) in case of success.

getObjectData

This method returns all objects sorted by object category, regnr (asc).

Token module access requirement
Objects (read)
Input Format Mandatory Comment
aircraftID int
forceAllObjects bool Will include all objects, even if hidden from the booking calendar view.
Output Format Comment
Object information including remarks and logged total times.

getObjectStatus

This method returns all objects with current status. No IP verification will be performed for this method.

Token module access requirement
Objects (read)
Output Format Comment
ID int
regnr string
bobjectCat int
objectStatus int 0|1|2 representing "ok", "yellow" or "red".

getTransactions

This method returns a list of transactions and their details sorted by transaction date (ASC), time of creation (ASC). Without from_date, only the last 12 months are returned.

Token module access requirement
Economy (read)
Input Format Mandatory Comment
from_date date (yyyy-mm-dd) Default: 12 months before to_date, or before today if to_date is not given. Not applied when transactionID is given.
to_date date (yyyy-mm-dd)
transactionID int
Output Format Comment
Numerous transaction details.

updateTransaction

This method updates the bookkeeping data of an existing transaction. To update a value, the corresponding updateKnt**** value must be set to 1.

Token module access requirement
Economy (read/write)
Input Format Mandatory Comment
transactionID int Y
updateKntDebit bool 0|1
newKntDebit int
updateKntCredit bool 0|1
newKntCredit int
updateKntCostCentre bool 0|1
newKntCostCentre string
updateKntProject bool 0|1
newKntProject string
updateKntVerNr bool 0|1
newKntVerNr string
Output Format Comment
The updated transaction, including details.

getBookings

This method returns a list of bookings.

Token module access requirement
Bookings (read)
Input Format Mandatory Comment
from_date date (yyyy-mm-dd)
to_date date (yyyy-mm-dd)
aircraftID int
bookingID int
Output Format Comment
Booking data divided in two lists: activeBookings and queueBookings.

getInstructorAvailability

This method returns a list of available instructors.

Token module access requirement
Bookings (read)
Input Format Mandatory Comment
at_date date (yyyy-mm-dd)
Output Format Comment
Availability data divided in three lists: byDefault, byEntries and byStbyDuty.

getStudentAvailability

This method returns a list of available students.

Token module access requirement
Bookings (read)
Input Format Mandatory Comment
at_date date (yyyy-mm-dd)
Output Format Comment
Availability data presented in one list: byEntries.

getFlights

This method returns logged flights sorted by date(asc), ID(asc). Without from_date, only the last 12 months are returned.

Token module access requirement
Flight Log (read)
Input Format Mandatory Comment
from_date date yyyy-mm-dd. Default: 12 months before to_date, or before today if to_date is not given. Not applied when flightID is given.
to_date date yyyy-mm-dd
aircraftID int
flightID int
flightUserID int
Output Format Comment
Flight list with numerous data fields.

Error codes

All error messages will be returned according to the following format (JSON exemple). The reply may contain several error messages:

{"APIVersion":"2.0.0","Error":[{"Code":"200","Message":"INVALID USERNAME OR PASSWORD"},":[{"Code":"299","Message":" TEST ERROR MESSAGE 2"}]}

"Code" is always a value according to the table below and Message is always a text string.

Code Message Comment
0 SSL CONNECTION NOT DETECTED SSL connection is required.
1 CONNECTION REFUSED FROM [IP ADDRESS] Connection from [IP ADDRESS] not allowed. Contact myWebLog support to request an IP approval.
301 SQL ERROR Internal error. Contact myWebLog Support.
400 USER NOT FOUND Submitted username could not be found.
401 SQL ERROR Internal error. Contact myWebLog Support.
402 SQL ERROR delete_user: internal error while checking the user's other memberships. Contact myWebLog Support.
403 SQL ERROR delete_user: internal error while checking the user's balance. Contact myWebLog Support.
410 ACCOUNT NOT ZERO The user account balance must be zero.
420 ADMIN USER CAN NOT BE DELETED delete_user: administrators can not be deleted through the API.
500 USERNAME NOT FOUND Submitted username could not be found.
510 INVALID PASSWORD Password can not be the same as the username.
511 WEAK PASSWORD update_user: the new password does not meet the password rules (minimum length, and letters, digits and special characters).
520 INVALID MTYPE Type of membership could not be found.
540 UPDATE FAILED Internal error. Contact myWebLog Support.
550 UPDATE FAILED Internal error. Contact myWebLog Support.
550 TRANSACTION ID NOT FOUND updateTransaction: the transaction does not exist in the organization. (Code 550 is also used by update_user, see above.)
551 TRANSACTION NOT UPDATED updateTransaction: internal error while updating. Contact myWebLog Support.
552 COULD NOT READ RESULT TRANSACTION updateTransaction: the transaction was updated but could not be read back. Contact myWebLog Support.
553 NO FIELDS TO UPDATE updateTransaction: no updateKnt... field was set to 1.
600 USERNAME ALREADY EXISTS The submitted username already exists in the database.
610 INVALID USERNAME PREFIX The username must begin with the club/org ID and a hyphen (e.g. "123-")
620 INVALID USERNAME Invalid username.
630 INVALID INPUT DATA Mandtory fields may not be empty.
640 INVALID PASSWORD Password can not be the same as the username.
641 WEAK PASSWORD insert_user: the password does not meet the password rules (minimum length, and letters, digits and special characters).
650 INVALID MTYPE Type of membership could not be found.
660 INSERT FAILED Internal error. Contact myWebLog Support.
670 INSERT FAILED Internal error. Contact myWebLog Support.
761 TOO MANY FAILED ATTEMPTS simpleLoginCheck: too many failed login attempts for this username. HTTP status 429; the Retry-After header gives the number of seconds to wait.
900 SQL ERROR Internal error. Contact myWebLog Support.
901 NOT AUTHORIZED Submitted administrator credentials incorrect or admin not authorized.
902 NOT AUTHORIZED Submitted administrator credentials not authorized from the requesting IP.
910 INVALID QUERY TYPE Submitted mtype is incorrect.

JSON Example

This is an example of (initial part of) a JSON coded reply from a getFlights request:

{"getFlightsResult":{"numberOfFlights":116,"flights":[{"flightID":"65457","isEmptyRow":null,"originalTransactionID":"137997","aircraftID":"24","regnr":"SE-\u00c4BC","flightDate":"2011-04-02","registeredDate":"2011-05-03","typeOfFlightID":"703","typeOfFlightDescription":"PRIVAT","flightUserID":"303","flightUserFullname":"Magnus af Winsth","flightUserMemberNr":"99999","flightInstructorID":null,"flightInstructorFullname":null,"isSoloInstructionFlight":null,"flightScoutID":null,"flightScoutFullname":null,"tachStart":"126.7000","tachEnd":"127.7000","tachTotal":"1.00000","hobbsStart":null,"hobbsEnd":null,"hobbsTotal":null,"airborneStart":"12:00","airborneEnd":"13:13","airborneTotal":"1.00000","blockStart":null,"blockEnd":null,"blockTotal":null,"towTimeTotal":null,"towHeightID":null,"towHeight":null,"dailyCheck":"1","departurePlace":"ESTA","viaRoute":null,"arrivalPlace":"ESTL","numberOfFlights":"1","distance":null,"fuelUplift":null,"oilUplift":null,"flightComments":"jkl","newRemarkRegistered":null,"user_fornamn":"Magnus","user_efternamn":"Winsth","user_efternamn_partikel":"af"} ...