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

# JSON RPC API - fsn-rpc-api

## FUSION JSON RPC API

FUSION RPC is compatible with Ethereum's [JSON-RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC) and [web3.js](https://github.com/ethereum/web3.js) API. In addition, FUSION's extended API include: Ticket, Asset, Timelock, USAN, Swap, Staking, etc.

## JSON RPC

[JSON](http://json.org/) is a lightweight data-interchange format. It can represent numbers, strings, ordered sequences of values, and collections of name/value pairs.

[JSON-RPC](http://www.jsonrpc.org/specification) is a stateless, light-weight remote procedure call (RPC) protocol. Primarily this specification defines several data structures and the rules around their processing. It is transport agnostic in that the concepts can be used within the same process, over sockets, over HTTP, or in many various message passing environments. It uses JSON ([RFC 4627](http://www.ietf.org/rfc/rfc4627.txt)) as data format.

## JavaScript API

To talk to an fusion node from inside a JavaScript application use the [web3.js](https://github.com/ethereum/web3.js) library, which gives a convenient interface for the RPC methods. FUSION's extended JavaScript API, See the [JavaScript API](https://fusionapi.readthedocs.io/) for more.

## JSON-RPC Endpoint

Online RPC service:

Testnet: <https://testnet.fsn.dev/api>

Mainnet: <https://fsn.dev/api>

Default JSON-RPC endpoints:

| Client | URL                                             |
| ------ | ----------------------------------------------- |
| Go     | [http://localhost:9000](http://localhost:9000/) |

You can start the HTTP JSON-RPC with the `--rpc` flag

```
efsn --rpc
```

change the default port (9000) and listing address (localhost) with:

```
efsn --rpc --rpcaddr <ip> --rpcport <portnumber>
```

If accessing the RPC from a browser, CORS will need to be enabled with the appropriate domain set. Otherwise, JavaScript calls are limit by the same-origin policy and requests will fail:

```
efsn --rpc --rpccorsdomain "http://localhost:9000"
```

The JSON RPC can also be started from the efsn console using the `admin.startRPC(addr, port)` command.

## Curl Examples Explained

The curl options below might return a response where the node complains about the content type, this is because the --data option sets the content type to application/x-www-form-urlencoded . If your node does complain, manually set the header by placing -H "Content-Type: application/json" at the start of the call.

The examples also do not include the URL/IP & port combination which must be the last argument given to curl e.x. 127.0.0.1:9000

## Read more

Find more details [here](https://github.com/fsn-dev/fsn-rpc-api/blob/master/fsn-rpc-api.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://fusiondev.gitbook.io/fusion/build/json-rpc-api-fsn-rpc-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
