Request

Response

    Beta APIs are subject to change. Please avoid using them in production environments.

    Access Data Using Exchange Container

    This tutorial will allow you, having the Collection ID and Exchange ID found within the exchange container, to further use the Data Exchange API to retrieve assets, relationships, snapshots, and revisions:

    Intro

    As mentioned at the end of Access exchange container tutorial, all Data Exchange APIs contain the path v1/collections/{collectionId}/exchanges/{exchangeId}/ and consequently require the following attributes:

    • Exchange ID - the ID of the exchange container;
    • Collection ID - the ID of the collection where the exchange data is stored.

    You can find these two IDs within the exchange container that can be retrieved by following the Access exchange container tutorial.

    Workflow explanation

    An exchange container is the entry point for exchange data that consists of collection of assets connected through relationships and forming a graph whose states are captured into snapshots. A more in-depth walk through the data, how it’s structured, and what information it holds is discussed in the next tutorial, while here you can concentrate on ways of retrieving the data.

    There are two ways of retrieving the data as follows:

    1. Download all data for processing on the client side;
    2. Download only parts you need by specifying filters or using the closure queries.

    1. Download all data for processing on the client side

    Downloading the entire data is intuitive, and each type of entity (e.g., assets, relationships, or snapshots) has its own endpoint:

    a. Downloading assets

    To download the assets, use v1/collections/{collectionId}/exchanges/{exchangeId}/assets:sync, and apply a token with the data:read scope as follows:

    curl 'https://developer.api.autodesk.com/exchange/v1/collections/'$COLLECTION_ID'/exchanges/'$EXCHANGE_ID'/assets:sync' \
    --header 'Authorization: Bearer '$TOKEN
    

    where TOKEN is the env variable holding your access token, and COLLECTION_ID with EXCHANGE_ID are the IDs retrieved from the exchange container.

    The above call provides a response similar to the following:

    {
        "pagination": {
            "cursor": "7b22637...7d",
           ...
        },
        "results": [
            {
                "createdBy": {
                    "serviceId": "CsBcAd522LYGDZmszDtALE8iuzpKPtXX",
                    "date": "2021-12-22T21:08:42.225778Z"
                },
                "lastModifiedBy": {
                    "serviceId": "CsBcAd522LYGDZmszDtALE8iuzpKPtXX",
                    "date": "2021-12-22T21:08:42.225778Z"
                },
                "id": "6B0A5D3C0C0FA85885A89FAED0C1AD9691D29AB9",
                "revisionId": "1640207302775_a3fa4471-229c-3265-818d-d2c87dbf2a8d",
                "type": "autodesk.design:assets.instance-1.0.0",
                "space": {
                    "id": "c7006ecd-d76c-3ad1-9afc-963d8232708b",
                    "url": "/collections/co.cjm3cQPdRBGKft6IWqTDdQ/spaces/c7006ecd-d76c-3ad1-9afc-963d8232708b"
                },
                "attributes": {},
                "components": {},
                "operation": "INSERT"
            },
            ...
        ],
        "root": "1F27591A01D9596B97522612977B7BCF88F33EA0"
    }
    
    Show More

    For brevity, the output was trimmed. You can see more details on asset data in the next tutorial, but for now, the most important thing to understand is that you get back pages of results (by default, a page returns 100 assets). As long as the cursor field is not empty, a page to receive (having provided the cursor as a query parameter) is like the following:

    curl --location --request GET 'https://developer.api.autodesk.com/exchange/v1/collections/co.cjm3cQPdRBGKft6IWqTDdQ/exchanges/474b17e1-0a39-3577-a349-0dccfd8680f4/assets:sync?cursor='$CURSOR \
    --header 'Authorization: Bearer '$TOKEN
    

    This kind of sequential query could be daunting, especially if the source view contains many elements. You can expect hundreds of elements which require dozens of sequential calls to retrieve all the data.

    For this very purpose, there is a way to facilitate a parallel retrieval of data by calling v1/collections/{collectionId}/exchanges/{exchangeId}/assets:sync-urls as follows:

    curl 'https://developer.api.autodesk.com/exchange/v1/collections/'$COLLECTION_ID'/exchanges/'$EXCHANGE_ID'/assets:sync-urls' \
    --header 'Authorization: Bearer '$TOKEN
    

    This call requests the data in the form of a list of URLs to pages containing the data, creating an output similar to the following:

    {
      "pagination": {
        "cursor": "",
        "nextUrl": ""
      },
      "results": [
        {
          "url": "https://developer.api.autodesk.com/exchange/v1/collections/co.xx/exchanges/xx/assets:sync?cursor=xx"
        }
      ],
      "root": "8AD0A128DA7B216DF3ADJB316C32FD24C525DCA7"
    }
    
    Show More

    These URLs can then be used concurrently to get all the pages and concatenate the results, increasing the speed of retrieving the data.

    At first sight, the assets:sync-urls (parallel) way of retrieving data seems to be the best, but paginated approach assets:sync has its own benefits too.

    TIP: In case you expect to get a lot of assets as a result of the request, the best approach is to use the assets:sync-urls to get the list of pages. However, in case you expect a smaller number of assets (e.g., when using filters), it’s more optimal to use assets:sync returning a single page of results.

    b. Downloading relationships

    To download the relationships, use v1/collections/{collectionId}/exchanges/{exchangeId}/relationships:sync, and apply a token with the data:read scope:

    curl 'https://developer.api.autodesk.com/exchange/v1/collections/'$COLLECTION_ID'/exchanges/'$EXCHANGE_ID'/relationships:sync' \
    --header 'Authorization: Bearer '$TOKEN
    

    The above call provides a response similar to the following:

    {
        "pagination": {
            "cursor": "7b226...764227d",
            ...
        },
        "results": [
            {
               ...
                "id": "031ea155-28de-389e-b519-59ab68b0bf4c",
                "type": "autodesk.design:relationship.containment-1.0.0",
                "from": {
                    "asset": {
                        "id": "1F27591A01D9596B97522612977B7BCF88F33EA0",
                        "url": "/collections/co.cjm...dQ/assets/1F275....CF88F33EA0"
                    }
                },
                "to": {
                    "asset": {
                        "id": "D5148FDAC14A89EFF21063A3816415608FB3D2A9",
                        "url": "/collections/co.cjm...dQ/assets/D5148F....5608FB3D2A9"
                    }
                },
                "category": "REL",
                "revisionId": "1640207302775_a3fa4471-229c-3265-818d-d2c87dbf2a8d",
                "operation": "INSERT",
                "attributes": {},
                "components": {}
            },
    
        ],
        "root": "1F27591A01D9596B97522612977B7BCF88F33EA0"
    }
    
    Show More

    The results in the structure are similar to those when getting the assets. The same options are also available when retrieving the full data, either iterating through paginated results relationships:sync using the cursor, or using the relationships:sync-urls to get the links to data pages for concurrent retrieving. The structure of relationships:sync-urls results is similar to that of assets:sync-urls, and is omitted here.

    2. Download only parts you need by specifying filters or using the closure queries

    In case of assets and relationships, even for smaller designs, the number of entities will be quite big.

    The approach of downloading everything (assets:sync and relationships:sync) and dealing with it on the client side is a viable approach, and it’s facilitated by an option of getting everything concurrently through a provided list of URLs (assets:sync-urls and relationships:sync-urls).

    However, a lot of effort and time can be saved if everything is performed at a server level, especially when you know what you’re looking for.

    To perform search and retrieve on the server side, there are two approaches as follows:

    1. Use filtering when creating requests;
    2. Use closure-queries for a more advanced search.

    Let’s dive deeper into each approach to better understand their benefits and limitations:

    a. Use filtering when creating requests

    To be able to use filtering at its best, it’s important to know the structure of an entity. In context of the Data Exchange,- collections, scenes, assets, relationships, and snapshots are the named entities and have the same kernel:

    {
        "id": "123abc",
        "type": "autodesk.fdx:exchange.<<entity>>-1.0.0",
        "attributes": {
            "id": "123abc",
            "url": "<<path>>/attributes",
            "data": []
        },
        "components": {
            "id": "123abc",
            "url": "<<path>>/components",
            "data": {}
        }
    }
    
    Show More

    Thus, the common and important parts of any entity type, besides its id, are the attributes and components. The attributes are mainly used to store key-value system data. Components, on the other hand, is the place where the properties of the model parts are stored using a certain schema.

    NOTE: For the time being, the filtering which uses attributes and components is limited, but soon it will be extended.

     
    ______
    icon-svg-close-thick

    Cookie preferences

    Your privacy is important to us and so is an optimal experience. To help us customize information and build applications, we collect data about your use of this site.

    May we collect and use your data?

    Learn more about the Third Party Services we use and our Privacy Statement.

    Strictly necessary – required for our site to work and to provide services to you

    These cookies allow us to record your preferences or login information, respond to your requests or fulfill items in your shopping cart.

    Improve your experience – allows us to show you what is relevant to you

    These cookies enable us to provide enhanced functionality and personalization. They may be set by us or by third party providers whose services we use to deliver information and experiences tailored to you. If you do not allow these cookies, some or all of these services may not be available for you.

    Customize your advertising – permits us to offer targeted advertising to you

    These cookies collect data about you based on your activities and interests in order to show you relevant ads and to track effectiveness. By collecting this data, the ads you see will be more tailored to your interests. If you do not allow these cookies, you will experience less targeted advertising.

    icon-svg-close-thick

    THIRD PARTY SERVICES

    Learn more about the Third-Party Services we use in each category, and how we use the data we collect from you online.

    icon-svg-hide-thick

    icon-svg-show-thick

    Strictly necessary – required for our site to work and to provide services to you

    Qualtrics
    W
    Akamai mPulse
    W
    Digital River
    W
    Dynatrace
    W
    Khoros
    W
    Launch Darkly
    W
    New Relic
    W
    Salesforce Live Agent
    W
    Wistia
    W
    Tealium
    W
    Upsellit
    W
    CJ Affiliates
    W
    Commission Factory
    W
    Google Analytics (Strictly Necessary)
    W
    Typepad Stats
    W
    Geo Targetly
    W
    SpeedCurve
    W
    Qualified
    #

    icon-svg-hide-thick

    icon-svg-show-thick

    Improve your experience – allows us to show you what is relevant to you

    Google Optimize
    W
    ClickTale
    W
    OneSignal
    W
    Optimizely
    W
    Amplitude
    W
    Snowplow
    W
    UserVoice
    W
    Clearbit
    #
    YouTube
    #

    icon-svg-hide-thick

    icon-svg-show-thick

    Customize your advertising – permits us to offer targeted advertising to you

    Adobe Analytics
    W
    Google Analytics (Web Analytics)
    W
    AdWords
    W
    Marketo
    W
    Doubleclick
    W
    HubSpot
    W
    Twitter
    W
    Facebook
    W
    LinkedIn
    W
    Yahoo! Japan
    W
    Naver
    W
    Quantcast
    W
    Call Tracking
    W
    Wunderkind
    W
    ADC Media
    W
    AgrantSEM
    W
    Bidtellect
    W
    Bing
    W
    G2Crowd
    W
    NMPI Display
    W
    VK
    W
    Adobe Target
    W
    Google Analytics (Advertising)
    W
    Trendkite
    W
    Hotjar
    W
    6 Sense
    W
    Terminus
    W
    StackAdapt
    W
    The Trade Desk
    W
    RollWorks
    W

    Are you sure you want a less customized experience?

    We can access your data only if you select "yes" for the categories on the previous screen. This lets us tailor our marketing so that it's more relevant for you. You can change your settings at any time by visiting our privacy statement

    Your experience. Your choice.

    We care about your privacy. The data we collect helps us understand how you use our products, what information you might be interested in, and what we can improve to make your engagement with Autodesk more rewarding.

    May we collect and use your data to tailor your experience?

    Explore the benefits of a customized experience by managing your privacy settings for this site or visit our Privacy Statement to learn more about your options.