Skip to main content

Requesting Portfolios

Learn how to use the API to obtain portfolio metadata

Written by Edgar Nuñez

This article assumes that your account has API access enabled and you have reviewed the article Developing with the Omega Point API.

Below is a simple cURL command to retrieve the IDs and names of the portfolios in your account.

curl \
    -XPOST \
    -H "Content-Type:application/json" \
    -H "Authorization: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
    -d '{"query": "query { portfolios { id, name } }"}' \
    https://api.ompnt.com/graphql

To simplify this a bit, let's set a bash variable for the authorization section of the request:

queryAuth="Authorization: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

This variable can then be inserted into the cURL command:

curl \
    -XPOST \
    -H "Content-Type:application/json" \
    -H "${queryAuth}" \
    -d '{"query": "query { portfolios { id, name } }"}' \
    https://api.ompnt.com/graphql

Sample Response:

{
    "data": {
        "portfolios": [
            {
                "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
                "name": "Portfolio1"
            },
            {
                "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
                "name": "Portfolio2"
            }
        ]
    }
}

You can use these results for locating the appropriate portfolio ID to be used in later requests.

Did this answer your question?