# APIを使い始める

#### APIを使う

APIを使い始める前に、まずNMKR Studioで認証トークンまたはAPIキーを作成する必要があります。使用するネットワークに応じて、[testnetアカウントかmainnetアカウントのどちらかでAPI Keyを作成](https://docs.nmkr.io/nmkr-studio/account/api-keys)する必要があります。

{% hint style="warning" %}
リクエストの大半は、以下の要素の一部（またはすべて）を使用します：

* ベースURI、で構成される：
* ウェブアドレス
* APIバージョン
* 方法名
* プロジェクトUID
* NFT UID
* NFTカウント
* JSONペイロード
* リクエスト元IPアドレス
* その他の特定方法データ
* リクエスト・ヘッダのBEARER TOKENとしてのAPIキー

ほとんどの一般的な言語を使用して、コンピューターからAPIコールを実行することができますが、ウェブサイトのユーザーに呼び出させることを計画している場合は、サーバーフロントエンド/バックエンドの原則を使用してウェブサイトを確実にセットアップする必要があります。その理由は、ほとんどのブラウザがフロントエンドのUIからAPIコールを行おうとすると、単にブロックしてしまうからです（CORS Policy Error）。

{% endhint %}

{% hint style="info" %}
注意 - プロジェクトおよびNFTのUIDは、予測できないランダムな文字列になり、この追加のセキュリティ機能は、攻撃者がIDを「推測」できないことを意味し、APIキーが侵害された場合でも特定の攻撃をより困難にします。
{% endhint %}

{% hint style="danger" %}
注意 - APIキーは絶対に公開しないでください。もし公開した場合は、すぐに削除して新しいものを作成してください。
{% endhint %}

#### API URLテストネット(preprod)とメインネット

**テストネット（prepod）API**

```
https://studio-api.preprod.nmkr.io/v2/
```

#### メインネットAPI

```
https://studio-api.nmkr.io/v2/
```

#### CURLの例

```
curl -X 'GET' \
  'https://studio-api.nmkr.io/v2/endpoint/aaaaaaa-bbbb-cccc-dddd-eeeeeeeeee' \
  -H 'accept: text/plain' \
  -H 'Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxx'
```

### APIの使い方を学ぶ

APIエンドポイントをDAppやウェブサイトに実装する前に、[ API Swaggerで](https://docs.nmkr.io/nmkr-studio-api/api-swagger)テストしてみると良いでしょう。API Swaggerは[ Testnetだけ](https://docs.nmkr.io/nmkr-studio/testnet/testnet-api-swagger)でなく[ Mainnetでも](https://docs.nmkr.io/nmkr-studio-api/api-swagger)利用できます。<br>

{% embed url="<https://studio-api.nmkr.io/swagger/index.html>" %}

APIをテストするもう一つの非常に便利なツールはPostmanです。Postmanは、開発者がAPIを設計、構築、テスト、反復するためのAPIプラットフォームです。

{% embed url="<https://www.postman.com/>" %}

#### APIテンプレートと例

また、NMKR Studio APIの最も一般的な回避策や機能の[API例とテンプレートも](https://docs.nmkr.io/nmkr-studio-api/api-examples)提供しています。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.nmkr.io/jp/nmkr-studio-api/apiwoimeru.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
