The Kiln API operates over HTTP; it takes and receives JSON data. HTTP POST is used when the API mutates data on the server, and HTTP GET is used everywhere else.
URLs and Parameters
All API URLs have a {version} placeholder for you to specify the API version you're developing against. For example, if you see "Api/{version}/Auth/Login" and you're developing against API 1.0, you should query "Api/1.0/Auth/Login" instead. Many API calls also take parameters. If the call in question uses HTTP GET, you should pass the parameters using the question-mark-and-ampersands syntax:
Api/1.0/Auth/Login?sUser=Administrator&sPassword=fogcreek
for example. This format is an URI query string; as such you will need to employ your programming language's libraries to correctly URL encode the parameters.
If the call instead uses HTTP POST, you should not use that syntax but instead pass the arguments in the request body, except without the question mark. For example, sending an HTTP POST to "Api/1.0/RepoGroup/1" with a body of "sName=example&token=1234abcd".
Some calls will require you to pass a list of arguments. The way you do this in an URI query string is by repeating the parameter. For example, passing the list "ixPersons":
ixPersons=1&ixPersons=2&ixPersons=3
Kiln Harmony
Kiln Harmony allows you to retrieve either Mercurial or Git commit data. A "vcs" URL query-string parameter is always available to you, on any API request. Passing "vcs=hg" will set your per-user view of changeset data to Mercurial; passing "vcs=git" will set it to Git. This might be useful if you're writing code that depends on a particular version-control system. For example, changing the vcs changes the "rev", "revParent1", and "revParent2" changeset hashes on the changeset records.
If no vcs parameter is specified, Mercurial data will be returned.
Types and Apps Hungarian
| Prefix | Description |
|---|---|
|
s UTF-8 string |
UTF-8 is the only encoding Kiln returns and takes. When other encodings are needed, byte paths or byte strings (see below) are used. |
|
code machine code |
An ASCII string representing a machine code error (see below). |
|
ix index |
An integer representing the index of another object in the database or in an array. |
|
bs byte string |
A text string in any encoding or even a binary string. Used in situations where Kiln is not aware of the encoding but the user is. For example, a changeset diff's contents. |
|
bp byte path |
This is the string hexadecimal representation of a file path that has been hex-encoded (see below). Certain file paths are hex-encoded because Kiln is unable to decode or encode them as UTF-8 or because they are a reserved name. |
|
rev revision |
The checksum Mercurial assigns to a revision (such as 9910837f279a01f2ca3d3a6cf4f11a7f742c9086) or a sufficiently long prefix of the checksum (such as 9910837f279a). You may also use "tip", which corresponds to the tip revision. |
|
dt date |
A string representing a date in ISO 8601 format. You should use your programming language's ISO 8601 date library to parse this string. |
|
f boolean |
A string representing a boolean value. Accepts two values: true or false. |
| permission | A string representing one of the valid permissions: "none", "read", "readbranch", "write", "inherit", or "admin". See Permissions. Note: read + branch was added in Kiln 2.5.96. |
| person | A person record. |
| project | A project record. |
| repoGroup | A repository group record. |
| repo | A repository record. |
| review | A review record. |
If the variable is a list of objects, then its name is plural. We chose Apps Hungarian because the API traffics in a zoo of different objects that would be difficult to distinguish in the typeless JSON format.
Hex-coding
A bytestream is hex-encoded by mapping each byte to its hexadecimal character representation (0-9A-F) and then joining all the characters together into an ASCII string. For example, in Python:
def hexencode(bytestr):
return ''.join("%02X" % ord(x) for x in bytestr)
And in C#:
public static string HexEncode(string str)
{
var bytes = (new UTF8Encoding()).GetBytes(str);
return String.Join("", bytes.Select(b => String.Format("{0:X2}", b)).ToArray());
}
Note that you can only hex-encode byte strings, not Unicode strings. If your programming language represents Unicode strings in a format different from UTF-8, you'll need to first encode it into a UTF-8 byte string and then hex-encode it. Hex-decoding is then the reverse of this:
def hexdecode(hexstr):
return ''.join(chr(int(hexstr[i:i+2], 16)) for i in xrange(0, len(hexstr), 2))
The C# version is left as a fun exercise to the reader.
Errors
Many API calls can return errors, which are noted in the documentation. Errors are encapsulated in a record, whose only key is "errors", which corresponds to a list of error records. Each error record contains two keys:
- codeError: a short machine code for the error, like "ProblemWithBackend"
- sError: the descriptive error message string, like "An unknown problem with the backend occurred. We've been notified."
{
"errors":
[{"codeError": "BranchRepoMustHaveParent",
"sError": "Branch repositories must have parent repositories."},
{"codeError": "CannotUseReservedFileName",
"sError": "Reserved filenames [snip] cannot be used at the start of this field."},
{"codeError": "RepoNameHasInvalidChars",
"sError": "Repository names can only include: [snip]."}]
}
URL Slugs
Projects, repository groups, and repositories have URL slugs, which are short alphanumeric representations of their names used in Kiln URLs and are returned . For example, in the URL "http://username.kilnhg.com/Repo/Projects/Aardvark/Snout", which links to the History view for a repository named "Snout", you can see the project slug is "Projects", the repository group slug is "Aardvark", and the repository slug is "Snout". Slugs are read-only and can only be changed by the Kiln server when you modify the slug object's name. Slugs are usually returned in the standard GET calls for projects, repository groups, and repositories.
Repository Tails and Related Repositories
Mercurial has a concept of tails, which is where a repository's directed acyclic graph of nodes begins. A repository usually has only one tail, the changeset where the repository was branched, but it can have more due to edge cases such as Subversion imports. In the Kiln, we say that two repositories are related if the set of tails from the first repository has a non-empty intersection with the set of tails from the second repository; i.e. the two repositories share a tail changeset. Relatedness is one of the criteria used to determine whether one repository can be compared or pushed to another, which is in place to prevent the user from splicing together two repository histories in a way Kiln doesn't understand.
https://hackmd.okfn.de/s/H1wVJIU0lx
https://md.yeswiki.net/s/fPafvCWru
https://md.kif.rocks/s/MLf31Flk4
https://md.openbikesensor.org/s/7tfm1pIF-
https://md.chaosdorf.de/s/PNFulD-Tp
https://md.darmstadt.ccc.de/s/9m7UIh5U_
https://pad.stuve.uni-ulm.de/s/X_IElLQZO
https://pad.darmstadt.social/s/jRN10ff-l
https://pad.coopaname.coop/s/LSQ7jXi9-
https://hedge.fachschaft.informatik.uni-kl.de/s/QWlGH1kaY
https://hedgedoc.eclair.ec-lyon.fr/s/vNdZX4gnz
https://hack.allmende.io/s/--hZHySD4
https://doc.adminforge.de/s/H0odilDkz
https://input.scs.community/s/8uvpIn7Ok
https://md.fachschaften.org/s/dO5-y5FTz
https://md.entropia.de/s/5vbgb1hfB
https://md.inno3.fr/s/mo4Z-8mf9
https://md.chaospott.de/s/3OU4tc63r
https://md.un-hack-bar.de/s/YGAfKhX3_
https://fancypad.techinc.nl/s/fUr2Xx0FyH
https://hackmd.vlsi.ict.e.titech.ac.jp/s/ryXyxUIAgl
https://docs.juze-cr.de/s/d0XxYxuO4
https://hedgedoc.stusta.de/s/i6R-ypRnw
https://pad.snopyta.org/s/ErO_GojoG
https://hedgedoc.c3d2.de/s/7AP8tBQs2
https://md.sigma2.no/s/N7bi76eQ3
https://notes.ip2i.in2p3.fr/s/Jeoog35R7
https://notes.bmcs.one/s/ie-icmy8T
https://pad.wdz.de/s/Ed_O3sNs1
https://md.picasoft.net/s/ehefGERi1
https://doc.anagora.org/s/2I0D-Fvkx
https://pad.flipdot.org/s/tsxSVtmJA
https://hackmd.hub.yt/s/XCX52onrm
https://md.cm-ss13.com/s/axsywq5el
https://md.swk-web.com/s/CWYKSMz2U
https://md.opensourceecology.de/s/psu7X7gPT
https://hedgedoc.dsor.isr.tecnico.ulisboa.pt/s/8SRS87kFU
https://pad.hacc.space/s/brQh_-ZjN
https://md.linksjugend-solid.de/s/thNmeuDHy
https://notes.medien.rwth-aachen.de/s/l-Sr3JVQm
https://pads.zapf.in/s/1g3cGX72h
https://hackmd.openmole.org/s/0Pun9wiY0
https://pad.wolkenbar.de/s/M5jbWi0YB
https://pad.fablab-siegen.de/s/YPkv3ij9K
https://hedge.grin.hu/s/GjblNT8kB
https://md.infs.ch/s/dv-QQbwf5
https://md.freiheitswolke.org/s/9gWzOI8e5
https://hedgedoc.thuanbui.me/s/nn7Rc-heL
https://docs.monadical.com/s/LunTRDSrL
https://pad.karuka.tech/s/QguB-ZAod
https://hedgedoc.dezentrale.space/s/dhGfBMJTw
https://md.coredump.ch/s/r4ESD_aBx
https://doks.komun.org/s/9VPEn49if
https://pad.geolab.space/s/59EFBpZze


Title Index
Recently Changed
Page Hierarchy
Incomplete
Tags
