> ## Documentation Index
> Fetch the complete documentation index at: https://developer.box.com/llms.txt
> Use this file to discover all available pages before exploring further.

> Boxの無料Developerアカウントにサインアップし、開発者トークンを生成して、最初のAPIコールを行います。

# クイックスタート

export const SignupCTA = ({children}) => {
  return <div className="flex flex-wrap items-center gap-4 p-5 rounded-lg border border-gray-200 dark:border-gray-700 my-6" style={{
    background: "linear-gradient(135deg, rgba(0, 97, 213, 0.06), rgba(0, 97, 213, 0.02))"
  }}>
      <div className="flex-1 text-sm leading-relaxed text-gray-700 dark:text-gray-300" style={{
    minWidth: "280px"
  }}>
        {children}
      </div>
      <div className="flex flex-col items-center gap-2">
        <a href="https://account.box.com/signup/developer#ty9l3" className="signup-cta-button inline-flex items-center whitespace-nowrap px-5 py-2 text-sm font-semibold text-white no-underline">
          {translate("Get started for free")}
        </a>
        <a href="https://account.box.com/developers/console" className="signup-cta-login text-xs text-gray-500 dark:text-gray-400 no-underline whitespace-nowrap">
          {translate("Already have an account? Log in")}
        </a>
      </div>
    </div>;
};

export const Link = ({href, children, className, ...props}) => {
  const localizedHref = localizeLink(href);
  return <a href={localizedHref} className={className} {...props}>
      {children}
    </a>;
};

[Box](https://www.box.com)は、どこからでもコンテンツの保存、アクセス、コラボレーションが行える、クラウドベースのインテリジェントなコンテンツ管理およびファイル共有プラットフォームです。

## 無料アカウントへのサインアップ

<SignupCTA>
  無料のDeveloperアカウントを作成すると、開発者コンソール、API、AIユニットにアクセスできるようになり、各開発者向けガイドに沿って作業を進めるために必要なものがすべて揃います。
</SignupCTA>

お使いのメールアドレスを確認し、Developerアカウントを有効にしてください。

## Boxにファイルをアップロードし、ルートフォルダ内のすべてのファイルのリストを取得する

[ファイルをアップロード](/reference/post-files-content)エンドポイントを使用すると、アップロードドメイン`https://upload.box.com/api/2.0/files/content`を通じて、Boxに1つのファイルをアップロードできます。

<Note>
  ファイルサイズの上限は50 MBです。ファイルがこれより大きい場合は、<Link href="/guides/uploads/chunked">分割アップロードAPI</Link>を使用してください。
</Note>

すぐに使い始められるよう、構築済みのアプリケーションが用意されています。リクエストを認証するための開発者トークンを作成します。[開発者コンソール](https://cloud.app.box.com/developers/console)から構築済みアプリケーションに移動し、\[**アプリの詳細**] セクションを探します。\[**開発者トークン**] フィールドを見つけ、\[**開発者トークンの生成**] を選択して、トークンをコピーします。

<img src="https://mintcdn.com/box/-dfq8BkD33WRZ8AY/images/guides/getting-started/app-details.png?fit=max&auto=format&n=-dfq8BkD33WRZ8AY&q=85&s=2050a97e6ad0a8cd51974da31d33a8c0" alt="アプリの詳細" width="344" height="372" data-path="images/guides/getting-started/app-details.png" />

<Warning>
  開発者トークンは、生成から1時間後に期限切れになります。
</Warning>

アップロード用の請求書サンプルが用意されています。プロジェクトのルートフォルダを作成したら、<Link href="/static/quickstarts/extract/files/demo-invoice-20tax-2.pdf">こちら</Link>からサンプルをダウンロードし、フォルダに保存してください。

<Tabs>
  <Tab title="Python">
    Pythonの仮想環境を作成してアクティブ化します。

    ```shell theme={null}
    python3 -m venv .venv
    source .venv/bin/activate
    ```

    <Link href="https://pypi.org/project/pip/">pip</Link>を使用して、次のコマンドを実行し、Box Python SDKをインストールします。

    ```shell theme={null}
    pip install "boxsdk>=10"
    ```

    <Note>
      必ずPython SDKの最新版を使用してください。詳細については、<Link href="https://pypi.org/project/boxsdk/">Python SDKのオープンソースページ</Link>を参照してください。
    </Note>

    開発者トークンで`client`を取得します。

    ```python theme={null}
    from box_sdk_gen import BoxClient, BoxDeveloperTokenAuth, UploadFileAttributes, UploadFileAttributesParentField
    import json

    auth = BoxDeveloperTokenAuth(token="YOUR_DEVELOPER_TOKEN")
    client = BoxClient(auth=auth)
    ```

    <Warning>
      本番環境のコードベースの場合には、必ず資格情報を`.env`ファイルに保存したうえで、`.gitignore`に`.env`を追加してください。
    </Warning>

    次に、以下のようにアップロードAPIを呼び出します。

    ```python theme={null}
    with open("demo-invoice-20tax-2.pdf", "rb") as file_content_stream:
        uploaded_file = client.uploads.upload_file(
            UploadFileAttributes(
                name="demo-invoice-20tax-2.pdf",
                parent=UploadFileAttributesParentField(id="0"),
            ),
            file_content_stream,
        )

    items = client.folders.get_folder_items("0")
    print(json.dumps(items.to_dict(), indent=2))
    ```

    `get_folder_items`コマンドは、ルートフォルダ内にあるすべてのファイルのリストを取得するものです。このスクリプトを実行してファイルをアップロードし、すべてのファイルのリストを取得します。
  </Tab>

  <Tab title="Node.js">
    <Link href="https://www.npmjs.com/package/box">npm</Link>を使用して、次のコマンドを実行し、Box Node.js SDKをインストールします。[box](/guides/tooling/box-npm-package)パッケージはBox Node SDKと[Box CLI](/guides/cli)を直接的な依存関係としてインストールします。Node.js 22以降が必要です。

    ```shell theme={null}
    npm install box
    ```

    <Info>
      既存のプロジェクトでは引き続き`npm install box-node-sdk`を使用できます。このパッケージはまだサポートされています。
    </Info>

    SDKをインポートします。

    ```javascript theme={null}
    import BoxSDK from 'box/sdk';  // ESM
    const BoxSDK = require('box/sdk');  // CommonJS
    ```

    すぐに使い始められるよう、構築済みのアプリケーションが用意されています。リクエストを認証するための開発者トークンを作成します。[開発者コンソール](https://cloud.app.box.com/developers/console)から構築済みアプリケーションに移動し、\[**アプリの詳細**] セクションを探します。\[**開発者トークン**] フィールドを見つけ、\[**開発者トークンの生成**] を選択して、トークンをコピーします。

    開発者トークンで`client`を取得します。

    ```javascript theme={null}
    const { BoxClient, BoxDeveloperTokenAuth } = require('box/sdk');
    const auth = new BoxDeveloperTokenAuth({ token: 'YOUR_DEVELOPER_TOKEN' });
    const client = new BoxClient({ auth });
    ```

    <Warning>
      開発者トークンは、生成から1時間後に期限切れになります。
    </Warning>

    ```javascript theme={null}
    const fs = require('fs');

    const attrs = { name: 'demo-invoice-20tax-2.pdf', parent: { id: '0' } };
    const body = {
      attributes: attrs,
      file: fs.createReadStream('demo-invoice-20tax-2.pdf'),
    };
    const files = await client.uploads.uploadFile(body);
    const file = files.entries[0];
    console.log(`File uploaded with id ${file.id}, name ${file.name}`);

    const items = await client.folders.getFolderItems('0');
    console.log(JSON.stringify(items, null, 2));
    ```

    `getFolderItems`コマンドは、ルートフォルダ内にあるすべてのファイルのリストを取得するものです。このスクリプトを実行してファイルをアップロードし、すべてのファイルのリストを取得します。
  </Tab>

  <Tab title="Swift">
    <Link href="https://github.com/box/box-swift-sdk-gen">Swift Package Manager</Link>を使用して、次のコマンドを実行し、Box Swift SDKをインストールします。

    ```shell theme={null}
    swift package update
    ```

    すぐに使い始められるよう、構築済みのアプリケーションが用意されています。リクエストを認証するための開発者トークンを作成します。[開発者コンソール](https://cloud.app.box.com/developers/console)から構築済みアプリケーションに移動し、\[**アプリの詳細**] セクションを探します。\[**開発者トークン**] フィールドを見つけ、\[**開発者トークンの生成**] を選択して、トークンをコピーします。

    <Warning>
      開発者トークンは、生成から1時間後に期限切れになります。
    </Warning>

    開発者トークンで`client`を取得します。

    ```swift theme={null}
    import BoxSdkGen

    let auth = BoxDeveloperTokenAuth(token: "YOUR_DEVELOPER_TOKEN")
    let client = BoxClient(auth: auth)
    ```

    必要なパラメータを含むリクエスト本文を作成します。パラメータとして属性 (`name`および`parent id`) とファイルストリームを指定します。

    ```swift theme={null}
    guard let fileStream = InputStream(url: URL(fileURLWithPath: "demo-invoice-20tax-2.pdf")) else {
        fatalError("Could not read a file")
    }

    let requestBody = UploadFileRequestBody(
        attributes: UploadFileRequestBodyAttributesField(
            name: "demo-invoice-20tax-2.pdf",
            parent: UploadFileRequestBodyAttributesParentField(id: "0")
        ),
        file: fileStream
    )

    let files = try await client.uploads.uploadFile(requestBody: requestBody)

    if let file = files.entries?[0] {
        print("File uploaded with id \(file.id), name \(file.name!)")
    }

    let items = try await client.folders.getFolderItems(folderId: "0")
    if let entries = items.entries {
        for entry in entries {
            switch entry {
            case let .fileMini(file):
                print("file \(file.name!) [\(file.id)]")
            case let .folderMini(folder):
                print("folder \(folder.name!) [\(folder.id)]")
            case let .webLinkMini(webLink):
                print("webLink \(webLink.name!) [\(webLink.id)]")
            }
        }
    }
    ```

    `getFolderItems`コマンドは、ルートフォルダ内にあるすべてのファイルのリストを取得するものです。このスクリプトを実行してファイルをアップロードし、すべてのファイルのリストを取得します。
  </Tab>

  <Tab title="Java">
    すぐに使い始められるよう、構築済みのアプリケーションが用意されています。リクエストを認証するための開発者トークンを作成します。[開発者コンソール](https://cloud.app.box.com/developers/console)から構築済みアプリケーションに移動し、\[**アプリの詳細**] セクションを探します。\[**開発者トークン**] フィールドを見つけ、\[**開発者トークンの生成**] を選択して、トークンをコピーします。

    <Warning>
      開発者トークンは、生成から1時間後に期限切れになります。
    </Warning>

    **Gradle**

    `build.gradle`ファイルに以下の依存関係を追加して、Box Java SDKをインストールします。

    ```shell theme={null}
    implementation 'com.box:box-java-sdk:10.9.0'
    ```

    <Info>
      必ず最新バージョン番号のJava SDKを使用してください。詳細については、<Link href="https://opensource.box.com/box-java-sdk/">Java SDKのオープンソースページ</Link>を参照してください。
    </Info>

    **Maven**

    以下をMaven依存関係に追加します。

    ```xml theme={null}
    <dependency>
        <groupId>com.box</groupId>
        <artifactId>box-java-sdk</artifactId>
        <version>10.9.0</version>
    </dependency>
    ```

    開発者トークンで`client`を取得します。

    ```java theme={null}
    BoxDeveloperTokenAuth auth = new BoxDeveloperTokenAuth("YOUR_DEVELOPER_TOKEN");
    BoxClient client = new BoxClient(auth);
    ```

    **`new UploadFileRequestBody`**を**`client.getUploads().uploadFile`**に渡します。属性 (名前を表す**`UploadFileRequestBodyAttributesField`**とフォルダIDを表す**`UploadFileRequestBodyAttributesParentField`**) と、ファイルのバイトを表す**`InputStream`**を指定します。

    ```java theme={null}
    FileInputStream fileContentStream = new FileInputStream("demo-invoice-20tax-2.pdf");
    client.getUploads().uploadFile(
        new UploadFileRequestBody(
            new UploadFileRequestBodyAttributesField(
                "demo-invoice-20tax-2.pdf",
                new UploadFileRequestBodyAttributesParentField("0")
            ),
            fileContentStream
        )
    );

    client.getFolders().getFolderItems("0").getEntries().forEach(item -> {
        System.out.println(item);
    });
    ```

    `getFolderItems`コマンドは、ルートフォルダ内にあるすべてのファイルのリストを取得するものです。このスクリプトを実行してファイルをアップロードし、すべてのファイルのリストを取得します。
  </Tab>

  <Tab title=".NET">
    **.NET Framework**

    .NET Frameworkに.NET SDKをインストールするには、<Link href="https://www.nuget.org/packages/Box.V2.Core">Nuget</Link>パッケージマネージャを使用して以下のコマンドを実行します。

    ```shell theme={null}
    PM> Install-Package Box.V2.Core
    ```

    すぐに使い始められるよう、構築済みのアプリケーションが用意されています。リクエストを認証するための開発者トークンを作成します。[開発者コンソール](https://cloud.app.box.com/developers/console)から構築済みアプリケーションに移動し、\[**アプリの詳細**] セクションを探します。\[**開発者トークン**] フィールドを見つけ、\[**開発者トークンの生成**] を選択して、トークンをコピーします。

    <Warning>
      開発者トークンは、生成から1時間後に期限切れになります。
    </Warning>

    **.NET Core**

    .NET Coreフレームワークに.NET SDKをインストールするには、<Link href="https://www.nuget.org/packages/Box.V2.Core">Nuget</Link>パッケージマネージャを使用して以下のコマンドを実行します。

    ```shell theme={null}
    PM> Install-Package Box.V2.Core
    ```

    開発者トークンで`client`を取得します。

    ```csharp theme={null}
    using Box.Sdk.Gen;

    var auth = new BoxDeveloperTokenAuth(token: "YOUR_DEVELOPER_TOKEN");
    var client = new BoxClient(auth: auth);
    ```

    **`new UploadFileRequestBody`**を使用して**`client.Uploads.UploadFileAsync`**を待機します。**`UploadFileRequestBodyAttributesField`** (`name`と`parent id`)、および**`Stream`** (例: **`File.OpenRead`**から)。

    ```csharp theme={null}
    using var fileContentStream = File.OpenRead("demo-invoice-20tax-2.pdf");
    var files = await client.Uploads.UploadFileAsync(
        requestBody: new UploadFileRequestBody(
            attributes: new UploadFileRequestBodyAttributesField(
                name: "demo-invoice-20tax-2.pdf",
                parent: new UploadFileRequestBodyAttributesParentField(id: "0")),
            file: fileContentStream));
    var file = files.Entries[0];
    Console.WriteLine($"File uploaded with id {file.Id}, name {file.Name}");

    var items = await client.Folders.GetFolderItemsAsync(folderId: "0");
    if (items.Entries != null)
    {
        foreach (var item in items.Entries)
        {
            if (item.FileFull != null)
            {
                Console.WriteLine(item.FileFull.Name);
            }
            else if (item.FolderMini != null)
            {
                Console.WriteLine(item.FolderMini.Name);
            }
            else if (item.WebLink != null)
            {
                Console.WriteLine(item.WebLink.Name);
            }
        }
    }
    ```

    `getFolderItems`コマンドは、ルートフォルダ内にあるすべてのファイルのリストを取得するものです。このスクリプトを実行してファイルをアップロードし、すべてのファイルのリストを取得します。
  </Tab>
</Tabs>

これで、Boxに最初のファイルをアップロードし、ルートフォルダ内のすべてのファイルのリストを取得できました。

## ユースケース

Box Platformに適したユースケースかどうかがわからない場合には、以下を参考にしてください。以下のいずれかに該当する場合には、Box Platformが効果を発揮します。

* ユースケースの中核はコンテンツ
* プロセスにはコンテンツの移動が伴う
* ワークフローが[ウォーターフォール型の権限](https://docs.box.com/en/box-apps/box-apps-for-box-admins/box-apps-permissions#permissions)に準拠できる
* プロセスに自動化できる管理タスクが含まれている

お客様向けの一般的なソリューションには、以下のようなものがあります。

* マーケティング資産の管理
* ドキュメントの安全な保管庫
* 資産管理ポータル
* ユーザープロビジョニングに基づくフォルダの自動作成
* 機械学習を使用した関連メタデータの追加
* 組み込みの承認/拒否フローによるクレームレビュー
* セキュリティと監査のためのイベント監視

## 次のステップ

以下のリソースをご確認ください。

* [無料の開発者プランで利用できる機能](/platform/free-developer-plan)
* [認証方法](/guides/authentication/select): 利用可能なさまざまな認証方法を確認します。
* [Box CLI](/guides/cli): アプリケーションの作成に役立ちます。
* [Boxの用語集](/platform/box-glossary): Box Platformの主要な概念が解説されています。
* [変更ログ](/changelog/): 最新の変更内容を確認できます。
