> For the complete documentation index, see [llms.txt](https://mach-4.gitbook.io/mach/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mach-4.gitbook.io/mach/protocol/api.md).

# API

## Endpoints for Trial and Usage

### **Where Can I Trial the Endpoints?**

You can trial the endpoints at the following link: [API Documentation and Testing](https://cache-half-full-staging.fly.dev/docs#/default/get_routes_get_routes_get)

### **Endpoints Used by the Front-End**

The front-end interacts with several key endpoints to ensure smooth operation and user experience. Here’s how these endpoints are utilized:

**On Load: Reading Available Chains and Assets**

* **Endpoint:** `get_config`
* **Description:** On load, the front-end reads the available chains and assets from the configuration to present the user with the latest options.

**Estimating Gas Costs**

* **Endpoint:** `estimate_gas`
* **Description:** When a user specifies the send token and buy token, the front-end estimates the gas cost for the transaction.

**Placing a Trade**

* **Endpoint:** `PlaceTrade`
* **Description:** When a user places a trade using MetaMask, the front-end retrieves the price and fee from the following endpoints:
  * **get\_price:** Retrieves the current price for the trade.
  * **get\_fee:** Retrieves the applicable fee for the trade.

**Order Clearing and Backend Fix**

* **Endpoint:** `make_order`
* **Description:** Immediately after the order has cleared on the source chain, this endpoint is called to have the backend finalize and fix the order.

**Displaying Order History**

* **Endpoint:** `get_orders`
* **Description:** After the trade is complete, the front-end uses this endpoint to display the user's order history.
