# Usage

## Usage

Welcome to the **Anvil API Usage** page! This section outlines the different environments available to interact with the Cardano blockchain, utilizing Anvil’s infrastructure. Each environment caters to a specific stage of development, or type of deployment, so you can choose the one that aligns best with your goals.

### Why Multiple Environments?

Cardano supports multiple network “environments,” each intended for different purposes. These environments allow you to test without risking native ADA, preview upcoming features, or run production-grade services on the live (Mainnet) network.

Anvil provides separate endpoints for each environment to seamlessly move from experimentation to production while keeping the same API methods.

***

## Overview of Anvil Environments

Below is a list of our available endpoints and their corresponding Cardano environments, along with links to detailed documentation and interactive API reference (Swagger UI).

### Available Endpoints

| Environment                      | Endpoint                                         |
| -------------------------------- | ------------------------------------------------ |
| Mainnet                          | `https://prod.api.ada-anvil.app/v2/services/`    |
| Preprod                          | `https://preprod.api.ada-anvil.app/v2/services/` |
| Preview                          | `https://preview.api.ada-anvil.app/v2/services/` |
| Staging (Not for public use)     | `https://staging.api.ada-anvil.app/v2/services/` |
| Development (Not for public use) | `https://dev.api.ada-anvil.app/v2/services/`     |
| Test (Not for public use)        | `https://test.api.ada-anvil.app/v2/services/`    |
| Private Cluster                  | Contact Us for details                           |

**Note**: To access any of these endpoints, you must include your **API Key** in the request header. See the next page on Authentication for details on generating and using your API Key.

### Documentation Links

| Environment                      | Cardano Documentation                                                       | OpenAPI (Swagger)                                                      |
| -------------------------------- | --------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| Mainnet                          | [Mainnet Documentation](https://book.play.dev.cardano.org/env-mainnet.html) | [Swagger UI](https://prod.api.ada-anvil.app/v2/services/swagger/ui)    |
| Preprod                          | [Preprod Documentation](https://book.play.dev.cardano.org/env-preprod.html) | [Swagger UI](https://preprod.api.ada-anvil.app/v2/services/swagger/ui) |
| Preview                          | [Preview Documentation](https://book.play.dev.cardano.org/env-preview.html) | [Swagger UI](https://preview.api.ada-anvil.app/v2/services/swagger/ui) |
| Staging (Not for public use)     | -                                                                           | [Swagger UI](https://staging.api.ada-anvil.app/v2/services/swagger/ui) |
| Development (Not for public use) | -                                                                           | [Swagger UI](https://dev.api.ada-anvil.app/v2/services/swagger/ui)     |
| Test (Not for public use)        | -                                                                           | [Swagger UI](https://test.api.ada-anvil.app/v2/services/swagger/ui)    |
| Private Cluster                  | -                                                                           | -                                                                      |

***

### Choosing the Right Environment

* **Mainnet**
  * **Who It’s For**: Production-ready dApps, applications handling real ADA or NFTs, and live user interactions.
  * **Key Benefits**: Fully decentralized, real economic value, backed by Cardano’s production network.
  * **Potential Risks**: Transactions have real financial implications and network fees.
* **Preprod**
  * **Who It’s For**: Users testing smart contracts, token minting, or new features without risking actual ADA.
  * **Key Benefits**: Closely mimics Mainnet behavior, using test tokens (TestAda).
  * **Ideal Use Cases**: Finalizing a project’s functionality before going live.
* **Preview**
  * **Who It’s For**: Developers who want to experiment with upcoming Cardano features.
  * **Key Benefits**: See how new Cardano protocol changes may impact your code.
  * **Ideal Use Cases**: Testing compatibility with future network updates.
* **Private Cluster**
  * **Who It’s For**: Enterprise solutions requiring a dedicated environment, or specialized compliance needs.
  * **Key Benefits**: Customizable settings, enhanced privacy, and dedicated resources.
  * **How to Access**: Reach out to Anvil to discuss your specific requirements.
* **Development, Staging & Test (Internal)**
  * **Who It’s For**: Anvil’s internal testing, staging, and QA processes.
  * **Availability**: Not publicly accessible—used for advanced in-house development.

***

## Getting Started: Your First API Call

Once you have chosen an environment and [obtained your API key](/anvil-api/authentication.md), you can make your first request.

1. **Construct the Request**: Use the correct endpoint for your chosen environment from the table above.
2. **Include Your API Key**: Add the `X-Api-Key` header with your key.

Here is a basic example using cURL to check the health of the Preprod environment:

```bash
curl -X GET \
  -H "Content-Type: application/json" \
  -H "X-Api-Key: YOUR_API_KEY_HERE" \
  https://preprod.api.ada-anvil.app/v2/services/health
```

A successful request will return a JSON response confirming the service is operational.

***

## Next Steps

Now that you've made a successful call, you're ready to explore more complex features:

* **Dive Into Guides**: Check out the detailed guides (e.g., **Minting**, **Transactions**) in the sidebar.
* **Review Best Practices**: Read through our [Troubleshooting](/anvil-api/troubleshooting.md) and [FAQ](/anvil-api/faq.md) pages for common tips and solutions.

***

## Common Pitfalls

* **Mixing Environments**: Ensure your transaction details (like UTXOs), and wallets match the environment you are calling (e.g., don't use Mainnet assets on Preprod).
* **Forgetting the API Key**: Requests without a valid `X-Api-Key` header will be rejected.


---

# 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://dev.ada-anvil.io/anvil-api/usage.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.
