# Algorand REST APIs

## Algod, Indexer and KMD REST Endpoints

Integration with the Algorand protocol daemon (`algod`), Algorand key management daemon (`kmd`) or Algorand Indexer daemon (`algorand-indexer`) is performed using a set of REST APIs.

All REST methods and models are fully described within reference documentation.

- [Algod REST APIs](https://dev.algorand.co/reference/rest-api/algod)
- [Indexer REST APIs](https://dev.algorand.co/reference/rest-api/indexer)
- [KMD REST APIs](https://dev.algorand.co/reference/rest-api/kmd)

### Algod REST Endpoints

[Algod REST Endpoints OAS3 spec file](https://github.com/algorand/go-algorand/blob/master/daemon/algod/api/algod.oas3.yml?raw=true)(.yml)

[Algod REST Endpoints OAS2 spec file](https://github.com/algorand/go-algorand/blob/master/daemon/algod/api/algod.oas2.json?raw=true)

### Indexer REST Endpoints

The `algorand-indexer` daemon provides its API from the _host:port_ defined by the _—server_ flag specified at start up. The default port is 8980.

[Indexer REST Endpoints OAS3 spec file](https://www.github.com/algorand/indexer/blob/develop/api/indexer.oas3.yml?raw=true)(.yml)

[Indexer REST Endpoints OAS2 spec file](https://github.com/algorand/indexer/blob/develop/api/indexer.oas2.json?raw=true)

### KMD REST Endpoints

This API is described using the [Open API Specification version 2 (OAS 2)](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md). The `kmd` daemon serves its API from the _kmd.net_ files found in the _~/node/data_ and _~/node/data/kmd-{version}_ directories. The `kmd` daemons provide their API specifications in a [swagger json](https://github.com/algorand/go-algorand/blob/master/daemon/kmd/api/swagger.json) format available from this endpoint:

Algorand Key Management Daemon (`kmd`)

```
curl http://$(cat ~/node/data/kmd-v0.5/kmd.net)/swagger.json
```

## Security Token

Most REST calls will also require an API token header to authenticate with the API server. For both `algod` and `kmd` the token is automatically generated by the daemon at startup and stored in a file. `algod` places _algod.token_ in the _~/node/data_ directory. `kmd` places _kmd.token_ the _~/node/data/kmd-{version}_ directory. Security tokens can be regenerated for both using the `goal node generatetoken` command.

| Daemon | Header Identifier | Header Value Defined Via |
| --- | --- | --- |
| `algod` | X-Algo-API-Token | file: ~/node/data/algod.token |
| `kmd` | X-KMD-API-Token | file: ~/node/data/kmd-{version}/kmd.token |
| `indexer` | X-Indexer-API-Token |  |

Each SDK provides a method for setting these headers. Most REST tools provide a method for setting additional headers. To set the header with a `curl` command use the `-H` parameter. For example, to make a call to retrieve a specific block, use the following curl command:

```
curl http://$(cat ~/node/data/algod.net)/v2/blocks/16486179 -H "X-Algo-API-Token: $(cat ~/node/data/algod.token)"
```

In the above example, the block information will be displayed if the block exists on the local node. If the node is a non-Archival node, blocks older than 1000 blocks will not be available.
