Skip to content

Search by capture

Search for an Outcome ID

This guide demonstrates how to retrieve metadata and imagery for a known Outcome ID using the Archive Service via the STAC API.

The following Python script connects to the STAC API, searches for a known Outcome ID, prints metadata, and downloads the preview image if available.

You must have a valid Bearer token and a Contract ID. If you're unsure how to authenticate, refer to ourAuthentication Getting Started guide.

Configuration and imports

Requirements for this demo:

To start, include the packages that we are going to need:

from pystac_client import Client
import requests

Replace with your actual credentials and Outcome ID

token = "YOUR_BEARER_TOKEN"
contract_id = "YOUR_CONTRACT_ID"
outcome_id = "cfa879d1-f136-4ac6-ba2f-639f329b2d23"

Performing the query and preparing the data

Then, let's create a connection to the archive API.

STAC_API_URL = "https://api.satellogic.com/archive/stac/"


headers = {
    "authorizationToken": f"Bearer {token}",
    "X-Satellogic-Contract-Id": contract_id,
    "Content-Type": "application/json",
}


client = Client.open(STAC_API_URL, headers=headers)

Now let's search for that outcome id so let's define one:

outcome_id = "cfa879d1-f136-4ac6-ba2f-639f329b2d23"

search = client.search(
    filter_lang="cql2-json",
    filter={
        "op": "=",
        "args": [
            { "property": "satl:outcome_id" },
            outcome_id
        ]
    },
    collections=["quickview-visual-thumb"]
)

Now, let's get this outcome id's metadata

for item in search.get_items():
    print("STAC Item ID:", item.id)
    print("Datetime:", item.datetime)
    print("Geometry:", item.geometry)
    print("Available assets:", list(item.assets.keys()))
    print("Full metadata:", item.to_dict())


    asset = item.assets.get("preview")
    if asset:
        asset_href = asset.href
        print(f"Downloading from: {asset_href}")
        response = requests.get(asset_href, headers=headers)
        filename = "preview_image.png"
        with open(filename, "wb") as f:
            f.write(response.content)
        print(f"Image saved as {filename}")
    else:
        print("No 'preview' asset found for this item.")

We appreciate your feedback so if there is anything that is not clear or that you think might help if added, please let us know.