Skip to content

Instantly share code, notes, and snippets.

@futoase
Forked from yokoji/api_v1_01_introduction.md
Last active November 16, 2017 06:24
Show Gist options
  • Save futoase/a16989814f0807a1e1ccdd9f3e4f3c18 to your computer and use it in GitHub Desktop.
Save futoase/a16989814f0807a1e1ccdd9f3e4f3c18 to your computer and use it in GitHub Desktop.

Revisions

  1. futoase revised this gist Nov 16, 2017. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion api_v1_02_example.rb
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    require 'oauth2'
    require 'faraday'
    require 'faraday_middleware'
    require 'base64'

    # Initialize

    @@ -19,13 +20,15 @@

    # Getting authorized

    AUTHORIZATION_BASE64_PACK = Base64.encode64("#{YOUR_APP_ID}:#{YOUR_SECRET}").gsub("\n", '')

    params = {
    grant_type: 'authorization_code',
    code: AUTHORIZATION_CODE,
    redirect_uri: YOUR_REDIRECT_URI,
    headers: {
    'Content-Type' => 'application/json',
    'Authorization' => HTTPAuth::Basic.pack_authorization(YOUR_APP_ID, YOUR_SECRET)
    'Authorization' => "Basic #{AUTHORIZATION_BASE64_PACK}"
    }
    }

  2. @yokoji yokoji revised this gist Jun 25, 2014. 1 changed file with 9 additions and 4 deletions.
    13 changes: 9 additions & 4 deletions api_v1_01_introduction.md
    Original file line number Diff line number Diff line change
    @@ -20,20 +20,25 @@

    ## 仕様

    ### エンドポイント
    ### APIエンドポイント

    https://api.freee.co.jp/ (httpsのみ)

    * authorize : /oauth/authorize
    * token : /oauth/token


    ### 認証

    [OAuth2][oauth2]に対応
    - Authorization Code Flow (Webアプリ向け)
    - Implicit Flow (Mobileアプリ向け)

    #### エンドポイント

    https://secure.freee.co.jp/ (httpsのみ)

    * authorize : /oauth/authorize
    * token : /oauth/token


    ### データフォーマット

    リクエスト、レスポンスともにJSON形式をサポート
  3. @yokoji yokoji revised this gist Jun 16, 2014. 1 changed file with 2 additions and 4 deletions.
    6 changes: 2 additions & 4 deletions api_v1_01_introduction.md
    Original file line number Diff line number Diff line change
    @@ -20,16 +20,14 @@

    ## 仕様

    ### OAuthエンドポイント


    ### APIエンドポイント
    ### エンドポイント

    https://api.freee.co.jp/ (httpsのみ)

    * authorize : /oauth/authorize
    * token : /oauth/token


    ### 認証

    [OAuth2][oauth2]に対応
  4. @yokoji yokoji revised this gist Jun 16, 2014. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion api_v1_01_introduction.md
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,10 @@

    ## 仕様

    ### エンドポイント
    ### OAuthエンドポイント


    ### APIエンドポイント

    https://api.freee.co.jp/ (httpsのみ)

  5. @yokoji yokoji revised this gist Dec 15, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion api_v1_01_introduction.md
    Original file line number Diff line number Diff line change
    @@ -72,4 +72,4 @@ Authorization Code Flowでユーザ情報、事業所情報を取得するまで

    ご不明点、ご要望等は以下までご連絡ください。

    dev-core@freee.co.jp
    dev-support@freee.co.jp
  6. @yokoji yokoji revised this gist Oct 10, 2013. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion api_v1_01_introduction.md
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,10 @@

    ### エンドポイント

    https://api.freee.co.jp/api/v1 (httpsのみ)
    https://api.freee.co.jp/ (httpsのみ)

    * authorize : /oauth/authorize
    * token : /oauth/token

    ### 認証

  7. @yokoji yokoji revised this gist Oct 9, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion api_v1_01_introduction.md
    Original file line number Diff line number Diff line change
    @@ -41,7 +41,7 @@ https://api.freee.co.jp/api/v1 (httpsのみ)
    1. [freee][freee]にサインアップします。
    2. [アプリケーション一覧][oauth_app]から「新しいアプリケーションを登録」します。
    3. アプリケーションの登録が完了すると、AppIDとSecretが取得できます。
    4. テスト環境では、認証用URLを直打ちしてAuthorization Codeを取得できます。
    4. ローカルの開発環境でテストする際は、認証用URLを直打ちしてAuthorization Codeを取得できます。

    [freee]: https://secure.freee.co.jp/
    [oauth_app]: https://secure.freee.co.jp/oauth/applications
  8. @yokoji yokoji revised this gist Oct 9, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion api_v1_01_introduction.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # freee API v1.0

    全自動クラウド会計ソフトfeeeの開発者向けAPIのドキュメントです
    全自動クラウド会計ソフトfreeeの開発者向けAPIのドキュメントです

    ## 概要

  9. @yokoji yokoji revised this gist Oct 9, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions api_v1_01_introduction.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # freee API v1.0

    全自動クラウド会計ソフトfeeeのAPIです
    全自動クラウド会計ソフトfeeeの開発者向けAPIのドキュメントです

    ## 概要

    @@ -67,6 +67,6 @@ Authorization Code Flowでユーザ情報、事業所情報を取得するまで

    ## 連絡先

    不明点、要望等は以下までご連絡ください
    ご不明点、ご要望等は以下までご連絡ください

    [email protected]
  10. @yokoji yokoji revised this gist Oct 9, 2013. 1 changed file with 29 additions and 5 deletions.
    34 changes: 29 additions & 5 deletions api_v1_01_introduction.md
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,22 @@

    ## 概要

    本APIを利用することで、あなたのアプリやサービスをfreeeと連携させることができます。

    ### 提供機能(2013/10/10現在)

    * ユーザ情報の取得
    * 事業所情報の取得
    * 取引(収入・支出・振替)の照会/登録
    * 口座明細の照会/登録
    * 取引先の照会/登録
    * 品目の照会/登録
    * 勘定科目の照会
    * 税区分の照会
    * 口座情報の照会

    ## 仕様

    ### エンドポイント

    https://api.freee.co.jp/api/v1 (httpsのみ)
    @@ -20,7 +36,7 @@ https://api.freee.co.jp/api/v1 (httpsのみ)

    [oauth2]: http://tools.ietf.org/html/rfc6749

    ## Quick Start
    ## はじめに

    1. [freee][freee]にサインアップします。
    2. [アプリケーション一覧][oauth_app]から「新しいアプリケーションを登録」します。
    @@ -30,19 +46,27 @@ https://api.freee.co.jp/api/v1 (httpsのみ)
    [freee]: https://secure.freee.co.jp/
    [oauth_app]: https://secure.freee.co.jp/oauth/applications

    ## API Reference
    ## APIリファレンス

    https://secure.freee.co.jp/developers/api/doc

    ## Sample
    ## サンプル実装 (Ruby)

    Authorization Code Flowでユーザ情報、事業所情報を取得するまでのRubyの実装例です
    Authorization Code Flowでユーザ情報、事業所情報を取得するまでの実装例です

    * 使用する外部ライブラリ
    - oauth2
    - faraday
    - faraday_middleware

    ## Contact
    ## 注意点

    * 本機能は現在β版として運用しており、予告なく新規APIが追加されることがありますのでご了承ください。

    * APIのパラメータ等が変更になる場合は、バージョンを更新して提供いたします。

    ## 連絡先

    不明点、要望等は以下までご連絡ください。

    [email protected]
  11. @yokoji yokoji revised this gist Oct 9, 2013. 2 changed files with 12 additions and 7 deletions.
    17 changes: 11 additions & 6 deletions api_v1_01_introduction.md
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,22 @@
    # freee API v1.0 draft
    # freee API v1.0

    全自動クラウド会計ソフトfeeeのAPIです。

    ## Notes
    ## 概要

    * 認証は[OAuth2][oauth2]に対応
    ### エンドポイント

    https://api.freee.co.jp/api/v1 (httpsのみ)

    ### 認証

    [OAuth2][oauth2]に対応
    - Authorization Code Flow (Webアプリ向け)
    - Implicit Flow (Mobileアプリ向け)

    * 通信はHTTPSのみ
    ### データフォーマット

    * データフォーマットはJSON
    - Content-Type: 'application/json'
    リクエスト、レスポンスともにJSON形式をサポート

    [oauth2]: http://tools.ietf.org/html/rfc6749

    2 changes: 1 addition & 1 deletion api_v1_02_example.rb
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    # Initialize

    options = {
    site: 'https://secure.freee.co.jp',
    site: 'https://api.freee.co.jp',
    authorize_url: '/oauth/authorize',
    token_url: '/oauth/token'
    }
  12. @yokoji yokoji revised this gist Sep 14, 2013. 2 changed files with 25 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion api_v1_01_introduction.md
    Original file line number Diff line number Diff line change
    @@ -31,7 +31,7 @@ https://secure.freee.co.jp/developers/api/doc

    ## Sample

    Authorization Code Flowでユーザ情報を取得するまでのRubyの実装例です
    Authorization Code Flowでユーザ情報、事業所情報を取得するまでのRubyの実装例です

    * 使用する外部ライブラリ
    - oauth2
    25 changes: 24 additions & 1 deletion api_v1_02_example.rb
    Original file line number Diff line number Diff line change
    @@ -35,7 +35,7 @@

    # GET /api/1/users/me

    access_token.get('/api/1/users/me').response.env[:body]
    access_token.get('/api/1/users/me?companies=true').response.env[:body]
    # {
    # "user" =>
    # {
    @@ -45,5 +45,28 @@
    # "last_name" => "freee",
    # "first_name_kana" => "たろう",
    # "last_name_kana"=> "ふりー"
    # "companies" =>
    # {
    # "id" => "12345",
    # "display_name" => "freee株式会社",
    # "role" => "default"
    # }
    # }
    # }

    # GET /api/1/companies/:id

    access_token.get('/api/1/companies/12345?details=true').response.env[:body]
    # {
    # "company" =>
    # {
    # "id" => 12345,
    # "name" => "freee株式会社,
    # "name_kana" => "ふりーかぶしきがいしゃ",
    # "display_name"=> "freeeカブシキガイシャ",
    # "role" => "default",
    # "account_items" => {...},
    # "taxes" => {...},
    # "items" => {...},
    # "partners" => {...}
    # }
  13. @yokoji yokoji revised this gist Sep 14, 2013. 2 changed files with 8 additions and 3 deletions.
    7 changes: 6 additions & 1 deletion api_v1_01_introduction.md
    Original file line number Diff line number Diff line change
    @@ -31,7 +31,12 @@ https://secure.freee.co.jp/developers/api/doc

    ## Sample

    Authorization Code Flowでユーザ情報を取得するまでのRubyの実装例。
    Authorization Code Flowでユーザ情報を取得するまでのRubyの実装例です。

    * 使用する外部ライブラリ
    - oauth2
    - faraday
    - faraday_middleware

    ## Contact

    4 changes: 2 additions & 2 deletions api_v1_02_example.rb
    Original file line number Diff line number Diff line change
    @@ -29,13 +29,13 @@
    }
    }

    token = client.auth_code.get_token(AUTHORIZATION_CODE, params).token
    token = client.get_token(params).token

    access_token = OAuth2::AccessToken.new(client, token)

    # GET /api/1/users/me

    access_token.get('/api/1/users/me').response.env[:body]
    access_token.get('/api/1/users/me').response.env[:body]
    # {
    # "user" =>
    # {
  14. @yokoji yokoji revised this gist Sep 14, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion api_v1_02_example.rb
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,7 @@
    params = {
    grant_type: 'authorization_code',
    code: AUTHORIZATION_CODE,
    redirect_uri: REDIRECT_URI,
    redirect_uri: YOUR_REDIRECT_URI,
    headers: {
    'Content-Type' => 'application/json',
    'Authorization' => HTTPAuth::Basic.pack_authorization(YOUR_APP_ID, YOUR_SECRET)
  15. @yokoji yokoji revised this gist Sep 14, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion api_v1_01_introduction.md
    Original file line number Diff line number Diff line change
    @@ -35,4 +35,4 @@ Authorization Code Flowでユーザ情報を取得するまでのRubyの実装

    ## Contact

    freee開発チーム [email protected]
    [email protected]
  16. @yokoji yokoji revised this gist Sep 14, 2013. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions api_v1_01_introduction.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@

    * 認証は[OAuth2][oauth2]に対応
    - Authorization Code Flow (Webアプリ向け)
    - Implicit Flow (Mobile向け)
    - Implicit Flow (Mobileアプリ向け)

    * 通信はHTTPSのみ

    @@ -31,4 +31,8 @@ https://secure.freee.co.jp/developers/api/doc

    ## Sample

    Authorization Code Flowでユーザ情報を取得するまでのRubyの実装例。
    Authorization Code Flowでユーザ情報を取得するまでのRubyの実装例。

    ## Contact

    freee開発チーム [email protected]
  17. @yokoji yokoji revised this gist Sep 13, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion api_v1_01_introduction.md
    Original file line number Diff line number Diff line change
    @@ -31,4 +31,4 @@ https://secure.freee.co.jp/developers/api/doc

    ## Sample

    * Authorization Code Flowでユーザ情報を取得するまでのRubyの実装例。
    Authorization Code Flowでユーザ情報を取得するまでのRubyの実装例。
  18. @yokoji yokoji revised this gist Sep 13, 2013. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions api_v1_01_introduction.md
    Original file line number Diff line number Diff line change
    @@ -20,11 +20,15 @@
    1. [freee][freee]にサインアップします。
    2. [アプリケーション一覧][oauth_app]から「新しいアプリケーションを登録」します。
    3. アプリケーションの登録が完了すると、AppIDとSecretが取得できます。
    4. テスト環境では、認証用URLを直打ちしてAuthorization Codeを取得することができます
    4. テスト環境では、認証用URLを直打ちしてAuthorization Codeを取得できます

    [freee]: https://secure.freee.co.jp/
    [oauth_app]: https://secure.freee.co.jp/oauth/applications

    ## API Reference

    https://secure.freee.co.jp/developers/api/doc

    ## Sample

    * Authorization Code Flowでユーザ情報を取得するまでの例をRubyで載せています
    * Authorization Code Flowでユーザ情報を取得するまでのRubyの実装例
  19. @yokoji yokoji revised this gist Sep 13, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions api_v1_01_introduction.md
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@
    ## Quick Start

    1. [freee][freee]にサインアップします。
    2. [アプリケーション一覧][applications]から「新しいアプリケーションを登録」します。
    2. [アプリケーション一覧][oauth_app]から「新しいアプリケーションを登録」します。
    3. アプリケーションの登録が完了すると、AppIDとSecretが取得できます。
    4. テスト環境では、認証用URLを直打ちしてAuthorization Codeを取得することができます。

    @@ -27,4 +27,4 @@

    ## Sample

    * Authorization Code Flowの例をRubyで載せています
    * Authorization Code Flowでユーザ情報を取得するまでの例をRubyで載せています
  20. @yokoji yokoji revised this gist Sep 13, 2013. 3 changed files with 30 additions and 5 deletions.
    30 changes: 30 additions & 0 deletions api_v1_01_introduction.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    # freee API v1.0 draft

    全自動クラウド会計ソフトfeeeのAPIです。

    ## Notes

    * 認証は[OAuth2][oauth2]に対応
    - Authorization Code Flow (Webアプリ向け)
    - Implicit Flow (Mobile向け)

    * 通信はHTTPSのみ

    * データフォーマットはJSON
    - Content-Type: 'application/json'

    [oauth2]: http://tools.ietf.org/html/rfc6749

    ## Quick Start

    1. [freee][freee]にサインアップします。
    2. [アプリケーション一覧][applications]から「新しいアプリケーションを登録」します。
    3. アプリケーションの登録が完了すると、AppIDとSecretが取得できます。
    4. テスト環境では、認証用URLを直打ちしてAuthorization Codeを取得することができます。

    [freee]: https://secure.freee.co.jp/
    [oauth_app]: https://secure.freee.co.jp/oauth/applications

    ## Sample

    * Authorization Code Flowの例をRubyで載せています。
    File renamed without changes.
    5 changes: 0 additions & 5 deletions introduction.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +0,0 @@
    # freee API v1.0 draft

    ## Quick Start

    ## Notes
  21. @yokoji yokoji revised this gist Sep 13, 2013. 2 changed files with 0 additions and 0 deletions.
    File renamed without changes.
    File renamed without changes.
  22. @yokoji yokoji created this gist Sep 13, 2013.
    49 changes: 49 additions & 0 deletions example
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    require 'oauth2'
    require 'faraday'
    require 'faraday_middleware'

    # Initialize

    options = {
    site: 'https://secure.freee.co.jp',
    authorize_url: '/oauth/authorize',
    token_url: '/oauth/token'
    }

    client = OAuth2::Client.new(YOUR_APP_ID, YOUR_SECRET, options) do |conn|
    conn.request :url_encoded
    conn.request :json
    conn.response :json, content_type: /\bjson$/
    conn.adapter Faraday.default_adapter
    end

    # Getting authorized

    params = {
    grant_type: 'authorization_code',
    code: AUTHORIZATION_CODE,
    redirect_uri: REDIRECT_URI,
    headers: {
    'Content-Type' => 'application/json',
    'Authorization' => HTTPAuth::Basic.pack_authorization(YOUR_APP_ID, YOUR_SECRET)
    }
    }

    token = client.auth_code.get_token(AUTHORIZATION_CODE, params).token

    access_token = OAuth2::AccessToken.new(client, token)

    # GET /api/1/users/me

    access_token.get('/api/1/users/me').response.env[:body]
    # {
    # "user" =>
    # {
    # "email" => "[email protected]",
    # "display_name" => "freee太郎,
    # "first_name" => "太郎",
    # "last_name" => "freee",
    # "first_name_kana" => "たろう",
    # "last_name_kana"=> "ふりー"
    # }
    # }
    5 changes: 5 additions & 0 deletions introduction
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    # freee API v1.0 draft

    ## Quick Start

    ## Notes