Please tell me more about API authentication and endpoints


This is my first message to this nice community. As a long-time user of Khan Academy, donor and evangelist; I was very happy to find out about KA Lite.
Currently I’m building a solution for a primary school in The Gambia.

Now, to get to the point:
Where can I find documentation about the API endpoints, and its parameters?
I was already happy to discover /api/exerciselog/.
Also, I’d like to be able to authenticate through javascript.

Thanks in advance.

BA Applied Informatics student interning in The Gambia

Welcome Shane! :slight_smile:

I have to apologize in advance. The authentication system may not be the most state-of-the-art system you’ll ever see…

Anyways, there is an API, it’s (kind of implicitly) made available by django-tastypie. You can see how it’s configured in the facility application which handles all the user logic:


It contains the following tastypie resource description [this isn’t all of it, just a snip of the first part]:

class FacilityUserResource(ModelResource):
    facility = fields.ForeignKey(FacilityResource, 'facility')

    class Meta:
        queryset = FacilityUser.objects.all()
        resource_name = 'user'
        authorization = TeacherOrAdminCanReadWrite()
        filtering = {
            'facility': ALL_WITH_RELATIONS,
            'is_teacher': ['exact']
        exclude = ["password"]

    def prepend_urls(self):
        return [
            url(r"^(?P<resource_name>%s)/login%s$" %
                (self._meta.resource_name, trailing_slash()),
                self.wrap_view('login'), name="api_login"),
            url(r'^(?P<resource_name>%s)/logout%s$' %
                (self._meta.resource_name, trailing_slash()),
                self.wrap_view('logout'), name='api_logout'),
            url(r'^(?P<resource_name>%s)/status%s$' %
                (self._meta.resource_name, trailing_slash()),
                self.wrap_view('status'), name='api_status'),

    # ...

The resource is connected in facility/

    # For user management (not yet used, but needed here to enable URI for tastypie exercise logging endpoints)
url(r'^', include(FacilityUserResource().urls)),

Then that’s connected in facility/

urlpatterns += patterns(__package__ + '.api_views',
url(r'^api/', include(api_urls)),


…and then FINALLY that’s connected in distributed/

urlpatterns += patterns('',
    url(r'^securesync/', include(kalite.facility.urls)),  # for backwards compat
    url(r'^securesync/', include(securesync.urls)),

The comment for backwards compat, I can’t tell what’s about… IRC this is the only place we connect facility.urls.

Finally, this gives you the following URL pattern:


I hope this can get you where you wanna go! Please do share your experiences in here or on our deployment map :slight_smile:


Thanks Ben

I’m not so familiar with this technology. I brought a raspberry pi and the latest rachel server image. Now I’m hacking full speed to show an MVP, which should reward me later with time and resources.

So, here’s my impatient question. :innocent:

I’ve got the logout and status working.
Can you help me with the login, as to which parameters and which method should be used.

      method: "POST",
      url: "",
      data: { password: "rachel", user: "rachel" }
     .done(function( msg ) {

Thanks in advance. KA Lite will be featured in my research paper, and I’ll certainly share my experiences.


Tip: Try introspecting the actual login form of KA Lite, using your browser’s “web developer” tool.

Hi @shanedeconinck

I read your msg on IRC, but you logged off before I could answer you or rather ask: What are you looking for help with exactly?

What types of problems are you encountering?

I can understand that you want to use the API endpoints for logging users in/out. Have you looked in your logs? Are you running KA Lite with kalite start --foreground?

I’m sorry that we’re unable to give you a complete API documentation… however, your use case sounds like it’s managable without API docs :slight_smile:

Hi Ben, thanks for getting back. My internet connection in The Gambia is not so smooth.
I’ll come back with a detailed answer!