Kundo's API makes it possible to fetch all the data in your forum, and integrate it into your application or website.
Table of contents
- Dialogs in a forum
- Dialogs filtered by topic
- Popular dialogs
- A given dialog
- Comments for a given dialog
- Dialogs that match a search query
- Forum properties
Working with tags
Pagination, and Sorting
Post data to the API
- Dialogs to a forum
- Comments to a dialog
- Votes to a dialog
- Report dialog as inappropriate
- Report comment as inappropriate
- Adding metadata to a dialog
- Auto archiving a dialog
- Uploading files
Methods of posting
- A string that uniquely identifies your forum. It's part of the URL for your forum, so if your forum is located on http://kundo.se/org/your-forum/, then your-forum is your slug. Keep this in mind as it's used in all API calls.
- One specific discussion forum. You can create several forums connected to one account, and each forum will behave as a independent entity. Each forum has its own slug.
- The posting that started a new thread in the forum. Other users add comments to a dialog, but the dialog object in itself does not include the comments. The API call to fetch the comments is available in the comments_uri property on the dialog. A dialog always has a topic, a category that denotes what kind of dialog they posted. It can be either a question, a problem, a suggestion, or praise.
All examples below are clickable, to make it easier to explore the API. You can also adapt the examples to your own forum by simply inputting your slug (see explanation above) in the below form.
Available return formats
- All dialogs, in JSON format. Since this is the recommended format, all other examples use JSON.
- All dialogs, in XML format.
Errors will be reported with the corresponding HTTP status code.
HTTP/1.1 400 BAD REQUEST
- JSON data posted was incorrectly formatted.
HTTP/1.1 400 BAD REQUEST
"Du m\u00e5ste fylla i din e-postadress."
- Required data is missing. The key indicates which field is incorrect, and the error message can be shown to the user to help them correct their error.
HTTP/1.0 409 CONFLICT
- HTTP response if the exact same dialog (title and text) already exists.
If everything went well a 201 CREATED response will be returned:
HTTP/1.1 201 CREATED
- The dialog, comment, or vote was created without problems.
Prefer server side over client side
If you are doing API calls that require an API key these must of course be done from your server side code to avoid publishing your API key.
Use the client IP address
The IP address of the user posting a dialog or comment is used by Kundo in a number of ways, most notably to protect your forum from spam and other abuse. When posting content to Kundo from your server side code the IP address sent by your server is used. We strongly recommend that you post data with the IP address of the user rather than your server. This can be done by setting the X-Forwarded-For header on your request with the IP address of the user.
- All dialogs in your forum. Limited to 50 dialogs per request - see pagination.
- All dialogs with topic "question". Available topics: question, problem, suggestion, and praise, or in their abbreviated forms: Q, P, S, and B (Why B for praise? Because "P" was taken :).
- It's also possible to select dialogs from multiple topics. Just send in a comma separated lists of the topics you want.
- The most popular questions at the moment. Popularity is also available as a sorting parameter to all dialog queries.
Each element in an API response contains a property called "uri", with an URL that can be used to access details about that object. NOTE: We've tried hard to include as much data as possible in the listing calls, so you might not need to use the details view.
- All information we have on the dialog with id=1.
Using the "comments_uri" property you can fetch comments for a given dialog.
You can also search for dialogs that contain one or more keywords. The search matches strings both in the title, body text, and comments. The title and body text contains a span with class "highlighted" where our search engine would highlight the matched query words.
- Search through all the dialogs that contain "test". Limited to 10 dialogs per query.
When building a customized mirror of the forum start page, it can be helpful to be able the fetch the user customizable settings for a forum instead of hardcoding them.
- Common user configurable properties of the forum.
|name||The forum name|
|formal_name||Formal company name. May be different from the forum name|
|intro_message||A short description of the forum|
|status_message||Temporary message displayed above the feedback form|
|status_url||URL where user can read more about the status message.|
|popup_header||Header text for the popup window|
|default_topic||The topic that should be selected by default|
|enabled_topic||List of all available topics|
|language||The language setting of the forum|
Calls that require an API key
It is also possible to fetch data that is normally only available to logged in editors. To fetch this kind of data do you need an API key, available to customers with an Medium, Large or Custom account. Contact us if you need an API key. A bad API key returns error code 401 "Authorization Required".
Working with tags
Tags are great for building new views into your forum. You could for instance tag your dialogs with a product specific tag, and use that one to show a list dialogs on your product page. Tags are only settable by editors or when posting dialogs to the API with an API key, and can be made either private (default) or public. If they are private you need a API key to fetch them in the API.
- Get dialogs tagged with "example".
- Get dialogs tagged with both "tag1" and "tag2".
- Search for dialogs including the word "test" and are tagged with "tag1".
Pagination can be controlled through the start and limit parameters. The start parameter sets the first index to fetch (NOTE: zero indexed, default: 0), the limit parameter sets the number of results to return (default: 50). These parameters works with all kinds of requests, including search.
- Fetch the next 50 dialogs. When no more dialogs are available, an empty response is returned.
- Fetch a maximum of 10 results.
All queries returning a list of dialogs also has a HTTP header called X-TotalResults that contains the total number of dialogs that are available, no matter what the limit and start parameters are set to. This makes it possible to calculate the number of page links to show after your partial list of results.
By default, dialogs and comments are sorted in reverse chronological order, i.e. the most recent first. By specifying the sort parameter you can select a different sorting order:
- All questions, sorted by number of comments. Ascending.
To reverse the sort order, add a minus sign ("-") in front of your sort parameter:
- All questions, sorted by number of comments. Descending.
Available sort parameters are:
|pub_date||The date and time when the dialog was posted|
|popularity||The dialog popularity (based on page views, comments, and time decay)|
|last_activity||The date and time when the dialog was last commented on. If there are no comments, the date the dialog was published.|
|num_votes||The number of votes|
|num_comments||The number of comments|
|title||Title of dialog|
|text||Dialog body text|
|topic||The topic of the dialog ("Q", "P", "S", or "B")|
|user__first_name||The name the user specified|
Post data using the API
To enable advanced customizations, it is also possible to post dialogs, comments and votes using the API. Posts can be done both using JSON and a HTML form, but the URL:s used are the same.
- Post new dialogs to your forum.
- Post comments to a given dialog.
- Post votes to a given dialog.
- Report a dialog as inappropriate
- Report a comment as inappropriate
Adding metadata to a dialog
It can be useful to append other data to a dialog, e.g. customer id or social security number, that is only available to logged in editors. Such data can be added as regular parameters to a dialog post. However, before doing so Kundo must set up the accepted parameters for you. Each parameter has a type (integer or text) and a max length or max value. Metadata can only be added if you have an Medium account at Kundo. To set up accepted metadata parameters for your account, please contact us.
Once parameters are set up, just add them to your regular dialog post:
"title": "Post title",
"text": "Post contents...",
- Post a new dialog using JSON with two metadata fields, customer_id and customer_level, added.
Auto archiving a dialog
Kundo support the concept of “archiving” dialogs. This means that the dialog is still available on Kundo for editors and anyone with the URL to the post. However, the dialog will not show up in lists or in search for regular users. This is a good way to keep personal posts away from the public forum.
If you for some reason want to archive a post immediately after it's posted you can add the "archived" parameter to your post. Since archiving is only available to editors the call requires an API key if this parameter is included.
"title": "Post title",
"text": "Post contents...",
- Post a new dialog that will be immediately archived.
To highlight a problem or add more details to a reply, users sometimes want to add images, PDF files and other types of documents to a dialog or comment. Kundo handles such attachments in a loosely coupled way: Each link found in the text of a dialog or comment will be replaced by a corresponding embed code for that particular file type.
Files that are uploaded to Kundo are handled in the same manner: Once the file is uploaded you simply add the link to that file info the text of your dialog or comment before you post it to Kundo.
- A successful call returns the URL of the uploaded file. The content type of your post needs to be “multipart/form-data” and the attached file should be added to a POST variable named “file”.
This call requires an API key.
Send data as JSON
All posts require structured data, and JSON works well for that purpose. To specify that you are using JSON you need to set the "Content-Type" header to "application/json".
"title": "Post title",
"text": "Post contents..."
"tags": "tag one, tag two, tag three"
- Post a new dialog using JSON. If you add tags to the dialog as in the example above you need to supply an API key in the URL. See working with tags.
"text": "My comment goes here..."
- Post a new comment using JSON
- Post a new vote using JSON
"report_reason": "Report reason goes here..."
- Report a dialog or comment using JSON
To use cURL to test the API, use these command flags:
curl -i -H 'Content-Type:application/json' -X POST -d '<Your JSON data here>' http://kundo.se/api/kundo
- Post a new dialog using cURL.
Send data using an HTML form
The API also support posting data through a HTML form directly.
<form action="http://kundo.se/api/kundo" method="POST">
Type of question:
<p>Title: <input name="title"></p>
<p>Your name: <input name="name"></p>
<p>Your e-mail: <input name="useremail"></p>
<input name="error_url" value="<URL to forward errors to>" type="hidden">
<input name="success_url" value="<URL when successfully posted>" type="hidden">
- Post data using an HTML form.
The two last fields,
success_url, are related to error handling:
- If all fields are correct the request is forwarded to
- If no
success_urlwas given, the request is forwarded directly to the dialog in the forum.
- If any field has an error the request is forwarded to
error_urland and the error message is added as a GET parameter to that URL. I.e:
These query parameters can be used to generate a new form on the server side, and display the errors to the user
- If any of
success_url, are incorrect, an error message will be shown.