# Get normalized portfolio state

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://api.g.alchemy.com/hypercore/v1/{apiKey}/portfolio-state

Retrieve a normalized portfolio-state composite for a user. Coming with HyperCore; this route is not yet callable.


Reference: https://www.alchemy.com/docs/data/hypercore/rest-api/hyper-core-data-api-endpoints/get-portfolio-state

## Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| apiKey | string | Yes |  |

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://api.g.alchemy.com/hypercore/v1/string/portfolio-state \
  --header 'Content-Type: application/json' \
  --data '{
  "user": "string",
  "startTime": 1,
  "endTime": 1,
  "cursor": "string",
  "include": [
    "string"
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    user: 'string',
    startTime: 1,
    endTime: 1,
    cursor: 'string',
    include: ['string']
  })
};

fetch('https://api.g.alchemy.com/hypercore/v1/string/portfolio-state', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.g.alchemy.com/hypercore/v1/string/portfolio-state"

payload = {
    "user": "string",
    "startTime": 1,
    "endTime": 1,
    "cursor": "string",
    "include": ["string"]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.g.alchemy.com/hypercore/v1/string/portfolio-state"

	payload := strings.NewReader("{\n  \"user\": \"string\",\n  \"startTime\": 1,\n  \"endTime\": 1,\n  \"cursor\": \"string\",\n  \"include\": [\n    \"string\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://api.g.alchemy.com/hypercore/v1/string/portfolio-state")
  .header("Content-Type", "application/json")
  .body("{\n  \"user\": \"string\",\n  \"startTime\": 1,\n  \"endTime\": 1,\n  \"cursor\": \"string\",\n  \"include\": [\n    \"string\"\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://api.g.alchemy.com/hypercore/v1/string/portfolio-state");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"user\": \"string\",\n  \"startTime\": 1,\n  \"endTime\": 1,\n  \"cursor\": \"string\",\n  \"include\": [\n    \"string\"\n  ]\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## Operation Specification

```yaml
path: /{apiKey}/portfolio-state
method: POST
operation:
  operationId: get-portfolio-state
  summary: Get normalized portfolio state
  description: |
    Retrieve a normalized portfolio-state composite for a user. Coming with HyperCore; this route is not yet callable.
  parameters:
    - name: apiKey
      in: path
      required: true
      schema:
        type: string
  requestBody:
    required: true
    content:
      application/json:
        schema:
          type: object
          required:
            - user
          properties:
            user:
              type: string
              pattern: ^0x[a-fA-F0-9]{40}$
              description: EVM-style account address.
            startTime:
              type: integer
              format: int64
              description: Unix timestamp in milliseconds.
            endTime:
              type: integer
              format: int64
              description: Unix timestamp in milliseconds.
            cursor:
              type: string
              description: Opaque cursor. Store and return it unmodified; its format may change.
            include:
              type: array
              items:
                type: string
        examples:
          default:
            value:
              user: '0x1111111111111111111111111111111111111111'
              include:
                - positions
                - balances
                - margin
  responses:
    '200':
      description: Successful response.
      content:
        application/json:
          schema:
            type: object
            properties:
              user:
                type: string
                pattern: ^0x[a-fA-F0-9]{40}$
                description: EVM-style account address.
              asOf:
                type: integer
                format: int64
                description: Unix timestamp in milliseconds.
              perpetual:
                type: object
                additionalProperties: true
              spot:
                type: object
                additionalProperties: true
              margin:
                type: object
                additionalProperties: true
          examples:
            default:
              value:
                user: '0x1111111111111111111111111111111111111111'
                asOf: 1780000000000
                perpetual:
                  accountValue: '1000.00'
                  positions: []
                spot:
                  balances: []
                margin:
                  totalMarginUsed: '100.00'
```
