Coder Social home page Coder Social logo

anki-http-server's Introduction

anki-http-server

An Anki add-on that launches an HTTP server upon startup and exposes Anki's data via a REST-ish API

Status

  • Work in progress.
  • Quick and dirty hack.
  • It works but I don't love the code.

Motivation

I needed a way to use Alfred on OS X to add notes to Anki. Mucking around with Anki's sqlite database directly didn't sound appealing. A lightweight HTTP server, on the other hand, opens a lot of possibilities. (ClojureScript frontend for Anki, anyone?)

The Alfred extension can be found here.

Installation

Copy the contents of src to your Anki's add-on folder (without the src folder itself). The code has no external dependencies.

By default listens on port 41837. To change it, edit anki_http_server_init.py - it'll be obvious.

API

Only 3 endpoints for now:

GET /decks

Returns names of all Anki decks in a json object with key 'decks':

{
    "decks": [
        "Python cheatsheets",
        "Clojure study"
    ]
}

GET /models

Returns names of all Anki note models in a json object with key 'models':

{
    "models": [
        "Basic (optional reversed card)",
        "Cloze",
        "Basic",
        "Basic (and reversed card)"
    ]
}

POST /decks/:deckName

Creates a "basic" note in the deck with the given deckName. Expects a urlencoded body with 2 params: front and back for the two sides of the note. Returns something meaningless.

More!!!

No time right now, but it's easy to add more. Look at the bottom of __init__.py

The endpoints I really want to add:

  • /notes
  • /notes/:id
  • A more flexible POST /decks that accepts the name of the note model and dynamically extracts necessary fields based on fields defined in the said model

anki-http-server's People

Contributors

pbkhrv avatar pcbng-peter avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

leonpeek

anki-http-server's Issues

ability to ask Anki to sync

could be useful while adding notes - i'd love to see them synced to the server so that I can load them on my phone

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.