Note: This document is a work in progress, it is not yet complete!
The PageKite Service API is an XML-RPC interface exposed at: https://pagekite.net/xmlrpc/
All API methods have the following characteristics:
a
) must be an account identifierc
) must be an access credentialSome less security-sensitive methods will accept an empty string as the account identifier and/or access credential, but most require both.
Account identifiers may be any of: e-mail addresses, kite names or user IDs.
In the case where a super-user account is being used to manipulate other users, the first argument is the name of the account being manipulated, and the credential should be a 2-tuple authenticating the super-user: (acct_id
, credential
).
Note that any XML-RPC methods with CamelCaps are deprecated and should not be used in new code.
Any other methods not documented on this page should be considered "under development" and subject to change without warning.
This is an example of interacting with the API using the Python shell:
$ python
Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import xmlrpclib
>>> pks = xmlrpclib.ServerProxy('https://pagekite.net/xmlrpc/')
>>> ok, creds = pks.login('user.pagekite.me', 'PASSWORD', '')
>>> ok
'ok'
>>> creds
('5a2b8499b3', 'f9a6xf7e7kbbkdeba6979f7d92z6db8f')
>>> a, c = creds
>>> ok, data = pks.get_account_info(a, c, 0)
>>> data
...
Arguments:
a
, required account identifierc
, required access credentialscredential
, a string which may be emptyThis method will return ('ok', (acct_id
, credential
)) on success.
If the credential
argument is less than 32 characters long, a new credential will be generated and returned. If it is of sufficient length it will be treated as a previously issued credential and its validity extended for another hour.
The returned acct_id
is an account ID which will stay valid even if kite names or e-mail addresses are changed.
Notes: It is recommended that clients DO NOT provide their own temporary credentials when first logging in, as the credentials generated by the service are known to be quite secure. Clients are also requested to limit the frequency of their calls to this method, as credential generation is a relatively expensive operation. Renewing old credentials is much more efficient.
Arguments:
a
, required account identifierc
, required access credentialsrevoke_all
, required booleanThis method will return ('ok', ...) on success.
If the revoke_all
variable is True, all temporary access credentials will be revoked. Otherwise, only the credential in use by this session will be revoked.
Arguments:
a
, optional stringc
, optional access credentialse-mail
, required string: the e-mail address for the new accountkitename
, required string: the domain name for the user's first kiteaccept_terms
, required boolean: has the user accepted the TOS?send_mail
, required boolean: send the user an e-mail with instructions and a passwordactivate
, required boolean: activate the account immediately?On successful account creation, the return code will be 'ok' and the payload will be a dictionary of account attributes including the following items:
email
: the user's e-mail addresssecret
: the shared secret for use with pagekite.pykitename
: the user's initial kite nameexpires
: the Unix timestamp of when this account expires if unactivatedpassword
: the user's password (only provided to privileged accounts)Possible errors: unauthorized
, email
, subdomain
, domain
, terms
, pleaselogin
, domaintaken
Notes:
accept_terms
is not True, the method will fail.send_mail
is False, then privileged credentials must be presentedactivate
is True, then privileged credentials must be presentedArguments:
a
, optional stringc
, optional access credentialse-mail
, required string: the e-mail address for the new accountkitename
, required string: the domain name for the user's first kitepassword
, required string: the password for the accountkite_secret
, required string: the default shared secret for flying kitesaccept_terms
, required boolean: has the user accepted the TOS?send_mail
, required boolean: send the user an e-mail with instructions and a passwordactivate
, required boolean: activate the account immediately?Behaves the same as create_account
(see above), except instead of generating a random password and random kite secret, it uses the provided values.
Arguments:
a
, optional stringc
, optional access credentialspassword
, user's passwordThis will freeze the user's account; this means all kites will be removed from DNS so they do not consume bandwidth and any recurring billing subscriptions will be canceled. On success, it should return ('ok', 'Account frozen'). If the password does not match it may return the code unauthorized
.
Arguments:
a
, optional stringc
, optional access credentialspassword
, user's passwordThis will delete the user's account. On success, it should return ('ok', 'Deleted: account'). If the password does not match it may return the code unauthorized
.
Arguments:
a
, optional stringc
, optional access credentialsreuse_names
, boolean: whether to free kite names for reuseThis method requires privileged credentials.
It will delete the user's account, possibly freeing up all registered domains for reuse (if reuse_names
is True). On success, it should return ('ok', 'Deleted: account'). If credentials are invalid or the domain does not allow domain name reuse, it may return the code 'unauthorized'.
Arguments:
a
, required account identifierc
, required access credentialsversion
, a version number may be empty or zeroThis method will return ('ok', payload
) on success. The payload will be a nested dictionary, like so:
Non-obvious keys in the data
dictionary will have a corresponding entries in the fields
dictionary which explains in human readable language what they mean.
Some common fields include:
Note that the kites
and groups
data sections may be incomplete if this account has registered a very large number of kites or sponsored accounts.
Arguments:
a
, required account identifierc
, required access credentialskey
, required stringvalue
, required valueThis method will return ('ok', 'Set key to value') on success. Any key returned by get_account_info() may, if the user has sufficient privileges, be set in this way, except for the user's e-mail address - please use set_email() for that.
Arguments:
a
, required account identifierc
, required access credentialssend_mail
, required booleanThis method will return ('ok', ...
) on success.
If send_mail
is True, the user will be e-mailed the new password, otherwise the new password is returned in the payload of the method. Only super-users can reset passwords for their users without e-mailing.
Arguments:
a
, required account identifierc
, required access credentialspassword1
, required stringpassword2
, required stringThis method will return ('ok', ...
) on success. Passwords must both be the same and must comply with the service password policy. Overly short or simple passwords may be rejected.
Arguments:
a
, required account identifierc
, required access credentialsset_email
, required e-mail addresssend_mail
, required booleanThis method will return ('ok', ...
) on success.
If send_mail
is True, a notification will be sent to the user's old account with instructions on how to undo the change. Only super-users can change e-mail addresses for their users without e-mailing.
Arguments:
a
, optional account identifierc
, optional access credentialsundo_key
, a key granting permission to undo this actionThis method will return ('ok', ...
) on success.
This method will undo an e-mail change operation, allowing users to rescue hijacked accounts. It does not require the user successfully log on first, but the user must have a valid "undo key" which would have been mailed out by the set_email() method.
Arguments:
a
, required account identifierc
, required access credentialsmessage
, required text to add to user's account historyThis method will return ('ok', ...
) on success.
Arguments:
a
, required account identifierc
, required access credentialsThis method will return ('ok', history
) on success, where history
is a list of 2-tuples: (timestamp
, text
). The times are Unix timestamps (seconds since the epoch).
Arguments:
a
, required account identifierc
, required access credentialsThis method will return ('ok', ...
) on success.
Arguments:
a
, required account identifierc
, required access credentialsThis method will return ('ok', domains
) on success, where domains
is a dictionary mapping available domain names to a list of capabilities for each. Capabilities are:
Arguments:
a
, required account identifierc
, required access credentialskitename
, name of kiteThis method will return ('ok', info
) on success, where info
is a dictionary providing information about the kite, including any DNS records it currently has registered. The structure of this dictionary is the same as in the kites
data returned by get_account_info
.
Arguments:
a
, required account identifierc
, required access credentialsThis method will return ('ok', kites
) on success, where kites
is a dictionary of kite names mapped to byte transfer counts for each. Kites which have been disabled will have negative counters.
Arguments:
a
, required account identifierc
, required access credentialskitename
, required stringThis method will return ('ok', ...
) on success, or an error describing why this kite can not be added to this user.
Possible error codes include: 'domain', 'domaintaken', 'no_service', 'subdomain' and 'unauthorized'.
Arguments:
a
, required account identifierc
, required access credentialscname
, required stringThis method will return ('ok', ...
) on success, or an error describing why this domain name can not be added as a CNAME kite for this user.
Arguments:
a
, required account identifierc
, required access credentialskitename
, required stringcheck_cnames
, required booleanThis method will return ('ok', ...
) on success, or an error describing why this kite can not be added to this user.
Possible error codes include: 'domain', 'domaintaken', 'no_service', 'subdomain', 'unauthorized', 'pleaselogin' and 'error'.
If check_cnames
is False, no attempt will be made to add external CNAME kites.
Arguments:
a
, required account identifierc
, required access credentialskitename
, required stringsecret
, required stringcheck_cnames
, required booleanThis method does the exact same thing and returns the same values as add_kite
above, except it also sets a specific shared secret for the kite at the same time.
Arguments:
a
, required account identifierc
, required access credentialskitename
, required stringsecret
, required stringThis method sets the shared secret for the given kitename
to secret
. Setting to the special value "default" will remove the per-kite secret and re-enable the account's default shared secret for this kite.
Possible error codes include: 'bad_value', 'unauthorized', 'pleaselogin' and 'error'.
Arguments:
a
, required account identifierc
, required access credentialskitenames
, a required list of stringsThis method will return ('ok', ...
) on success.
Note that not all kites can be deleted, some can just be disabled. The function will return 'ok' in either case, the actual result can be confirmed by consulting the get_kite_stats() function.
Arguments:
a
, required account identifierc
, required access credentialskitenames
, a required list of stringsforce
, a required booleanThis method requires privileged credentials.
This method will return ('ok', ) on success.
If force
is True, it will attempt to forcibly delete name that would otherwise be kept reserved to prevent reuse. If forced deletion is requested but is prevented by policy, the method will return the 'unauthorized' code.
Arguments:
a
, required account identifierc
, required access credentialskitenames
, a required list of stringsThis method will return ('ok', ...
) on success.
This function will reset a list of kites, reenabling them if necessary and setting their traffic counters to zero.
Arguments:
a
, required account identifierc
, required access credentialsdomain
, a required stringrectype
, a required string (one of 'A', 'CNAME' or 'MX')value
, a required stringThis method will return ('ok', ...
) on success.
The domain name must match one of the user's existing kite names. Note that at the moment, no sanity checking is done on record validity, you can easily create completely DNS bogus records using this method. The time-to-live for the new DNS record will be chosen automatically.
Arguments:
a
, required account identifierc
, required access credentialsdomain
, a required stringrectype
, a required string (one of 'A', 'CNAME' or 'MX')value
, a required stringThis method will return ('ok', ...
) on success. The domain name must match one of the user's existing kite names.
Arguments:
a
, required account identifierc
, required access credentialsdomain
, a required stringrectype
, a required string (one of 'A', 'CNAME' or 'MX')values
, a required list of stringsThis method will return ('ok', ...
) on success.
The domain name must match one of the user's existing kite names. All pre-existing records for that type will be removed, replaced with the specified values. Note that at the moment, no sanity checking is done on record validity, you can easily create completely DNS bogus records using this method. The time-to-live for the new DNS record will be chosen automatically.
Arguments:
a
, required account identifierc
, required access credentialsThis method will return ('ok', group_info
) on success, where group_info
is a list of hashes, one for each group. The hashes will have at least the following keys: 'gid', 'name', 'flags', 'description'.
Arguments:
a
, required account identifierc
, required access credentialsThis method will return ('ok', group_info
) on success, where group_info
is a list of hashes, with one hash for each group. The hashes contain the same information as those returned by get_groups(), but add a 'members' field, which is a list of hashes describing all group members, including their names, e-mails and kite statistics.
Arguments:
a
, required account identifierc
, required access credentialsname
, required stringflags
, required stringdescription
, required stringThis method will return ('ok', ...
) on success.
The only defined flag at the moment is O
which marks the group as open.
Arguments:
a
, required account identifierc
, required access credentialsgroup_ids
, required list of group IDs.This method will return ('ok', ...
) on success.
Arguments:
a
, required account identifierc
, required access credentialsThis method will return ('ok', ...
) on success.
Arguments:
a
, required account identifierc
, required access credentialsThis method will return ('ok', ...
) on success.
Arguments:
a
, required account identifierc
, required access credentialsgm_ids
, required list of pairsThe gm_ids
must be a list of (group_id
, user_id
) pairs, each of which will be removed if found in the user's list of groups and members.
This method will return ('ok', ...
) on success, and will not complain if some requested user/group pairs appear to have already been removed.
Arguments:
a
, required account identifierc
, required access credentialsThis method will return ('ok', ...
) on success.
Arguments:
a
, required account identifierc
, required access credentialsThis method will return ('ok', ...
) on success.
Arguments:
a
, required account identifierc
, required access credentialsThis method will return ('ok', ...
) on success.
The following are some of the more common error codes returned by various API methods:
Comments