# Request quotes

## Goal

Request a quote from a stream (RFS).

## Prerequisites

- Your REST API app.
- Integral API login with trading permission.
- Your organization provisioned with at least one provider who streams RFS prices.


## Steps

```mermaid
flowchart TD
  LOGIN(Step 1: Login) --> REQUEST(Step 2: Request quote) --> QUERYREQUESTSTATUS(Step 3: Query request for status) --> ACCEPTQUOTE(Step 4: Accept quote) --> QUERYREQUESTTRADES(Step 5: Query request for trades)
  click LOGIN "#step-1-login"
  click REQUEST "#step-2-request-quote"
  click QUERYREQUESTSTATUS "#step-3-query-quote-request-for-status"
  click ACCEPTQUOTE "#step-4-accept-quote"
  click QUERYREQUESTTRADES "#step-5-query-quote-request-for-trades"
```

### Step 1: Login

Use the [Login and get token](/openapi/integral-api-reference/rest/authentication-api/login) endpoint.

See the related [Login](/developer-portal/tutorials/tutorialauth/) tutorial.

Your access token is in `SSO_TOKEN` of the response header. Your token is valid for limited time.

Pass the `SSO_TOKEN` cookie value with all of your subsequent API requests.

```json Payload application/json
{
  "user": "apiUserId",
  "pass": "This is a long password!",
  "org": "apiOrganizationId"
}
```

### Step 2: Request quote

Use the [Request quote](/openapi/integral-api-reference/rest/rfsrfq/quoterequest) endpoint.

You must query your request for its status. After the initial success/fail response, status updates are not pushed to you.

```json Payload application/json
{
  "clOrderId": "view1MultiLP5",
  "symbol": "EUR/USD",
  "amount": 1000000,
  "dealtCurrency": "EUR",
  "expiry": 140,
  "nearValueDate": "1W",
  "farDealtAmount": 1000000,
  "farValueDate": "2W",
  "side": "TWO_WAY",
  "priceType": "FwdFwd",
  "customerAccount": "pfOrgLE",
  "customerOrg": "pfOrg",
  "providers": [
    "ProvA",
    "ProvB",
    "ProvC"
  ]
}
```

### Step 3: Query quote request for status

Use the [Query quote request](/openapi/integral-api-reference/rest/rfsrfq/queryrequestclientid) endpoint.

Query the state of quote request by the RFS ID `clOrderId` assigned by you when you sent the request. The response can include quotes and state of the quote request.

```javascript JavaScript
const query = new URLSearchParams({
  clOrderId: 'view1MultiLP5'
}).toString();

const resp = await fetch(
  `/v2/rfs?${query}`,
  {
    method: 'GET',
    headers: {
      SSO_TOKEN: 'YOUR_API_KEY_HERE'
    }
  }
);

const data = await resp.text();
console.log(data);
```

### Step 4: Accept quote

Use the [Accept quote](/openapi/integral-api-reference/rest/rfsrfq/acceptquote) endpoint.

Accept a quote with the request ID assigned by Integral returned in `requestId` of the [query quote response](#responseWithQuotes).

You must query your quote request to get any trades after accepting the quote.

```json Payload application/json
{
  "quoteId": "G-4796976cf-17b1781b062",
  "side": "BUY",
  "symbol": "GBP/USD",
  "dealtCurrency": "USD",
  "clOrderId": "view1MultiLP5"
}
```

### Step 5: Query quote request for trades

Use the [Query quote request](/openapi/integral-api-reference/rest/rfsrfq/queryrequestclientid) endpoint.

After you accept a quote, you must query your quote request to get any trades.

```javascript JavaScript
const query = new URLSearchParams({
  clOrderId: 'view1MultiLP5'
}).toString();

const resp = await fetch(
  `/v2/rfs?${query}`,
  {
    method: 'GET',
    headers: {
      SSO_TOKEN: 'YOUR_API_KEY_HERE'
    }
  }
);

const data = await resp.text();
console.log(data);
```