# OScore Open API

**OScore** is a digital asset score that is calculated based on the assigned to each wallet account on the Ontology chain. The score can be queried by sending requests to the following public APIs.

## Request Particulars

1. The `timestamp` sent in the request is only valid for **30 seconds**. In case this threshold is exceeded the error code `62020` will be sent in the response.
2. The request needs to be signed by the respective **ONT ID**. The back end carries out signature verification. If verification fails, the `62006` error code will be sent in response.
3. The ONT ID and timestamp are concatenated together to obtain the signature content. The signature is a `base64` string. For example, for `ont_id=did:ont:AaRxdnJA5mArpFr1CA7RhT9AYrXdRgNqWm` and `timestamp=1596164819`, the ONT ID's private key is used to sign the signature data and generate the base64 string. The data to be signed is `did:ont:AaRxdnJA5mArpFr1CA7RhT9AYrXdRgNqWm1596164819`

{% hint style="info" %}
The base URL used to send the requests is [**`https://service.onto.app/S5`**](https://service.onto.app/S5)
{% endhint %}

## Fetch User's Asset Score

This method can be used to fetch a user's asset score by passing the ONT ID.

**Method:** POST

**URL:** `/v2/ontoservice/asset_score`

**Request:**

```javascript
{
  "ont_id": "did:ont:AaRxdnJA5mArpFr1CA7RhT9AYrXdRgNqWm",
  "signature": "AYAMGuzl1lh4VQ6PbIQIa2M....fvs6VIfhBfYD4HkqqIGE=",
  "timestamp": 1596164819 // UNIX timestamp
}
```

**Response:**

```javascript
{
  "Action": "",
  "Error": 0,
  "Desc": "SUCCESS",
  "Version": "1.0",
  "Result": {
    "score": "400"
  }
}
```

## Fetch User's Asset Score Details

This method can be used to fetch details regarding a user's asset score by passing the ONT ID.

**Method:** POST

**URL:** `/v2/ontoservice/asset_score/detail`

**Request:**

```javascript
{
  "ont_id": "did:ont:AaRxdnJA5mArpFr1CA7RhT9AYrXdRgNqWm",
  "signature": "AYAMGuzl1lh4VQ6PbIQIa2M....fvs6VIfhBfYD4HkqqIGE=",
  "timestamp": 1596164819
}
```

**Response:**

```javascript
{
  "Action": "",
  "Error": 0,
  "Desc": "SUCCESS",
  "Version": "1.0",
  "Result": {
    "snapshot_asset_avg_usd": "0",
    "asset_usd": "0",
    "exchange_asset_usd": "0"
  }
}
```

|           Field           |  Type  | Description                                       |
| :-----------------------: | :----: | ------------------------------------------------- |
| snapshot\_asset\_avg\_usd | String | Daily average asset value for all accounts in USD |
|         asset\_usd        | String | Current asset value in USD                        |
|    exchange\_asset\_usd   | String | Total assets in exchange wallet accounts in USD   |
