项目作者: eltercero

项目描述 :
Elixir wrapper for Wanikani API
高级语言: Elixir
项目地址: git://github.com/eltercero/wanikani.git
创建时间: 2017-12-12T12:33:16Z
项目社区:https://github.com/eltercero/wanikani

开源协议:MIT License

下载


Wanikani

Wrapper for the Wanikani API V2.

Installation

The package can be installed by adding wanikani to your list of dependencies in mix.exs:

  1. def deps do
  2. [
  3. {:wanikani, "~> 0.1.0"}
  4. ]
  5. end

Documentation canbe found at https://hexdocs.pm/wanikani.

Setup

The library will look for a environment variable called WANIKANI_API_TOKEN for your V2 Wanikani Token. You can get yours in your account.

Example usage

For further examples, refer to the documentation.

Getting the user information

  1. iex(1)> Wanikani.User.get
  2. {:ok,
  3. %{"data" => %{"current_vacation_started_at" => nil, "level" => 39,
  4. "profile_url" => "https://www.wanikani.com/users/eltercero",
  5. "started_at" => "2016-03-02T09:14:21.072290Z", "subscribed" => true,
  6. "username" => "eltercero"},
  7. "data_updated_at" => "2017-12-12T08:11:06.996305Z", "object" => "user",
  8. "url" => "https://www.wanikani.com/api/v2/user"}}

Listing a resource (e.g., Kanji list)

  1. iex(1)> Wanikani.Kanji.list(%{levels: "1,2"})
  2. {:ok,
  3. %{"data" => [%{"data" => %{"character" => "一",
  4. "component_subject_ids" => [1],
  5. "created_at" => "2012-02-27T19:55:19.000000Z",
  6. "document_url" => "https://www.wanikani.com/kanji/%E4%B8%80",
  7. "level" => 1, "meanings" => [%{"meaning" => "One", "primary" => true}],
  8. "readings" => [%{"primary" => true, "reading" => "いち",
  9. "type" => "onyomi"},
  10. %{"primary" => false, "reading" => "ひと", "type" => "kunyomi"},
  11. %{"primary" => false, "reading" => "かず", "type" => "nanori"}],
  12. "slug" => "一"}, "data_updated_at" => "2017-10-04T18:56:21.270971Z",
  13. "id" => 440, "object" => "kanji",
  14. "url" => "https://www.wanikani.com/api/v2/subjects/440"},...

Getting a single resource (e.g., a radical)

  1. iex(1)> Wanikani.Radical.get(41)
  2. {:ok,
  3. %{"data" => %{"character" => "手", "character_images" => [],
  4. "created_at" => "2012-02-28T21:14:49.000000Z",
  5. "document_url" => "https://www.wanikani.com/radicals/hand", "level" => 2,
  6. "meanings" => [%{"meaning" => "Hand", "primary" => true}],
  7. "slug" => "hand"}, "data_updated_at" => "2017-06-12T23:21:19.687249Z",
  8. "id" => 41, "object" => "radical",
  9. "url" => "https://www.wanikani.com/api/v2/subjects/41"}}