Looks like the Great Firewall or something like it is preventing you from completely loading www.skritter.com because it is hosted on Google App Engine, which is periodically blocked. Try instead our mirror:

legacy.skritter.cn

This might also be caused by an internet filter, such as SafeEyes. If you have such a filter installed, try adding appspot.com to the list of allowed domains.

VocabList Endpoints

This endpoint gives you access to all lists a user would have access to (except for ChinesePod lists), as well as the ability to make the same sorts of edits the user is authorized to make. Use this endpoint if you want to:

  • See what lists Skritter has available.
  • See what lists the user is studying, and where they are in their progress.
  • Control what lists a user is studying, or any other such setting.
  • Create, reorganize, or delete lists, or modify their meta data.
GET http://legacy.skritter.com/api/v0/vocablists

Get meta data on lists of various sorts, and a starting point for seeing what there is.

Parameters

  • lang
    The language of the Vocabs you want to query for.
    (default: user setting or Chinese)
  • offset
    timestamp that filters the result based on sort type. Only works for "published" and "custom".
  • sort
    response sort order.
    "published": lists made by all users, sorted by when they were published
    "custom": made by the user, sorted by when it was last changed
    "official": lists Skritter provides, sorted alphabetically
    "disabled": this user's custom lists that have been disabled
    "studying": lists the user is currently studying, sorted by when their settings were last changed.
    "search": search published lists that contain a given word, passed in through "q"
    "adding": lists being added from by the user
    "deleted": custom lists which have been deleted by the user
    (default: "published")
  • q
    Required for "search" sort. Returns list containing the given word.
  • limit
    maximum number of VocabLists to fetch
    (default: 100) (max: 100)
  • cursor
    string used for pagination
  • ids
    pipe-separated list of VocabLists to fetch. Overrides any query properties used.
  • fields
    comma-separated list of VocabList properties to return.
    (default: all)
  • include_percent_done
    Includes property percentDone in VocabLists returned. It is costly in terms of resources so use only when needed.
  • include_user_names
    Includes property creatorName in VocabLists returned.

Response

  • VocabLists
    list of VocabLists. Does not include the sections property. If by id, non existent VocabLists will have null in their place.
  • cursor
    string to pass back in future requests for pagination. If not included, there are no more. If included, there probably are more.
GET http://legacy.skritter.com/api/v0/vocablists/(id)

Fetches a single list and all its sections. Include the id in the url.

Parameters

  • fields
    comma-separated list of VocabList properties to return.
  • sectionFields
    comma-separated list of VocabListSection properties to return.
  • includeSectionCompletion if true, include "completed" date in VocabListSection entities

Response

  • VocabList
    The requested list, complete with sections, or null if the VocabList does not exist.
POST http://legacy.skritter.com/api/v0/vocablists

Creates a new VocabList.

Input

One VocabList object with the parameters you would like to set. Only mutable properties will be used; all others will be ignored, and any missing properties will be set to defaults.

The rows property will be ignored in this endpoint. Editing words must be done when editing individual sections. You can, however, create and name sections with this call.

The name and sections properties must be included in the VocabList, and names must be included in all VocabListSections. All other properties are optional.

Parameters

  • fields
    comma-separated list of VocabList properties to return.
  • sectionFields
    comma-separated list of VocabListSection properties to return.

Response

  • VocabList
    The created list, complete with sections.
PUT http://legacy.skritter.com/api/v0/vocablists/(id)

Alters an existing VocabList or its settings for this user. Same as when creating a list in every way, except that it modifies an existing list. Also similarly, you cannot use this call to modify words within the list.

For the sections list, all existing undeleted sections must be included to be valid. If you are deleting a VocabListSection, mark it so with the deleted field. If you are creating a new VocabListSection, don't include an id for its object. As above, for new VocabListSections, names must be included, but all other properties are optional.

Input

Same as POST

Parameters

Same as POST

Response

Same as POST

POST http://legacy.skritter.com/api/v0/vocablists/(id)/publish

Publishes the VocabList. Must be an unpublished custom list, with one or more sections, and created by the authenticated User.

Parameters

  • isTexbook
    Optional boolean that tags whether this published list is intended to be for a textbook. If true, will contact the Skritter team for approval.
GET http://legacy.skritter.com/api/v0/vocablists/(id)/image

Returns the custom image for VocabList, or redirects to default images if there is no custom image. Can be used as the img src attribute.

POST http://legacy.skritter.com/api/v0/vocablists/(id)/image

Save a new image for the VocabList.

Input

A jpeg, png or gif image. It's form key should be 'image'.

DELETE http://legacy.skritter.com/api/v0/vocablists/(id)/image

Removes the custom image for VocabList, so that future requests for the image redirect to the default image.

Example: List of Lists Being Studied

Goal:

Print out the names of the lists the user is studying.

Solution:

Use the "sort" field to specify.


    # prepare the request GET parameters
    params = {
        'sort': 'studying',
        'gzip': False,
    }

    # fetch the first 100
    response = client.get('http://legacy.skritter.com/api/v0/vocablists', params)
    response = json.loads(response.content)

    for vocab_list in response['VocabLists']:
        print 'studying', vocab_list['name'], 'with state', vocab_list['studyingMode']

    

Example: Fetching Words

Goal:

Get a complete list of Vocab ids in a list.

Solution:

Fetch the list by id, then compile the Vocab ids in there.


    # prepare the request GET parameters
    params = {
        # minor optimization, not required
        'fields':'sections',
        'sectionFields':'vocabIds,tradVocabIds',
        'gzip': False
    }

    # fetch the first 100
    response = client.get('http://legacy.skritter.com/api/v0/vocablists/%s' % vocab_list_id, params)
    response = json.loads(response.content)

    # compile the Vocab ids
    vocab_ids = set()
    for section in response['VocabList']['sections']:
        for row in section['rows']:
            vocab_ids.add(row['vocabId'])
            vocab_ids.add(row['tradVocabId'])

    return vocab_ids
    

Example: New List

Goal:

Create a new custom list, and have some sections in there.

Solution:

Build the list, then use POST to save it.


    # prepare the request GET parameters
    params = {
        'gzip': False
    }

    # build the list
    vocab_list = {
        'name': 'New List', # required
        'lang': 'ja',       # required
        'description': 'Made through the API',
        'tags':['intermediate', 'technology'],
        'sections': [
            { 'name': 'Section 1' }, # section name required too
            { 'name': 'Section 2' },
            { 'name': 'Section 3' },
        ]
    }

    # POST it
    data = json.dumps(vocab_list)
    response = client.post('http://legacy.skritter.com/api/v0/vocablists', params, data=data)
    response = json.loads(response.content)
    return response['VocabList']['id'] # now you have the id
    

Example: Editing Lists

Goal:

Given a VocabList id, reverse its name, shuffle its sections, and delete its last section, for science.

Solution:

Fetch the list, make the edits, and use PUT to return the result.


    # no special GET parameters needed
    params = {
        'gzip': False
    }
    url = 'http://legacy.skritter.com/api/v0/vocablists/%s' % vocab_list_id

    # fetch the list
    response = client.get(url, params)
    response = json.loads(response.content)
    vocab_list = response['VocabList']

    # reverse the list name
    name = list(vocab_list['name'])
    name.reverse()
    vocab_list['name'] = ''.join(name)

    # randomize the sections
    import random
    random.shuffle(vocab_list['sections'])

    # delete the last section
    if vocab_list['sections']:
        vocab_list['sections'][-1]['deleted'] = True

    # save changes
    data = json.dumps(vocab_list)
    response = client.put(url, params, data=data)

    # print results
    if response.status_code == 200:
        print 'operation "list chaos" successful'
    else:
        print '%s: %s' % (response.get('error'), response.get('message'))